Devices & Components
40 colored male-male jumper wires
Arduino Uno Rev3
Power Connector to 2 Screw Terminal Female Adapter
24V 5A Power Supply
Linear Stage Actuator with NEMA23 Stepper Motor
Arduino Connector Cable
DM332T Leadshine Digital Stepping Driver (Microstepper Driver)
Hardware & Tools
Digilent Screwdriver
Software & Tools
Arduino IDE
Project description
Code
Github Code
Code For Controlling Stepper Motor with DM332T Dri
DM332TStepperMotorArduino
cpp
Arduino code to control stepper motor with DM332T
1//Code By: Bo Bowman 2//Updated: July 2023 3 4//WIRING: 5//Connect Red wire of NEMA23 motor to A+ on the DM332T Stepping driver 6//Connect Green wire of NEMA23 motor to A- on the DM332T Stepping driver 7//Connect Yellow wire of NEMA23 motor to B+ on the DM332T Stepping driver 8//Connect Blue wire of NEMA23 motor to B- on the DM332T Stepping driver 9//Connect Pin ~9 of Arduino to PUL on the DM332T Stepping driver 10//Connect Pin 8 of Arduino to DIR on the DM332T Stepping Driver 11//Connect Pin 7 of Arduino to ENA on the DM332T Stepping Driver 12//Connect Red (+) of Power Supply to +Vdc on the DM332T Stepping Driver 13//Connect Black (-) of Power Supply to GND on the DM332T Stepping Driver 14 15//TIPS: 16//Use digilent screwdriver to screw/unscrew the terminal blocks on the DM332T to connect jumper wires 17//Use a power jack to 2 terminal block connector/adapter to connect jumper wires to your power supply 18 19//TROUBLESHOOTING: 20//If motor is not moving, ensure the green indicator is turned on for the DM332T PWR. If it isn't, there's an issue with your power supply. Also check the Pulse/rev, your motor might just be turning super slow. 21//If motor is only moving in one direction, check wiring connection to ENA. If that still doesn't work, change the signal sent from HIGH to LOW to the ENA from Arduino pin 7. 22//The DM332T instruction manual is confusing regarding ENA; for Arduino, the ENA should be connected to an Arduino pin set to HIGH (+5V) in order for the motor to switch directions using the DIR pin 23 24//Work Attribution: V-Slot, NEMA connection to motor driver https://vslot-poland.com/how-to-connet-arduino-to-nema 25 26int x; 27 28void setup() { 29 // put your setup code here, to run once: 30 pinMode(7,OUTPUT); //enable, ENA 31 pinMode(9,OUTPUT); //pulse, PUL 32 pinMode(8,OUTPUT); //direction, DIR, used to be pin 8 33 Serial.begin(9600); 34 35 digitalWrite(7,HIGH); //set to ENABLE 36 37} 38 39 40void loop() { 41 // put your main code here, to run repeatedly: 42 43 digitalWrite(8,HIGH); //set direction "go backwards" 44 45 Serial.println("Pin 8 DIR has now been set to on HIGH"); 46 delayMicroseconds(1500); 47 48 delayMicroseconds(500); //wait (pause) for 500 microseconds 49 for(x=0;x<80;x++) //this loop dictates the distance it travels (or maybe the time that it travels??) 50 51 { 52 digitalWrite(9,HIGH); //pulse (move) the motor 53 delayMicroseconds(500); //wait (pause) for 500 microseconds 54 55 digitalWrite(9,LOW); //stop the motor 56 delayMicroseconds(500); //wait (pause) for 500 microseconds 57 58 } 59 delayMicroseconds(500); 60 delay(1000); 61 62 digitalWrite(8,LOW); //Set direction to be the opposite way 63 64 Serial.println("Pin 8 DIR has been being set to on LOW"); 65 delayMicroseconds(1500); 66 67 delayMicroseconds(500); //wait (pause) for 500 microseconds 68 for(x=0;x<80;x++) //this loop dictates the distance it travels. 69 { 70 digitalWrite(9,HIGH); //pulse (move) the motor 71 delayMicroseconds(500); //wait (pause) for 500 microseconds 72 digitalWrite(9,LOW); //stop the motor 73 delayMicroseconds(500); //wait (pause) for 500 microseconds 74 75 } 76 77delay(1000); 78 79}
Downloadable files
Wiring Instructions
How to wire the Arduino, stepper motor, and driver
Wiring Instructions DM332T Motor Stepper Arduino.pdf
Comments
Only logged in users can leave comments