Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

algorithm for diagonal motion in xy plane by stepper motor

Status
Not open for further replies.

maham ahmed

Newbie level 4
Joined
Dec 16, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
44
hi ,
i have to move two stepper motors simultaneously in XY plane. i am using pic microcontroller 16f877a.

kindly tell me the algorithm to implement this
 

What have you tried?

1axis control with home position or reference switch.?

Moving from home positions , uses software count of present and.desired position for each axis. therefore you, need 2 counters, present and target difference position.

count down until target difference= 0 or limitswitch is not tripped.
 

i have just controlled stepper motor for 1 direction either x or y .
 

This may be crude but…
X=20, Y=10.
Use float variables to divide the short side by the long side. 10/20= 0.5
Code:
Float Yfraction = Y / X
Int oldY=0     // starting place
Int newY
For Xstep = 1 to 20
Step X motor
newY = Yfraction * Xstep         //You have to get around the float to int problem here
	If  newY > oldY	// Integer comparison 
		(
               Step Y motor
               oldY = newY		// to be ready for the next increment
                )
Next Xstep

Y will only step when newY increments to the next whole number.
You will have to sort out beforehand which side is longer and positive or negative directions.
This would be more graceful with modulo multiplication but it’s late and I would have to get out the books for that one.
I hope for your sake that someone has a better way.
 

Look at this: https://en.wikipedia.org/wiki/Bresenham's_line_algorithm

Normally used to calculate pixel positions on graphical displays but the same algorithm should work to find the shortest step route between two coordinates anywhere. The page includes some sample code you can adapt.

Brian.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top