I am really happy to hear that the code works.
I've migrated this weekend to controlling the motor with PULSE, DIR, EN. And it works !
Really happy about it. Still wish it would have worked with UART.
The code that I am playing with now is below:
- CODE: SELECT_ALL_CODE
// this takes the motor through these steps:
// enable motor, keep like this 1 sec
// turn motor one revolution in one direction ( should start with CCW )
// disable motor, keep like this for 1 sec
// enable motor, keep like this 1 sec
// turn motor one revolution in the other direction (CW second time)
// disable motor, keep like this for 1 sec
// repeat the loop
// since I have to use 400 steps to get a full rev, it makes me believe that SD02B is in half step
// One NEEDS to CONNECT the GND from Arduino to GND on SDO2B !!! ( next to Vmotor )
const int PULSE = 2;
const int DIR = 3;
const int EN = 4;
void setup()
{
pinMode(PULSE, OUTPUT);
digitalWrite(PULSE, LOW);
pinMode(DIR, OUTPUT);
digitalWrite(DIR, LOW);
pinMode(EN, OUTPUT);
digitalWrite(EN, LOW);
}
void loop()
{
for (int direction=0; direction<=1; direction++ )
{
digitalWrite(EN, HIGH);
delay(1000);
digitalWrite(DIR, direction); // set direction
for (int i=0; i<400 ; i++)
{
digitalWrite(PULSE, HIGH);
delay(1);
digitalWrite(PULSE, LOW);
delay(1);
}
digitalWrite(EN, LOW); // disengage the motor
delay (1000);
}
}
Questions:
(1)
How do I set micro stepping to None / 2 / 5 / 10 while using PULSE, DIR, EN.? It's on page 5 in the manual. PULSE.
(2)
I know that maximum accepted speed for SD02B is 1Khz or 1000 steps/second.
That's why if I set delays like 0.5 it wont work ? Maybe delays have to be int. Have to look some more into this.
I wish I would be able to turn the motor at higher speeds. Not crazy high. One way is to get it to work in full step. Then if I could send 2Khz that would double it. Not such a big problem though. Some cogs will solve the speed problem.
Thanks again Sich !