Controlling 6 motors with timer Interrupt routine

Hey guys and girls, its me once again.

I am currently trying to build a very high performing Servomotor from an ams AS5048A absolute rotary encoder and a stepper. I use a teensy 3.5 and i looked in the very nice TeensyStep library.. it works in a very interesting way, but i cant use this algorithm for my purposes (i guess).

I just want to define the desired motorspeed for each stepper, calculate the actual speed via PID Controller and everything else thats needed accordingly, and call a timer interrupt every time a step needs to be made. so far so good. i think i am capable of doing that, shouldnt be too hard.

but thats just for one motor. Now I am trying to figure out an algorithm to call the timer each time a step needs to be made, for 6 motors. all have different speeds, so the intervals are all different. and i cant think of a way i could do this. maybe some smart mind could lighten me up here.

Hope everything is understandable.

any advice is appreciated! thanks a lot

Greetings from Germany, Aachen :wink:

RWTH_MASCHI:
I just want to define the desired motorspeed for each stepper, calculate the actual speed via PID Controller

Why do you need PID with a stepper motor? Won't you know the speed very precisely from the interval between step pulses?

What is the maximum number steps per second do you want to achieve for a single motor?

What is the role of the rotary encoder?

Post a link to the datasheet for the stepper motor.

What stepper motor driver are you using?

...R

Hello. It may happen that u lose Steps if u push a Stepper to its limits, so i dont want that for my purposes, thats why I try to make it Closed Loop.

I study engineering, so i dont have money to buy "real" servo motors, and i think its fun to make some and thats why i do it the "fun way"

Max Steps per sec, maybe smth around 10-20 thousand i dont know yet

The rotary encoder is needed to get awarness of the absolute (actual- as stepcount doesnt count) position of the stepper motor.

Stepper motor is a regular Bipolar Nema 17 or Nema 23,

Stepper driver is a DM542T- so no need to get into the hardware as this works fine.

Just thinking about the right way to implement it

RWTH_MASCHI:
Hello. It may happen that u lose Steps if u push a Stepper to its limits,

Don't.

Use a stepper motor that is capable of doing the job without missing steps

...R

those dont exist- id need nema34 but with gearboxes, first of all those arent available, and second it would be way too expensive
so .. :slight_smile:

With a stepper a position loop is the natural way to go, not speed loop.

I use a teensy 3.5 and i looked in the very nice TeensyStep library..it works in a very interesting way, but i cant use this algorithm for my purposes (i guess)..

I'm currently implementing the possibility to change the rotation speed on the fly in TeensyStep. Change of speed will be done using normal acceleration / deceleration. In case you attached more than one motor to the controller the movement of the motors will stay in sync (Bresenham) when you change the speed. As usual, each controller will be able to control up to 10 steppers in sync and you can have up to 4 independent controllers. Step frequencies of up to 300'000 steps/sec should be no problem with a T3.5.
Once this is working, it should be easy to use a standard PID algorithm to control your motors.

I hope that I can finish this in the next 2 weeks. If you are interested and want to test a pre-release version drop me a note.

Right @MarkT

still. i do it the unusual way. And its fun!
its kind of working already

Its done.
and it turned out to be VERY useful (as expected)

and a special thanks to Luni64

a little demo video here:

Nice. For your next trick try a DC motor and get much higher top speeds!

I'm currently implementing the possibility to change the rotation speed on the fly in TeensyStep. Change of speed will be done using normal acceleration / deceleration. In case you attached more than one motor to the controller the movement of the motors will stay in sync (Bresenham) when you change the speed. As usual, each controller will be able to control up to 10 steppers in sync and you can have up to 4 independent controllers. Step frequencies of up to 300'000 steps/sec should be no problem with a T3.5.

To follow that up:
Meanwhile, a test version is available: https://github.com/luni64/TeensyStep/tree/develop_newRotate.
Here a video showing it in action: https://youtu.be/HcaStXmkH2w
And here a quick description of the usage
New Stepper Motor Library | Page 2 | Teensy Forum