cancel
Showing results for 
Search instead for 
Did you mean: 

Quadrature encoder simulation

Cesar cfg
Associate II
Posted on April 28, 2015 at 16:49

Hello 

I am using the STM32F4 interfaced with two hall effect quadrature encoders.

Is there a method to generate the signals (A,B) coming from the encoder to validate my work ? because now i don't have the sensor 

#qei
5 REPLIES 5
pmoore
Associate II
Posted on April 28, 2015 at 17:16

Cesar:

That's easy.  Just run spare GPIO pins configured as push-pull outputs into the GPIO pins for your encoder inputs.  Quadrature repeating pattern is 1st high, then 2nd high, then 1st low, then 2nd low.  

-Patrick

Cesar cfg
Associate II
Posted on April 28, 2015 at 17:40

Thank youpatrick for your reply

I don't understand your solution.

I think that your solution don't give a signal in quadrature, they will be in phase.

I attach to you a picture of two signals in quadrature

Thank you in advance.

________________

Attachments :

encoder-quadrature.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I138&d=%2Fa%2F0X0000000bhM%2F83dYF7V6LYTULxUC1QOookzDMipmwWrs6g7o3Cjq_eI&asPdf=false
jpeacock
Associate II
Posted on April 28, 2015 at 19:39

Make sure there is a delay between changing the first simulated phase and the second simulated phase, as described.  You can test direction by varying which phase rises first.

Both pins low->delay->phase A pin hi, B lo->delay->phase A hi, B hi -> delay -> phase A lo, phase B hi -> delay -> both pins low  will give you one count in one direction.  To reverse direction reverse the logic, phase B pin rises first.

The delay ensures the signals are out of phase so you get simulated motion.  The delay drives your tachometer, how fast the encoder is moving.

  Jack Peacock

Cesar cfg
Associate II
Posted on April 29, 2015 at 10:35

Thank you Jack , I will test your solution

Posted on April 29, 2015 at 14:38

You could generate a quadrature signal using a single TIM, two channels, toggle mode, with the phase shift expressed as the difference in CCR1 vs CCR2 settings.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..