Encoders and Quadrature decoder

Ask for and share advice on using the PicoScope kit to fix Electric Vehicles
Post Reply
ben.martins
Pico Staff Member
Pico Staff Member
Posts: 330
Joined: Tue May 16, 2017 1:02 pm

Encoders and Quadrature decoder

Post by ben.martins »

Hi all,

Hope everyone is keeping safe and well.

I wanted to pick up on a new decoder for PS7 that has been out for a while but you might not think it has a role in automotive.

Quadrature encoding is used by rotary position sensors to transmit information about the angle and direction of a rotating shaft, for example on a motor, as a pair of binary signals. This type of sensor has been used on electric motors for sometime and we can decode these signals to determine what the ECU is seeing when the motor is turning.

Below is an image taken from a Tesla motor fitted to a Mercedes B Class. There are two square wave outputs for the sensor. I've also included battery current to get an idea of when the motor is turning.
Encoder signal.png
The encoder determines the speed and direction of the shaft based on the interaction between the two signals.

There are some known criteria that is required when setting up the quadrature decoder. Which signal is the leading and the number of pulses per rotation. As I quickly found out though this information isn't readily available but it shouldn't stop us using the decoder.

To add the decoder click More > Serial Decoding and then select the Quadrature
Decoder selection.png
Decoder selection 1.png
With the configuration section in view you need to tell the decoder where to find the data.
Decoder selection 2.png
1. In the case of this example my data is on channels B & C.

2. The signal is sitting between 0V and 5V and selecting a threshold of 3V will put us nearly in the middle of the signal allowing a clean crossing point. Hysteresis not overly important here as the crossing point is very clean so leave the software to automatically apply this. The second signal should be added in with hopefully similar settings!

3. The display setting has a number of options - speed, displacement and transition clock. For this particular application we will use Speed.

4. Pulses per revolution is defaulted to 24. If you can find this information then please use it but if not then leave as it is. It does mean the speed value you obtain from the decoder will not represent that of the shaft being monitored by the encoder.

5. A leads B is - this refers to your two signals and which one is the leading signal. You have the options of Clockwise and Anticlockwise. Again this may not be known but once the decoder is added to the graph you will have a direction arrow in the table. It's up to you but it will become obvious which is the forward direction depending on how you are diving the motor in either forward or reverse.

6. Speed Units - has a number of options as well but the one we are most familiar with is RPM.
Decoder final.png
The decoder will appear on the bottom of the screen as with all Pico decoders but I have moved it to the side for easier viewing.

As you can now see we have a speed and a direction given in the table. By double clicking/tapping on the a line in the table it will take you to that section in the graph.
Decoder final 1.png
From the table you can see that the first two packets, the direction is different. When we made this capture we reversed briefly before putting the vehicle into drive and travelling forward. You could amend the decoder by changing the A Leads B to the alternative option.

Finally as the speed is reflected by the frequency change in the signal we can add a frequency math channel for one or both signals to display the change in speed of the shaft.
Decoder final with frequency.png
I hope this helps in someway and if you have any feedback for the Quadrature decoder please let us know.

Kind regards

Ben

Post Reply