Laser Cutter Stepper Motor Control Code

Stepper motors are the most precise motors available. You can order them to move exactly 1.8/16 = 0.1125 degrees/step in each direction. Although this can depend on the motortype. These orders are given out in the form of PWM signals. These signals are square signal. You can read more about PWM on the internet. Everytime the signal jumps to HIGH state the motor turns a step. Our stepper motor devicehandler can control multiple stepper motors simultaneously. It is also capable to handle two endstops for each motor, which are capable to keep the motors moving between a minimum and maximum range.

Required hardware

  • Stepper Motors (2)
  • Stepper Motor Drivers (2)
  • Micro Switches (2)
  • Power Supply (1)
  • Laser Cutter Controller Board (1)

Source code to install on controller


Before you upload this code to your Arduino, please format the EEPROM...
#include <OzIDManager.h>
#include <OzMotorMultiController.h>
#include <OzSwitchController.h>

OzIDManager* manager;
OzMotorMultiController* motorController;
OzButtonController* endStopXMin;
OzButtonController* endStopYMin;
OzSwitchController* switchController;

void setup() {
  Serial.begin(115200);

  manager = new OzIDManager;
  manager->_sendACK = true;
  manager->_checksum = true;

  OzCommunication::setIDManager(manager);

  endStopXMin = new OzButtonController(3, CHANGE);
  endStopYMin = new OzButtonController(2, CHANGE);

  endStopXMin->_flipped = true;
  endStopYMin->_flipped = true;

  motorController = new OzMotorMultiController(PinPreset::LASERCUTTER);

  motorController->addEndStop(AXIS::X, EndPoint::MIN, endStopXMin);
  motorController->addEndStop(AXIS::Y, EndPoint::MIN, endStopYMin);

  switchController = new OzSwitchController(10);

  int x = 1;
  manager->sendLinkSetup();
  manager->PrintWelcomeLine(motorController, x++, "MyStepperMotors");
  manager->PrintWelcomeLine(endStopXMin, x++, "MyEndStopX");
  manager->PrintWelcomeLine(endStopYMin, x++, "MyEndStopY");
  manager->PrintWelcomeLine(switchController, x++, "MyLaser");
}

void loop() {
  OzCommunication::communicate();
  motorController->ownLoop();
}

More information