Stepper Motor driver in Assembler - Has anyone coded that?
Christof Eb.
Posts: 1,229
Hi,
I tried to find a stepper motor driver in assembler for the prop and did not find one. Did I miss something?
Hardware is in my case to drive L298N via 4 port lines.
Thanks for some input!
C.
I tried to find a stepper motor driver in assembler for the prop and did not find one. Did I miss something?
Hardware is in my case to drive L298N via 4 port lines.
Thanks for some input!
C.
Comments
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
For a LM298 connection Input 1 is Bit0 Input2 Bit1 .....
Saluti Joerg
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
Look at
http://forums.parallax.com/forums/default.aspx?f=25&m=170328
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
Looks like there was not much code. I will decide, if I am going to write my own code which should ramp up and slow down and go for a given number of steps.
Christof
If very high speed is required you have to use ASM
But try SPIN before you go that way as we have done some work many months ago
with a simple step/direction set up and we got pretty good speeds using spin..
The key to the code is a BARREL SHIFTER type program..
You load the pattern ( for CW and CCW) and rotate the same BARREL one way or the other way. (ROR and ROL)
The speed of rotation determines the speed of the motor
That example program listed (as per Sap's link) shows you that precisely..
cheers ron
I´m programing an asm driver for steppers and servo motors...I think I will get it finished early...when I get home I will post this.
Now...it´s only my aditional fun in vacations.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
The output of which is clock/direction, to an external microstepping stepper motor driver board.
The code includes ramp up - steady speed - ramp down trapesiod motion profile, with programmable start speed, terminal speed, home speed·(steps/second), and ramps (steps/second^2)
It also includes·origin (home) sensor seek routines, + loads more...
I shall post the code tonight when I get in... Please bear with me 6 hours or so...
That´s exactly what I´m doing..... also with the (home) position sensor.
I´ll be hopefully waiting for your version ....also then I will post mine (when I get it finished).
Maybe with both ideas, we could get an improved driver for that !!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
Please find the attached Clock-Direction stepper driver Object.
M.R.B.
Here's what I promess.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
i took a quick look into the code without analysing it in details.
i have a question to m.r.b.
in the sourcecode you wrote "Axis driver object ... THREE instances of this object are created for X,Y and Z axes"
can two or maybe even all three axis work synchronized to move two or three axis at the same time?
This would make it possible to move in ANY direction in 3D-Space.
example:
looking at only two axis X,Y
i start at X,Y = 0,0 and wnat to move to X,Y 50,80
now unsynchronized it would work:
1.) move from 0,0 to 50,0 (only-X-Axle-move)
then
2.) move from 50,0 to 50,80 (only Y-axle-move)
maybe it is possible to start two axes at the same time.
But if they are using the same speed the X-axle reaches the target faster than the Y-axle.
If Y-axle is at position 50 the X-axle has reached its target and stops
then the Y-axle does the rest from position 50 to 80
synchronized would be:
start at X,Y 0,0 and move DIRECTLY to X,Y 50,80 (X-axle AND Y-axle are moving at the SAME TIME - AND if X reaches 50, Y reaches 80
This means the output between X and Y-Axles has to be synchronized
the Y-axle has more steps than the X-Axle
In average every 80/50 = 1.6 steps of the Y-Axle the X-Axle has to go one step
Now you could try to calculate different speeds for the axis. But how about errors in the calculation of the speeds
(which has not endlessly digits to calculate superexactly)
and how about the synchronized starting of the two axis ?
For one move maybe it doesn't matter. But how about a lot of sequential movements without any stops until reaching the final position ?
The position-error of each single move will add to a summary-position-error.
How big will the position error be after 50 or 250 moves ?
example:
start at 0,0 move a route to 40,20 to 100,10 to 80,15 etc.
Move without any stops
if not synchronized EXACTLY it would work this way
start at 0,0 to 40,20. Y-axles reaches 20 but X-axle is at 38 and not at 40.
Y-Axle starts next move towards 100,10 so X-axle does the move from X=38 to X=40 while Y-axle is already running into a different direction (towards Y=10)
So the REAL route would be 0,0 to 38,20 instead of 0,0 to 40,20
With synchronized axis the error stays very low
Therefore it is nescessary that the bitbanging for the steps of BOTH axis is done by ONE loop
This could be done by an algorithm called "Bresenham-Algorithm".
The advantage of this algorithm is that it needs only addition and subtraction of integers, regardless of the step-relation of X-axle to Y-axle
F.e. step-relation X:Y 47:19 or 197 : 5311 or what ever is done correctly by the algorithm.
This means the algorithm is fast because it doesn't need floating-point maths.
Did anybody work on implementing the Bresenham-Algorithm for two or maybe even three axis ?
best regards
Stefan
In the application I am using it for (robot!!!, helping someone with a college project), in the parent object, I do something like this.... (assuming you have instanciated 3 instances of the axis driver already as "Axis"..) .... Doing the following, will home axes, then move an X,Y axis configuration in a diagonal line!!!
·· Axis[noparse][[/noparse]0].Home(True)·· 'Home X, wait for home complete
·· Axis[noparse][[/noparse]1].Home(True)··· 'Home Y, wait for home complete
·· ......·· previous code
·· ......·· blah blah
·· Axis[noparse][[/noparse]0].MoveAbs(100,False)·· 'Start X axis move to absolute position, with no wait
·· Axis[noparse][[/noparse]1].MoveAbs(100,False)·· 'Start Y axis move to absolute position, with no wait
·· Repeat while Axis[noparse][[/noparse]0].GetBusy or Axis[noparse][[/noparse]1].Getbusy· 'Wait for move to complete, before issuing next move command
·· ......·· more code
·· ......·· blah blah
The False's relate to "Do you pause program execution until move is complete".
You can subtitute the 'MoveAbs', for 'MoveInc', to move incrementally, rather than to an absolute logical position!!
B.T.W.... You can adjust the 'angle' of the line, by adjusting the drive speed settings, before your move....
IE:-
Axis[noparse][[/noparse]0].SetTerminalSpeed(nnnn)
Axis[noparse][[/noparse]1].SetTerminalSpeed(nnnn)
...·adjusts the X/Y terminal speeds... thus adjusting the angle of movement..Of course, there will be a small delay between X & Y starting, due to spin program execution timing, for most things it is insignificant, because the motors are ramping up to speed anyway!! (True trapeziod motion profile... Ramp up-Hold-Ramp down!!!)
But... doing this moves the X, then the Y, after the X is done.......
·· Axis[noparse][[/noparse]0].MoveInc(100,True)·· 'Start X axis move, with wait
·· Axis[noparse][[/noparse]1].MoveInc(100,True)·· 'Start Y axis move, with wait
Regards M.R.B.