void motorMove (u8 motionID, u8 stCh, u32 position)
motionID : The ID of the Motion Control Module |
stCh: The channel on the Motion Control Module (0 or 1) |
position: The position, in steps, to move the motor to. |
Moves the motor specified by motionID and stCh to the specified position. If position is the same as the current position, the motor will not move. If position is less than the current position, the motor will move backwards. If position is greater than the current position, the motor will move forward. The current position can be set to 0 using the setMotorPos function.
#include "moacon500.h" //Waits for motor to finish moving void motorWaitToFinish(u8 motionId, u8 stChannel) { //Get the current number of pulses left to send u32 pulseCount = motorStat(motionId, stChannel); //While there are still pulses remaining (i.e. the motor is still moving) while(pulseCount > 0) { //Get the current number of pulses left to send pulseCount = motorStat(motionId, stChannel); //Print the number of pulses remaining to the debug console printf("%d pulses remaining\r\n", pulseCount); delay(500); //Give the CPU a break. } } void cmain(void) { motorSetup(0, 0, 500, 5000, 1000); //Initialize the motor setMotorPos(0,0,0); //Current position is starting position motorMove(0,0,100000); //Move the motor to position 100,000 motorWaitToFinish(0,0); //Wait for the motor to finish moving motorMove(0,0,0); //Move motor back to starting position motorWaitToFinish(0,0); //Wait for the motor to finish moving }