How to control a stepper motor using SD02B?

Autonomous Robot, Manual Robot, DC Motor Driver, Stepper Motor Driver, Servo, Multi PWM chip.....

Re: How to control a stepper motor using SD02B?

Postby sam » Tue Sep 27, 2011 1:51 pm

Thanks a lot sich!
It will be very kind of you to include these info in the next version of the manual.

Still i have one little query, since you mentioned that the current limiting is not accessible, and the manual states that the drive can supply up to 2A per phase, can i safely assume that the current limit is by default at 2A?

Regards,
Sam
sam
Freshie
 
Posts: 6
Joined: Sat Sep 24, 2011 3:38 pm

Re: How to control a stepper motor using SD02B?

Postby sam » Thu Sep 29, 2011 10:58 pm

Hi all,

The driver is meant for open loop control.
I am thinking of doing a closed-loop that will do the switching for each phases accordingly.
An incremental encoder will be employed and its output being connected to the PULSE input pin of the SD02B, so as to switch (commutate)the phases accordingly.
Also, using the dual voltage supply capabilities of SD02B, the Vmotor will be use as a control input up to the rated voltage to control the voltage applied to the motor phases. While the direction of the motor is determined via the DIRECTION input pin of the SD02B.
In brief, with this particular configuration, the SD02B+stepper motor will become a DC motor.
Advantage?no mis-stepping.
Possible? need your precious inputs.
Thanks.

Regards,
Sam
sam
Freshie
 
Posts: 6
Joined: Sat Sep 24, 2011 3:38 pm

Re: How to control a stepper motor using SD02B?

Postby sich » Fri Sep 30, 2011 12:37 am

sam WROTE:Still i have one little query, since you mentioned that the current limiting is not accessible, and the manual states that the drive can supply up to 2A per phase, can i safely assume that the current limit is by default at 2A?

The current version of SD02B only can drive up to 1A per phase, as mentioned in the latest user's manual. So the current limit would be at 1A.

sam WROTE:An incremental encoder will be employed and its output being connected to the PULSE input pin of the SD02B, so as to switch (commutate)the phases accordingly.

You will need to process the output of the encoder, compare the result with the desired value, then alter the signal to the PULSE input accordingly. You can't connect the encoder output to PULSE input directly.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

SD02B and UC00A not working

Postby bspin » Sun Nov 06, 2011 3:13 pm

Hi there !

Hope you can help me with this:
I have the SD02B but no matter what I've tried I couldn't make it work. (Control a stepper motor)
I've purchased the UC00A but no luck with that either.
I am using this stepper motor:http://www.robotshop.com/ca/cytron-3-40v-2a-unipolar-bipolar-stepper-motor-controller.html

I've tried to control the SD02B with Arduino Mega:
This is the code:

CODE: SELECT_ALL_CODE
void setup()
{
  Serial1.begin(9600);
  Serial1.print('U');  //set motor controloer boud rate to
  Serial1.print(1);    // 9600bps ( same as the reset button on SD02B )
}

void loop()
{
  Serial1.print('O');  //turn on stepper motor
  delay(1000);
  Serial1.print('S');  //set speed
  Serial1.print(9);    // to XX
  Serial1.print('<');  // rotate counterclockwise
 
  Serial1.print('G');  // run the stepper motor
  delay(2000);
 
  Serial1.print('F');  //brake stepper motor
  delay(2000);
}


Of course TX - RX and RX to TX and GND to GND.
I tried all the serials ouputs from the Mega. I tried different boudrates. Nothing. 12V on the Vmotor.
All I get is a correct spin of the motor shaft on TEST button. That is all.
Then I have another issue: I have two other motors pulled from a printer. I have all the specs. 7.5 step, 12V, 5 wires. I think I got the wiring right.
With 5 wires the GNDs are joined. Resistance between the common GND and all other leads is the same (1/2 of full resitance ). When you get two ends .. it is max.
With these two motors on test button all I get is some random vibration on the shaft. I've tried all kind of wire combinations without any luck. Maybe should try some more. Not really happy about it.
EDIT The two printer motors now work: I've realized that there is one combination that I didn't try for hooking the wires .. apparently that was the right one. So now I got three motors that work on test button. Wish they would work though on UART. End EDIT


Please see pics attached for the contraption with the 6 wire unipolar motor.

I am too lazy to try to do the PULSE DIR EN. UART seems to be the way and I can get it to work.

Unfortunately the UC00A that I got isn't recognized by the OS (Win7) and I noticed that one little component gets really hot. Maybe it was plugged in the USB for 5 min the longest before I noticed the component getting really hot. ( it gets hot in about 5 seconds, burns ) So .. I guess it's defective. See attached pics.

You should give it a try at having a tutorial for Arduino users since it is quite popular. I am not very savvy with programming or electronics and I don't want to be bothered by translating code form other micorcontroler to another. My aim is not programming or the fun of electronics but the final product, my project to work. I put my effort into it .. but it doesn't have to be blood, sweat and tears. I hope you understand my point of view. I did spent way too many hours trying to get things to work. The UC00A not working was the biggest disappointment. I didn't really needed it , I got it only to test the SD02B.

Well, I hope you guys give me some new ideas to try because I've run out of any fresh ones.
Thanks a lot for any suggestions!
Attachments
IMG_0676resize.jpg
IMG_0678 resize.jpg
bspin
Freshie
 
Posts: 6
Joined: Sun Nov 06, 2011 2:36 pm

Re: How to control a stepper motor using SD02B?

Postby sich » Sun Nov 06, 2011 3:55 pm

Hi bspin,

Really good explanation there. Appreciate your effort to test intensively, instead of searching for help straight away!

Seems that you have tried almost all I can recommend here. Now one last thing to confirm. Please connect the UC00A to Arduino Mega. By using a terminal program such as Hyperterminal or Realterm, read the data going out from Arduino's serial pins. This is to make sure the Arduino and UC00A are working fine. Please check to see if the component on UC00A is still hot with that connection.

If everything works like a charm, that indicates something is going wrong with the SD02B's UART. We apologize for your inconvenience if it's our product defect. You may contact Cytron's support by filling up the details here: http://www.cytron.com.my/support.php.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: How to control a stepper motor using SD02B?

Postby bspin » Sun Nov 06, 2011 5:42 pm

Quick post with some notes, latest tests.
(1)

This code:
CODE: SELECT_ALL_CODE
void setup()
{
  Serial.begin(9600);
  Serial.print('U');
  Serial.print(1);

}

void loop()
{
  delay (10);
}


Generates this weird behavior:

Motor makes a high pitch sound without turning actually ( just vibration ).
The sound slowly transforms into a lower pitch over 5-8 secs.
Then the shaft starts turning erratically first - for 2 sec, then into a constant spin .. approx. 3-5 rot per sec I would say.
It keeps this constant turning as long as I let it.
It seems like it starts at a too high frequency that the motor can't read, for some reason the freq. decreases and settles to something that by some chance the motor can produce.
If I remove the delay(10) form the loop, I get a short jerk on the motor, and nothing after that.

Even more weird:
If I move this to serial1 .. nothing happens. Dead in the water.
Don't know if I should continue with this.

(2)
I don't quite understand what do I need to do with the UC00A
Please connect the UC00A to Arduino Mega.

Is the UC00A supposed to be connected to Arduino ? and while connected should it be attached to an USB on the computer ?
the UC00AA isn't recognized at all by WIN7 , I don't get the new device detected.
So to go through this once more: Arduino should send some Serial to ... lets say Serial1. and UC00A should read that .. and then read that in the computer ?
Or while UC00A is connected to the computer read output withe serial read on Arduino ?
I can't make sense of it. Then I don't really know how to use the Realterm ... step by step instructions will be the only way till I figure it out. To be sincere, I don't really want to learn this too. :) Not that I know to much of anything else.
The Arduino board serial print seems to be working. I see for Serial in Serial Monitor the commands that I am sending.

One more thing:
Serial1 connected to SD02B. Power is OFF on SD02B.
The power led on SD02B blinks with what I presume to be TX data being fed into the SD02B.
Same thing with Serial.
So this kind of tells me that Serial1 is working.

Did I mentioned that I am using a converted PSU as power supply for the SD02B ? Is there anything wrong with that ? I can't imagine.

Not so short post after all.

Bought the SD02B and UC00A from robotshop. Will do RMA through them. They pay for shipping and stuff. Don't know what this means to you.

It's 2:40am here. Got to catch some sleep.
Thanks for helping me. Much appreciated.
bspin
Freshie
 
Posts: 6
Joined: Sun Nov 06, 2011 2:36 pm

Re: How to control a stepper motor using SD02B?

Postby sich » Sun Nov 06, 2011 9:00 pm

For your first question, about the motor's weird behaviour, usually it happens when the coils are not correctly energized - in other word, the wires of the motor is not connected to the driver correctly. Anyway, since I'm not there seeing all the condition, it's just a wild guess from my experience working on stepper motors.

About UC00A, you need to know that this product is actually a USB to UART converter. It creates a virtual COM port in your computer. You need to install driver for it to function. You can get the driver from UC00A product page. Installation guide is given in that page as well. I'm using UC00A on both my Win7 laptop and PC without any problem so far. Since you cannot get UC00A to work on your computer, so it actually haven't communicate with SD02B too. So whether SD02B's UART interface has problem is still unknown.

There're two problems here - to make sure the UC00A is recognized by your PC first, then get it to communicate with SD02B through the VB software which can be downloaded from SD02B product page.

bspin WROTE:One more thing:
Serial1 connected to SD02B. Power is OFF on SD02B.
The power led on SD02B blinks with what I presume to be TX data being fed into the SD02B.
Same thing with Serial.
So this kind of tells me that Serial1 is working.

First of all, what's Serial1? If you have powered up SD02B and it's power is off when you plug in something, that means the connection has problem. The power LED shouldn't blink if the power source supplies constantly. It must be something wrong with the power input then.

After reading your last post, I think there are still some problems lying in your hardware and software setup that's to be solved. Anyway, thanks for explaining all you've got in such detail! That helps a lot to know the issue better. I'll write a sample program for interfacing SD02B with Arduino soon.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: How to control a stepper motor using SD02B?

Postby bspin » Mon Nov 07, 2011 2:43 am

"it happens when the coils are not correctly energized - in other word, the wires of the motor is not connected to the driver correctly"
No longer the case - as I've mentioned, all work fine now. Same constant CCW movement on TEST button, good torque, no silly vibration, shifting direction or anything like that.

"About UC00A, you need to know that this product is actually a USB to UART converter."
Yes, I know what I've bought. It's just that I don't understand what the previous post wanted me to do with it.
as per this suggestion " Please connect the UC00A to Arduino Mega."

This "UC00A is recognized by your PC first" is indeed my first problem with UC00A.

"The power LED shouldn't blink if the power source supplies constantly"
The power doesn't blink when PSU is ON. It only blinks faintly when PSU is disconnected and through UART current leaks into SD02B, which is provided by the Mega.

Serial1 is one of the hardware serials available on Arduino Mega. (They are addressed as Serial, Serial1, Serial2, Serial3 )Check link below for Specs.
http://arduino.cc/en/Main/ArduinoBoardMega2560

Being ultra descriptive is one way to avoid confusion, misunderstandings, solve problems, avoid creating false expectations. It's like lawyer talk. :) God is in the details.

Thanks!
bspin
Freshie
 
Posts: 6
Joined: Sun Nov 06, 2011 2:36 pm

Re: How to control a stepper motor using SD02B?

Postby sich » Mon Nov 07, 2011 12:30 pm

Hi, I've tested your Arduino code and it's working. I'm going to retest all of the SD02B in stock. Please wait for my result...
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: How to control a stepper motor using SD02B?

Postby sich » Mon Nov 07, 2011 2:23 pm

After some testing, I see something that might be the reasons which contribute to the problems you are facing.

1. Please refer to Arduino serial.print() and serial.write(). serial.print(10); won't send the data as byte. So upon receiving wrong data, the driver has gone haywire. I use serial.write(10); instead. Eg:
serial.print(10); --> send 10 as string, "10"
serial.write(10); --> send 10 as byte
I'm sorry that I didn't notice this error when you first posted the code as I'm still novice to Arduino. Below is my code.
CODE: SELECT_ALL_CODE
void setup()
{
  Serial1.begin(9600);
  Serial1.print('U');  // set motor controloer boud rate to
  Serial1.write(1);    // 9600bps ( same as the reset button on SD02B )
}

void loop()
{
  Serial1.print('O');  // turn on stepper motor
  Serial1.print('S');  // set speed
  Serial1.write(20);   // to XX

  Serial1.print('<');  // rotate counterclockwise
  Serial1.print('M');  // set micro-stepping to
  Serial1.write(1);    // 1
  Serial1.print('G');  // run the stepper motor
  delay(3000);
 
  Serial1.print('>');  // rotate counterclockwise
  Serial1.print('M');  // set micro-stepping to
  Serial1.write(10);   // 10
  Serial1.print('G');  // run the stepper motor
  delay(3000);
}


2. Different stepper motor has its own max stepping frequency. I've tested two stepper motors, one with higher freq and one with lower. When running the code above, the lower one performs similar to what you've described earlier, while the higher one is doing fine. Sometimes the lower one even get stuck at one direction.
You can reduce the speed value to may be 10 or lower to see if your stepper can rotate correctly. If you find the motor can run smoothly at lower speed, you can make use of the microstepping feature. Set it to 1/10 microstepping and you'll have larger range of value to play with the speed.

3. The last thing is sufficient current from the power supply. I'm not sure about PSU, I'm using the DC power supply in our lab. Although the current needed for my stepper is only as low as 0.2A for free load and normal running, whenever I limit the current to 1A, the driver performs strangely too. This happens especially when it wants to change direction, and I can see the current goes up a lot during that short period of time.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

PreviousNext

Return to Robot Controller

Who is online

Users browsing this forum: No registered users and 13 guests

cron