Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Single direction servo maths help.

Status
Not open for further replies.

dr pepper

Well-Known Member
Most Helpful Member
I'm building a positioner servo with a microcontroller and a stepper motor, I need to position the motor in one of 16 positions, the motor needs to turn clockwise only, no reverse.

Any ideas on an efficient way in to C to calculate the number of positions to move forwards, ie if the motor in on position 8 and the next position command is 4, then the motor needs to move 12 positions forwards.
 
Last edited:
I'm using a 7.5 degree stepper, divides no problem, and a step out on some would be ok anyway.

Thought you liked JD.
 
Assuming I have understood the question being asked. Subtract current position from desired position. If the answer is positive move that number of steps. if the answer is negative then subtract the magnitude of the difference from 16. In the mid 1970s I had a similar problem with an antenna tracking system (For the antenna to track radio amateur satellites.) I wanted it to take the shorted direction to move the antenna. For example if the antenne was pointing 350 degrees and the next position was 20 degrees I wanted it to move 30 degrees to the new position. Not 330 degrees.

Les.
 
Top mon Les, that sussed it.

Turned out I'd nearly understood it, I was adding 15 if <0, I wasnt taking zero into account 16 is the correct number.

I packed in booze years ago, but having a bit of scot im me I liked Mc Callan, esp the 12 year old stuff.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top