![](/media/cache/group/Download.jpg.50x50_q85.jpg)
6.13 Schrittmotor bis zum Endschalter laufen lassen, Nullpunkt setzen, 10 x 100 Schritte vorwärts und in einem Lauf zurück auf die Nullposition. Zusätzlich einen Button als Notaus (Soforthalt) vorsehen. Anwendung: 3D Drucker, Plotter, CNC Fräse.
Dependencies: StepperMotorUni mbed
Fork of IoTKit_StepperMotor by
main.cpp@2:a0607b1417da, 2015-03-04 (annotated)
- Committer:
- marcel1691
- Date:
- Wed Mar 04 16:35:56 2015 +0000
- Revision:
- 2:a0607b1417da
- Parent:
- 1:1330fe477c67
6.13 Schrittmotor bis zum Endschalter laufen lassen, Nullpunkt setzen, 10 x 100 Schritte vorw?rts ; und in einem Lauf zur?ck auf die Nullposition. Zus?tzlich einen Button als Notaus (Soforthalt) vorsehen.; Anwendung: 3D Drucker, Plott
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcel1691 | 2:a0607b1417da | 1 | /** 6.13 Schrittmotor bis zum Endschalter laufen lassen, Nullpunkt setzen, 10 x 100 Schritte vorwärts |
marcel1691 | 2:a0607b1417da | 2 | und in einem Lauf zurück auf die Nullposition. Zusätzlich einen Button als Notaus (Soforthalt) vorsehen. |
marcel1691 | 2:a0607b1417da | 3 | Anwendung: 3D Drucker, Plotter, CNC Fräse. |
okano | 0:ae2206213141 | 4 | */ |
okano | 0:ae2206213141 | 5 | |
okano | 0:ae2206213141 | 6 | #include "mbed.h" |
okano | 0:ae2206213141 | 7 | #include "StepperMotorUni.h" |
okano | 0:ae2206213141 | 8 | |
marcel1691 | 2:a0607b1417da | 9 | // Schrittmotor |
marcel1691 | 2:a0607b1417da | 10 | StepperMotorUni motor( PTB18, PTB19, PTC1, PTC8 ); |
marcel1691 | 2:a0607b1417da | 11 | // Endabschalter |
marcel1691 | 2:a0607b1417da | 12 | DigitalIn home( A3, PullUp ); |
marcel1691 | 2:a0607b1417da | 13 | // Notstop |
marcel1691 | 2:a0607b1417da | 14 | DigitalIn stop ( PTC9, PullUp ); |
okano | 0:ae2206213141 | 15 | |
okano | 0:ae2206213141 | 16 | int main() |
okano | 0:ae2206213141 | 17 | { |
marcel1691 | 1:1330fe477c67 | 18 | // Motordrehzahl |
marcel1691 | 2:a0607b1417da | 19 | printf( "Schrittmotor Test\n" ); |
marcel1691 | 1:1330fe477c67 | 20 | motor.set_pps( 300 ); |
okano | 0:ae2206213141 | 21 | |
marcel1691 | 1:1330fe477c67 | 22 | while ( 1 ) |
marcel1691 | 1:1330fe477c67 | 23 | { |
marcel1691 | 2:a0607b1417da | 24 | printf( "vorwaerts\n" ); |
marcel1691 | 2:a0607b1417da | 25 | int steps = 10; |
marcel1691 | 2:a0607b1417da | 26 | for ( int i = 0; i < 2048; i += steps ) |
marcel1691 | 2:a0607b1417da | 27 | { |
marcel1691 | 2:a0607b1417da | 28 | motor.move_steps( steps ); |
marcel1691 | 2:a0607b1417da | 29 | if ( home == 0 ) |
marcel1691 | 2:a0607b1417da | 30 | break; |
marcel1691 | 2:a0607b1417da | 31 | if ( stop == 0 ) |
marcel1691 | 2:a0607b1417da | 32 | return( -1 ); |
marcel1691 | 2:a0607b1417da | 33 | wait( 0.1 ); |
marcel1691 | 2:a0607b1417da | 34 | } |
okano | 0:ae2206213141 | 35 | |
marcel1691 | 2:a0607b1417da | 36 | printf( "rueckwaerts\n" ); |
marcel1691 | 2:a0607b1417da | 37 | motor.move_steps( -1024 ); |
marcel1691 | 2:a0607b1417da | 38 | wait( 5.0 ); |
marcel1691 | 2:a0607b1417da | 39 | |
marcel1691 | 2:a0607b1417da | 40 | printf( "in die Mitte\n" ); |
marcel1691 | 2:a0607b1417da | 41 | motor.move_steps( 512 ); |
marcel1691 | 2:a0607b1417da | 42 | wait( 2.5 ); |
okano | 0:ae2206213141 | 43 | } |
okano | 0:ae2206213141 | 44 | } |