/*
Stepper Motor Tester v2.2.2 @Kunal Panchal (MicroStepping)
Board - Arduino Uno R3
Test motor - Stepper motor from 0.1 - 10 Amps
Driver everelettronica LW3D2030N2A1 & LW3D3070N0A1
*/
//Config
int Pulse_Delay = 200; //Pulse Delay Min 10 micros to 49000 micros.
void setup() {
PORTD |= 0X20; //Direction Signal
}
void CW (){
PORTD |= 0X40; //Direction Signal
PORTD |= 0x80;
delayMicroseconds(Pulse_Delay);
PORTD &= 0X60;
delayMicroseconds(Pulse_Delay);
}
void CCW (){
PORTD &= 0x20;; //Direction Signal
PORTD |= 0x80;
delayMicroseconds(Pulse_Delay);
PORTD &= 0X20;
delayMicroseconds(Pulse_Delay);
}
void loop(){
// Loop clockwise and Counterclockwise
for (int i=0, i<=200, i++)
CW();
delay(1000):
for (int i=0, i>=-200, i--)
CW();
}
/*
{
"version": 1,
"author": "Kunal Panchal",
"editor": "wokwi",
"parts": [
{ "type": "wokwi-arduino-uno", "id": "uno", "top": 165.34, "left": 111.35, "attrs": {} },
{ "type": "wokwi-a4988", "id": "drv1", "top": 35.14, "left": 156.88, "attrs": {} },
{
"type": "wokwi-stepper-motor",
"id": "stepper1",
"top": -146.71,
"left": 220.42,
"attrs": { "size": "17" }
},
{ "type": "wokwi-slide-switch", "id": "sw1", "top": -11.06, "left": 78.17, "attrs": {} }
],
"connections": [
[ "drv1:DIR", "uno:6", "orange", [ "h-17.24", "v10.86", "h188.8" ] ],
[ "uno:7", "drv1:STEP", "purple", [ "v-16.92", "h-188.2", "v-31.1" ] ],
[ "drv1:1B", "stepper1:B-", "black", [ "h0" ] ],
[ "drv1:1A", "stepper1:B+", "green", [ "h0" ] ],
[ "drv1:2B", "stepper1:A-", "red", [ "h0" ] ],
[ "drv1:2A", "stepper1:A+", "blue", [ "h0" ] ],
[ "uno:5V", "drv1:VDD", "red", [ "v35.84", "h158.55", "v-295.22" ] ],
[ "drv1:GND.1", "uno:GND.1", "black", [ "v0.4", "h40.71" ] ],
[ "drv1:RESET", "drv1:SLEEP", "green", [ "h-16.24", "v1.17" ] ],
[ "uno:5", "sw1:3", "blue", [ "v-48.27", "h-252.35" ] ],
[ "sw1:2", "drv1:ENABLE", "red", [ "v0" ] ]
],
"dependencies": {}
}
*/