32#define motor ConnectorM0
38#define SerialPort ConnectorUsb
41int32_t velocityLimit = 10000;
42int32_t accelerationLimit = 100000;
47void MoveDistance(int32_t distance);
55 Connector::CPM_MODE_STEP_AND_DIR);
65 motor.VelMax(velocityLimit);
68 motor.AccelMax(accelerationLimit);
72 SerialPort.Mode(Connector::USB_CDC);
73 SerialPort.Speed(baudRate);
74 uint32_t timeout = 5000;
76 SerialPort.PortOpen();
77 while (!SerialPort &&
Milliseconds() - startTime < timeout) {
82 motor.EnableRequest(
true);
90 SerialPort.SendLine(
"Motor Ready");
100 MoveDistance(-12800);
123void MoveDistance(int32_t distance) {
124 SerialPort.Send(
"Moving distance: ");
125 SerialPort.SendLine(distance);
128 motor.Move(distance);
131 SerialPort.SendLine(
"Moving... Waiting for the step output to finish...");
132 while (!motor.StepsComplete()) {
136 SerialPort.SendLine(
"Steps Complete");
void Delay_ms(uint32_t ms)
Blocks operations for ms milliseconds.
Definition SysTiming.h:287
uint32_t Milliseconds(void)
Number of milliseconds since the ClearCore was initialized.
bool MotorInputClocking(MotorClockRates newRate)
Sets the output step rate for the motor step generators.
bool MotorModeSet(MotorPair motorPair, Connector::ConnectorModes newMode)
Sets the operational mode for the specified MotorDriver connectors.