LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading the Pulse Count for Incremental Encoder

Solved!
Go to solution

Hello, 

I am using an Incremental Encoder for which I am able to read the three pins (Phase A, Phase B and Phase C) of it and I am plotting the pulses. Now I wanted to calculate the angular speed of it. 

I am not able to understand that, based on the three signals how I shall proceed to calculate its angular speed. 

 

Pls:  1. If you have any test example LabVIEW Code of Incremental encoder, please do share.

        2. I am using IEH3-4096 Encoder (Per channel 1024 resolution) of Faulhaber with SbRIO-9627 in LabVIEW.

0 Kudos
Message 1 of 50
(1,275 Views)
Solution
Accepted by topic author rishab_kr

Hi rishab,

 


@rishab_kr wrote:

I am using an Incremental Encoder for which I am able to read the three pins (Phase A, Phase B and Phase C) of it and I am plotting the pulses. Now I wanted to calculate the angular speed of it. 

I am not able to understand that, based on the three signals how I shall proceed to calculate its angular speed. 


Angular speed is given by the reciprocal of of the pulse duration…

So you need to measure the duration of the pulses: I recommend to use the FPGA to count the time in ticks for each pulse.

This will work with just one pulse train…

 

To improve readings you should analyze A and B signals as they give you better resolution (4×, atleast for position measurements). You could measure the duration between each edge of both signals. (For speed measurement the resolution might be worse as there are shorter pulse durations for the same tick duration.)

 

What is "Phase C" of your encoder? Typically this is the zero pulse, which is useful for position measurements. For speed measurement you typically don't need it…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 50
(1,241 Views)

Thanks for your quick response,

 

Okay, so I have to count the times in ticks for each pulse (in the FPGA Target). 

 

Yes, In the documentation it is being used to measure the index so it can be excluded as of now. (I am taking about phase C).

 

I am new to LabVIEW; can you provide an example for it. I am trying for it but unfortunately not able to understand concept to count the pins.  

 

 

 

0 Kudos
Message 3 of 50
(1,229 Views)
Solution
Accepted by topic author rishab_kr

Hi rishab,

 

here's an example (usable on FPGA):

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 50
(1,217 Views)

I tried this code, and I rotated the encoder. So, 0 and 1 values were showing as an output. So basically, what this code is doing? So, what I am understand is I need to count the high (for phase A) and high (for phase B), then I need to subtract it. (please correct if I am wrong) and do some calculations with the resolution.

0 Kudos
Message 5 of 50
(1,194 Views)
Solution
Accepted by topic author rishab_kr

Hi rishab,

 


@rishab_kr wrote:

So basically, what this code is doing? So, what I am understand is I need to count the high (for phase A) and high (for phase B), then I need to subtract it. (please correct if I am wrong) and do some calculations with the resolution.


The shown code looks for edges in the boolean signal (using an XOR).

  • When there is no edge then the upper shift register counts loop iterations.
  • When there is an edge the upper shift register is reset to 0 (to start the next counting) and the lower shift register stores the last count.

You need to add some timing in your loop so you get a defined iteration time: iteration time × count gives a duration!

 

Why do you think you need to subtract pulse durations of A and B signal? Your diagram doesn't show any subtractions…

(Hint: you need to count duration between edges of A and B when you want to improve position measurement resolution.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 50
(1,186 Views)

I tried out something based on our discussion, please correct me if it does not make any sense to you.

 

0 Kudos
Message 7 of 50
(1,159 Views)

I think it does not make any sense. I am still working on it.

 

0 Kudos
Message 8 of 50
(1,124 Views)
Solution
Accepted by topic author rishab_kr

You are reading the A+, B+, and Z+ outputs.

 

An encoder works by creating pulses (A & B) a number of times per revolution.  Some encoders, as in your case, have a Z pulse that only occurs when the encoder rolls over at the revolution mark.  This if turning in the same direction will produce a pulse for every complete revolution of the encoder.

 

You need to understand how many pulses per revolution occurs in your encoder.  Usually it is included in the part number as a -1000 to imply one thousand (A & B) pulses per revolution.

 

Now the encoder needs to differentiate between forward and reverse rotations.  This is accomplished by following the pulse direction:

  • (AB) A & B are high [A B]
  • (AB) A is low and B is high [Anot B]
  • (AB) A & B are low [Anot Bnot]
  • (AB) A is high and B is low [A Bnot]
  • returning to (AB) above completes one rotational direction while moving backward in the sequence to (AB) is when the direction changes.

A & B will pulse high and low 999 times in one direction before another Z pulse occurs for a 1,000 pulse encoder.  If it is a 1000 pulse encoder, each A or B pulse will occur every (360 degrees / 1,000 pulses) = 0.36 degrees.  Using the A/B sequences can improve that resolution by a factor of 4 which can detect movement down to 0.09 degrees.

 

In your case, the IEH3-4096 Encoder is a 1024 pulse per revolution encoder with 4096 total steps (1024 * 4).  It would offer the smallest resolution down to 0.087890625 degrees per step.  A step is one step in the AB sequence above.  Only a single pulse for either A or B occurs during the 4 steps.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
Message 9 of 50
(1,108 Views)

I understand that A and B channel will give pulses whereas Channel C will give single pulse in a revolution. when you are talking about number of pulses in a revolution you are taking A&B combinedly. 

I understand the four conditions are useful to determine whether it is rotating in Clockwise or anticlockwise direction. 

I am attaching one code; can you check whether it is making sense to you. (Correct me if it is required).

 

Thanks for your time. 

0 Kudos
Message 10 of 50
(1,074 Views)