Connecting Stepper Motors to Microcontrollers Tutorial

Microcontroller Topics
sthn
Corporal
Corporal
Posts: 9
Joined: Sat Jan 05, 2013 9:14 am

Re: Connecting Stepper Motors to Microcontrollers Tutorial

Post by sthn » Tue Feb 19, 2013 5:21 pm

If you consider above example, to cut a line with 45 degree angle, with 1mm accurate steppers, you will get the cut as on the top image. When accuracy is higher (step angle is lower)
Basic two operations of a stepper motor are either full step or half step. To achieve this high accuracy(to reduce the step angle) do I have to use microstepping method of a stepper motor.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Connecting Stepper Motors to Microcontrollers Tutorial

Post by Neo » Wed Feb 20, 2013 12:54 am

I don't think you can easily do microstepping. So it would be better to go on with full-step for now. When you are perfect with full-step, you can add microstepping circuitry.
sthn
Corporal
Corporal
Posts: 9
Joined: Sat Jan 05, 2013 9:14 am

Re: Connecting Stepper Motors to Microcontrollers Tutorial

Post by sthn » Wed Feb 20, 2013 8:54 am

If I need to do microstepping I have to change the circuitry as well right. I think I have to use a DAC for that. and some changes to the coding. is that correct
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Connecting Stepper Motors to Microcontrollers Tutorial

Post by Neo » Wed Feb 20, 2013 12:47 pm

For microstepping, yes you will need extra circuitry which can generate a sine wave. A DAC would be ideal. You would need to do some experiments with this arrangements. And it will consume lot of time I'm sure. So on the easy way, I think it would be better for you to go with full-step. Try to find a stepper with very low step-angle. That will do the job.
sthn
Corporal
Corporal
Posts: 9
Joined: Sat Jan 05, 2013 9:14 am

Re: Connecting Stepper Motors to Microcontrollers Tutorial

Post by sthn » Fri Mar 01, 2013 5:37 pm

what would be the correct way of calculating the number of steps required to move lead screw to a 1mm or 1inch,

L = ? × r (when ? is in radians)
L = (? × ?/180) × r (when ? is in degrees)

? - step angle
r - radius of the wheel connected to stepper motor
L - distance travelled

or

L = X × Y

X - lead screw revolutions per inch/mm
Y - motor steps per revolution
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Connecting Stepper Motors to Microcontrollers Tutorial

Post by Neo » Mon Mar 04, 2013 7:48 am

r? is the length moved along the belt where r is the radius of the wheel connected to the stepper motor to drive the belt + height of the belt.
cnc.png
cnc.png (2.61 KiB) Viewed 7934 times
Remember, the actual movement on the belt could be slightly different due to mechanical errors such as uneven belt movements along the pulleys, belt play, etc... So to compensate with that, you must do calibration to the unit. Here is a simple procedure to do so.

1. Move Q1 mm by calculating the number of steps required using r?. Say it is A1 steps. The actual movement is say L1 mm.
2. Move Q2 mm by calculating the number of steps required using r?. Say it is A2 steps. The actual movement is say L2 mm.
3. Move Q3 mm by calculating the number of steps required using r?. Say it is A3 steps. The actual movement is say L3 mm.
....
....
10. Move Q10 mm by calculating the number of steps required using r?. Say it is A10 steps. The actual movement is say L10 mm.

Now calculate the error.
Total Error (P) = [(L1 - Q1) + (L2 - Q2) + (L3 - Q3) + ...... + (L10 - Q10)]
Total distance (T) = Q1 + Q2 + Q3 + .... + Q10

Error per millimeter (E) = P / T
Note that the error could be plus or minus.

Now we know, when we ask the machine to move L mm, it actually moves L mm + (L x E) mm.

Okay, so if you want to move L mm accurately, you need to instruct the machine to move L - (L x E) mm.

Note, It would be better to calculate forward and reverse error; Ef (forward) and Er (reverse) to apply for both directions separately.
sthn
Corporal
Corporal
Posts: 9
Joined: Sat Jan 05, 2013 9:14 am

Re: Connecting Stepper Motors to Microcontrollers Tutorial

Post by sthn » Sun Jun 23, 2013 8:55 pm

To cut the 45 degree line as on above image, the instructions would be as below.

MoveX(1);
MoveY(1);
MoveX(1);
MoveY(1);
MoveX(1);
MoveY(1);
MoveX(10);
I have wrote code for above situation. I have a little problem. what happen when routing a circle (pad of a component) or a non 45 degree line. Can I use above method for these situations as well.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Connecting Stepper Motors to Microcontrollers Tutorial

Post by Neo » Tue Jun 25, 2013 4:04 am

General equation of a circle which the centre is (a, b) is given as (x-a)2 + (y-b)2 = r2

With this, for every x location, you can have two y location which you have to plot. That's simple co-ordinate geometry. If you have questions you can ask.
Post Reply

Return to “Microcontrollers”