From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quadrature Decoding

Solved!
Go to solution

Currently I'm have problem for the comparison signal A and B. From the vi below I'm using the feedback node to check the previous iteration(PI) and current iteration(CI) for signal A, if PI higher than CI it the signal will detect as falling edge and if PI lower than CI will detect as rising edge. So how I'm going to build an algorithm to detect whether the signal A lead B (detect as rising edge and is up counter) or the signal B lead A (detect as falling edge and is down counter)? 

0 Kudos
Message 1 of 29
(5,682 Views)

Hi Ambrose,

 

you just need to check PI/CI of A and B signal as shown in these tables

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 29
(5,646 Views)

@GerdW wrote:

Hi Ambrose,

 

you just need to check PI/CI of A and B signal as shown in these tables


I know to generate signal, but problem is how to know whether the signal is A lead B (then the counter will count up) or B lead A (then counter will count down)?

0 Kudos
Message 3 of 29
(5,632 Views)

Hi Ambrose,

 

those tables explain how to determine direction!

Examples:

When PI for AB is 00 and CI is 01 then you have a clockwise rotation/forward movement.

When PI is 11 and CI is 01 you see counter-clockwise rotation/backward movement…

 

You already know how to compare PI/CI for a single signal (either A or B), so what's the problem to compare the same for a combination of AB?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 29
(5,626 Views)

@GerdW wrote:

Hi Ambrose,

 

those tables explain how to determine direction!

Examples:

When PI for AB is 00 and CI is 01 then you have a clockwise rotation/forward movement.

When PI is 11 and CI is 01 you see counter-clockwise rotation/backward movement…

 

You already know how to compare PI/CI for a single signal (either A or B), so what's the problem to compare the same for a combination of AB?


Here is the signal i generated (pic below)

Capture.JPG

 

my problem is how to detect the rising or falling edge for the both channel A and B ? 

0 Kudos
Message 5 of 29
(5,623 Views)

Hi Ambrose,

 

in your first message you already described the algorithm: compare PI and CI of the signals…

You need a shift register and a comparison function!

(Or you try the PtByPt-BooleanCrossing function available in LabVIEW…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 29
(5,620 Views)

 


@GerdW wrote:

Hi Ambrose,

 

in your first message you already described the algorithm: compare PI and CI of the signals…

You need a shift register and a comparison function!

(Or you try the PtByPt-BooleanCrossing function available in LabVIEW…)


Mind you share out the vi how is it look like? I try so many way still not achieve. T.T

0 Kudos
Message 7 of 29
(5,611 Views)

Hi Ambrose,

what have you tried so far?

Two solutions, both mentioned before:

check.png

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 29
(5,603 Views)

@GerdW wrote:

Hi Ambrose,

what have you tried so far?

Two solutions, both mentioned before:

check.png

 


Thank you for your showing vi. What I want is detect if A lead B then each of the rising edge of the channel A the counter will count up and if B lead A then each of the falling edge of the channel B the counter will count down. This is what I finally want. I can generate the signal A and B but I dunno how to detect and compare the signal only. Thank you.

0 Kudos
Message 9 of 29
(5,595 Views)

Hi Ambrose,

 

did you read the Wikipedia article I linked above? Did you understand the part explaining AB/Quadrature encoders with rotary encoders as example?

 

You need to get the current state of A and B and compare them with their previous state. The tables show you the possible combinations and their meaning (forward/backward movement).

Comparing boolean signals is easy - as shown above. Comparing numeric values is also easy using simple comparision functions!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 29
(5,590 Views)