cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 as quadrature encoder output

paul sauv
Associate III
Posted on August 29, 2017 at 10:02

Hi everyone,

I need to reed a quadrature encoder signal from a sensor, modify the number of pulse and send this signal out to a machine.

The output signal must be a TTL quadrature signal, I have 5 pins: 0v, 5v, A, B and Z on my machine.

All the reading part is OK but I don't know how I should do for sending exact amount of pulse with quadrature signal.

Thank you for your help

#quadrature-encoder #output-quadrature #ttl

Note: this post was migrated and contained many threaded conversations, some content may be missing.
12 REPLIES 12
Uwe Bonnes
Principal III
Posted on August 29, 2017 at 10:38

As you gave no speed requirements and nearly no other informations on your environment:

Try bitbanging the signals.

Posted on August 29, 2017 at 10:44

I'm not sure I'm allowed to put commercial link on this forum

Here are information that I have

0690X00000603qkQAA.jpg0690X000006042tQAA.jpg
Posted on August 29, 2017 at 11:02

Your title is wrong. You need quadrature encoder input, so a quadrature decoder!

Any two channel STM32 timer can act as quadrature decode. Read the reference manual and the timer cookbook about that.

Posted on August 29, 2017 at 11:07

In my project, I have 3 main components:

A quadrature encoder which value is read by STM32, the STM32 and the chinese DRO.

The chinese DRO can't accept the resolution of the quadrature encoder so I must change the resolution with the STM32 and need the STM32 to act as a quadrature encoder for the DRO. so, if I'm correct, In need to decode the signal and to encode the new signal after

Posted on August 29, 2017 at 11:12

What is a DRO?

Posted on August 29, 2017 at 11:13

This stands for Digital Read Out. This is a display unit used on machines such as lathe, milling machine etc to show the relative position of the tool on X,Y and Z

Posted on August 29, 2017 at 11:18

And what is your translation factor. How many DRO pulses  do you need for a given number of encoder pulses? I think you can generate N up pulses by programming a 2 channel timer to run N times, with both channels to toggle output on compare match and one channel set to 25 % of the period and the other 75%. For pulses for the other direction set to 75 and 25 %. But N and period need to be determined

Posted on August 29, 2017 at 11:27

This is the other tricky part.

Encoder pulse: 512 pulses per mm, hence 1.95micron per pulse

DRO can accept multiple resolution: 0.1 mic, 0.5mic, 1mic, 2mic and more.

I was thinking about using 0.1mic resolution and adjust the remaining error with DRO software or live with that error which is very very low, this is for hobby use, not professional purpose. hence when i receive 1, I send 19 pulses.

I need to pay attention to the limit of the STM32 regarding number of pulses sent in a short time. If it's not powerful enough, I can decrease the resolution. 

And also, for fast traveling moment, I have the Z reference each 25mm hence each 12800 pulse in

Posted on August 29, 2017 at 11:33

Ah, so you probably have bought an encoder and a DRO that don't fit together, as the scale factor does not fit? The encoder can give you up to 10 MPulse/s, you wan't be able to rescale as described above. So weither get a display for the STM32 as DRO  and use the decoded values or get a fitting DRO.