Update
Dependencies: mbed mbed-rtos X_NUCLEO_IHM02A1
Diff: STEPPER.cpp
- Revision:
- 36:ba2e7eddbafa
- Parent:
- 35:758191d5c6e1
- Child:
- 37:a74d377d8f74
--- a/STEPPER.cpp Sun May 05 16:18:20 2019 +0000 +++ b/STEPPER.cpp Wed May 08 09:35:40 2019 +0000 @@ -31,6 +31,31 @@ +/* --------------------------- Stop ----------------------------------------- */ +void Stepper_1_Stop() +{ + motors[0]->hard_stop(); + motors[0]->wait_while_active(); +} +void Stepper_2_Stop() +{ + motors[1]->hard_stop(); + motors[1]->wait_while_active(); +} +void Stepper_3_Stop() +{ + motors2[0]->hard_stop(); + motors2[0]->wait_while_active(); +} +void Stepper_4_Stop() +{ + motors2[1]->hard_stop(); + motors2[1]->wait_while_active(); +} +/* ---------------------------- END ----------------------------------------- */ + + + /* ---------------------- Setzte Home Position ------------------------------ */ void Stepper_1_SetHome() { @@ -197,3 +222,119 @@ motors2[1]->wait_while_active(); } /* ---------------------------- END ----------------------------------------- */ + + + +/* --------------------------------- MOVE ----------------------------------- */ +void Stepper_1_Move(char direction, unsigned int steps) +{ + if( direction == 'V') + { + motors[0]->move(StepperMotor::FWD, steps); + motors[0]->wait_while_active(); + } + else if ( direction == 'R') + { + motors[0]->move(StepperMotor::BWD, steps); + motors[0]->wait_while_active(); + } + +} +void Stepper_2_Move(char direction, unsigned int steps) +{ + if( direction == 'V') + { + motors[1]->move(StepperMotor::FWD, steps); + motors[1]->wait_while_active(); + } + else if ( direction == 'R') + { + motors[1]->move(StepperMotor::BWD, steps); + motors[1]->wait_while_active(); + } +} +void Stepper_3_Move(char direction, unsigned int steps) +{ + if( direction == 'V') + { + motors2[0]->move(StepperMotor::FWD, steps); + motors2[0]->wait_while_active(); + } + else if ( direction == 'R') + { + motors2[0]->move(StepperMotor::BWD, steps); + motors2[0]->wait_while_active(); + } +} +void Stepper_4_Move(char direction, unsigned int steps) +{ + if( direction == 'V') + { + motors2[1]->move(StepperMotor::FWD, steps); + motors2[1]->wait_while_active(); + } + else if ( direction == 'R') + { + motors2[1]->move(StepperMotor::BWD, steps); + motors2[1]->wait_while_active(); + } +} +/* ---------------------------- END ----------------------------------------- */ + + + +/* --------------------------------- RUN ------------------------------------ */ +void Stepper_1_Run(char direction, unsigned int speed) +{ + if( direction == 'V') + { + motors[0]->run(StepperMotor::FWD, speed); + motors[0]->wait_while_active(); + } + else if ( direction == 'R') + { + motors[0]->run(StepperMotor::BWD, speed); + motors[0]->wait_while_active(); + } + +} +void Stepper_2_Run(char direction, unsigned int speed) +{ + if( direction == 'V') + { + motors[1]->run(StepperMotor::FWD, speed); + motors[1]->wait_while_active(); + } + else if ( direction == 'R') + { + motors[1]->run(StepperMotor::BWD, speed); + motors[1]->wait_while_active(); + } +} +void Stepper_3_Run(char direction, unsigned int speed) +{ + if( direction == 'V') + { + motors2[0]->run(StepperMotor::FWD, speed); + motors2[0]->wait_while_active(); + } + else if ( direction == 'R') + { + motors2[0]->run(StepperMotor::BWD, speed); + motors2[0]->wait_while_active(); + } +} +void Stepper_4_Run(char direction, unsigned int speed) +{ + if( direction == 'V') + { + motors2[1]->run(StepperMotor::FWD, speed); + motors2[1]->wait_while_active(); + } + else if ( direction == 'R') + { + motors2[1]->run(StepperMotor::BWD, speed); + motors2[1]->wait_while_active(); + } +} +/* ---------------------------- END ----------------------------------------- */ \ No newline at end of file