Teensy 4.1 Stepper Motor Driver Controllers and Encoder Readers Via Ethernet

talltanbarbie

New member
Hi Guys -- I'd like to know if it's possible to make a stepper driver controller that can output step and direction signals and control it over a network.

Each controller would have its own network address and would/could set and return rotation speed (pulse frequency), distance (total pulses), acceleration, turn each motor on and off, etc.

I also need to be able to control each motor at precise angular rates within 1/16 or 1/64th of a microsecond.

If you could do this with a Trinamic type stepper driver, that would be even better.

The same for optical encoders -- return the current angular position, reset the position, etc., as separate devices on a network.

Each device would have its own Teensy and Ethernet connection.

Any help or suggestions would be greatly appreciated.

Thanks :)
 
Can you specify your requirements in terms of messages per second? If you mean that you want to be able to send/receive 64M times per second, then no, that won't be possible.
 
Can you specify your requirements in terms of messages per second? If you mean that you want to be able to send/receive 64M times per second, then no, that won't be possible.

The Ethernet message traffic wouldn't be anywhere near that rate -- 30 - 50 Hz max.

I'd like to make something that could do something like the following. All of the motors and encoders would be on separate axes.

<motor addr1>: Rotate at one rev per 240.01140625 sec continuously
<motor addr2>: Move relative 90 degrees then stop
<motor addr3>: Move relative 3 degrees then stop

<encoder addr1>: Set angular position to zero
<encoder addr2>: Set angular position to zero


<motor addr1>: Report angular position and velocity and acceleration every 0.02 sec
<motor addr2>: Report angular position and velocity and acceleration every 0.02 sec

<encoder addr1>: Report angular position and velocity and acceleration every 0.02 sec
<encoder addr2>: Report angular position and velocity and acceleration every 0.02 sec

<motor addr1>: Move relative 63.279409 degrees
<motor addr1>: Return to rotating at one rev per 240.01140625 sec continuously
<motor addr2>: Move relative -10.178601 degrees then stop

etc., etc., etc.

The code would turn these commands into the correct pulse frequency to the drivers to move the motors, interpret the encoder pulses and get angular measurements, generate a network message data string for output, etc.

I know how to do this mathematically, what I don't know is (a) how I would set up the network communication between the host computer and the Teensy(s) and (b) how to get the motors drivers to run continuously at a precise rate. I have done simple tests with an Arduino Mega and a Teensy sending step and direction signals to a stepper motor driver, so it seems that this should be possible.

So far, I've found this for the TMC 5160


and this


for earlier Teensyies.

If you could point me to any examples of stuff like this that I could modify, it would be a big help.
 
I also need to be able to control each motor at precise angular rates within 1/16 or 1/64th of a microsecond.


Thanks :)
Do you mean microsecond? A resolution of 17 nanoseconds makes no sense at all in the physical world - even at 2000rpm your motor would rotate less than a second of arc in 17 nanoseconds. Steppers have angular errors of a degree or so at the best of times...
 
The Ethernet message traffic wouldn't be anywhere near that rate -- 30 - 50 Hz max.

I'd like to make something that could do something like the following. All of the motors and encoders would be on separate axes.

<motor addr1>: Rotate at one rev per 240.01140625 sec continuously
<motor addr2>: Move relative 90 degrees then stop
<motor addr3>: Move relative 3 degrees then stop

<encoder addr1>: Set angular position to zero
<encoder addr2>: Set angular position to zero


<motor addr1>: Report angular position and velocity and acceleration every 0.02 sec
<motor addr2>: Report angular position and velocity and acceleration every 0.02 sec

<encoder addr1>: Report angular position and velocity and acceleration every 0.02 sec
<encoder addr2>: Report angular position and velocity and acceleration every 0.02 sec

<motor addr1>: Move relative 63.279409 degrees
<motor addr1>: Return to rotating at one rev per 240.01140625 sec continuously
<motor addr2>: Move relative -10.178601 degrees then stop

I still don't understand your terminology regarding timing and resolution, but if you only need 30-50 msgs/sec from host Teensy to each motor-control Teensy, that's certainly doable. Your motor control stuff is entirely independent of where the commands are coming from, so you can just work on that development independently of Ethernet. When you're ready for the Ethernet part, use the QNEthernet library and work through the examples to get an idea of how it works. You can use TCP or UDP to do this kind of thing. UDP is faster, while TCP gives you a persistent connection.
 
I've used EncoderTool on my electronic lead screw project for my lathe, for both the rotary encoders and the linear quadrature encoders. The library is fast enough to keep up with my needs of 150K interrupts per second. That corresponds to 2200 RPM, (using a 4096 edge/revolution encoder), which is the max speed rating of my chuck. I control a stepper, and have a control loop that is closed on the Z DRO (digital read out). I use a 64 bit counter for the rotary encoder, so I effectively never have to deal with roll over in a day session. It's fast enough and flexible enough for my needs.
 
The Teensy’s MCU has four built-in quadrature encoders/decoders that may be useful to you. That could take some interrupt load off.
 
Back
Top