Arduino Mega 2560
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
- Arduino Mega 2560
- RAMPS panel
- Stepper motor(s)
- Stepper Motor Driver(s)
- Micro Switche(s)
- Resistor(s) 1kΩ
- Power Supply
Source code to install on controller
Before you upload this code to your Arduino, please format the EEPROM...
#include <OzIDManager.h> #include <OzMotorMultiController.h> OzIDManager* manager; OzMotorMultiController* motorController; void setup() { Serial.begin(115200); manager = new OzIDManager; manager->_sendACK = true; manager->_checksum = true; OzCommunication::setIDManager(manager); motorController = new OzMotorMultiController(PinPreset::RAMPS_v14); int x=1; manager->sendLinkSetup(); manager->PrintWelcomeLine(motorController, x++, "MyStepperMotors"); } void loop() { OzCommunication::communicate(); motorController->ownLoop(); }
Pinpresets you can add to the source code:
new OzMotorMultiController(PinPreset::RAMPS_v14)
case PinPreset::RAMPS_v14: _number_of_motors = 4; _motors = new OzMotor[_number_of_motors]; // x _motors[0].setAxis(AXIS::X); _motors[0]._pin_step.set(A0); _motors[0]._pin_direction.set(A1); _motors[0]._pin_enable.set(38); _motors[0].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[0].disable(); // y _motors[1].setAxis(AXIS::Y); _motors[1]._pin_step.set(A6); _motors[1]._pin_direction.set(A7); _motors[1]._pin_enable.set(A2); _motors[1].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[1].disable(); // z _motors[2].setAxis(AXIS::Z); _motors[2]._pin_step.set(46); _motors[2]._pin_direction.set(48); _motors[2]._pin_enable.set(62); _motors[2].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[2].disable(); // e _motors[3].setAxis(AXIS::A); _motors[3]._pin_step.set(26); _motors[3]._pin_direction.set(28); _motors[3]._pin_enable.set(24); _motors[3].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[3].disable();
new OzMotorMultiController(PinPreset::GT2560)
case PinPreset::GT2560: _number_of_motors = 4; _motors = new OzMotor[_number_of_motors]; // x _motors[0].setAxis(AXIS::X); _motors[0]._pin_step.set(25); _motors[0]._pin_direction.set(23); _motors[0]._pin_enable.set(27); _motors[0].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[0]._isDirectionFlipped = true; _motors[0].disable(); // y _motors[1].setAxis(AXIS::Y); _motors[1]._pin_step.set(31); _motors[1]._pin_direction.set(33); _motors[1]._pin_enable.set(29); _motors[1].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[1].disable(); // z _motors[2].setAxis(AXIS::Z); _motors[2]._pin_step.set(37); _motors[2]._pin_direction.set(39); _motors[2]._pin_enable.set(35); _motors[2].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[2]._isDirectionFlipped = true; _motors[2].disable(); // e _motors[3].setAxis(AXIS::A); _motors[3]._pin_step.set(43); _motors[3]._pin_direction.set(45); _motors[3]._pin_enable.set(41); _motors[3].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[3]._isDirectionFlipped = true; _motors[3].disable();
new OzMotorMultiController(PinPreset::LASERCUTTER)
case PinPreset::LASERCUTTER: _number_of_motors = 2; _motors = new OzMotor[_number_of_motors]; // x _motors[0].setAxis(AXIS::X); _motors[0]._pin_step.set(12); _motors[0]._pin_direction.set(6); _motors[0]._isDirectionFlipped = true; _motors[0]._pin_enable.set(8); _motors[0].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[0].disable(); // y _motors[1].setAxis(AXIS::Y); _motors[1]._pin_step.set(11); _motors[1]._pin_direction.set(5); _motors[1]._pin_enable.set(7); _motors[1].setMicrostepping(MICROSTEP::SIXTEENTH); _motors[1].disable();