LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quadrature Decoding

Solved!
Go to solution

@GerdW wrote:

It's again a LV2015 VI. Please upload a downconverted version…


Sorry. here it is the LV 2014 vi.

0 Kudos
Message 21 of 29
(2,135 Views)

Hi Ambrose,

 

according to the tables shown in the linked Wikipedia article you need this logic:

IF RisingEdge(A) AND B THEN "count up"
IF FallingEdge(A) AND NOT(B) THEN "count up"
IF FallingEdge(B) AND A THEN "count up"
IF RisingEdge(B) AND NOT(A) THEN "count up"

IF FallingEdge(A) AND B THEN "count down"
IF RisingEdge(A) AND NOT(B) THEN "count down"
IF RisingEdge(B) AND A THEN "count down"
IF FallingEdge(B) AND NOT(A) THEN "count down"

You can combine those IF-THEN statements when ORing their conditions…

To detect edges on A or B you could use the BooleanCrossing function!

Best regards,
GerdW


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

@GerdW wrote:

Hi Ambrose,

 

according to the tables shown in the linked Wikipedia article you need this logic:

IF RisingEdge(A) AND B THEN "count up"
IF FallingEdge(A) AND NOT(B) THEN "count up"
IF FallingEdge(B) AND A THEN "count up"
IF RisingEdge(B) AND NOT(A) THEN "count up"

IF FallingEdge(A) AND B THEN "count down"
IF RisingEdge(A) AND NOT(B) THEN "count down"
IF RisingEdge(B) AND A THEN "count down"
IF FallingEdge(B) AND NOT(A) THEN "count down"

You can combine those IF-THEN statements when ORing their conditions…

To detect edges on A or B you could use the BooleanCrossing function!


I need to implement this vi on my fpga, is it effective? I feel take many resounces and the boolean crossing function I dunno how to use although i see the detailed help then that why I din implement on my vi. Mind you draw an example vi for me ? Thank you.

0 Kudos
Message 23 of 29
(2,130 Views)

Hi Ambrose,

it's the first time you mention the FPGA part…

The BooleanCrossing function is not available on the FPGA, use a feedback node with a boolean function instead (as shown before, so there's no need to attach another snippet). All the remaining comparisons are quite "small" on the FPGA!

Best regards,
GerdW


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

@GerdW wrote:

Hi Ambrose,

it's the first time you mention the FPGA part…

The BooleanCrossing function is not available on the FPGA, use a feedback node with a boolean function instead (as shown before, so there's no need to attach another snippet). All the remaining comparisons are quite "small" on the FPGA!


Let ignore the FPGA part first, from the picture below, i currently having the problem is detect the edge of A and B during A lack B case. Because A lead B i can compare the rising edge of channel A in the same time, then the A lack B case I dunno how to function it since the falling edge of channel A is not at the same time when A lack B. Currently i can produce the output because i direct set into 2 mode which A lead B and A lack B which din not detect the edge of the A and B. 

Download All
0 Kudos
Message 25 of 29
(2,109 Views)

Hi Ambrose,

 

it's nice to show some FP artwork, but without knowing your current VI we cannot troubleshoot your problem! (You know I prefer LV2014, don't you?)

Did you implement the IF-THEN logic I told you before?

 

Btw. use "lag" instead of "lack" 😄

Best regards,
GerdW


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

@GerdW wrote:

Hi Ambrose,

 

it's nice to show some FP artwork, but without knowing your current VI we cannot troubleshoot your problem! (You know I prefer LV2014, don't you?)

Did you implement the IF-THEN logic I told you before?

 

Btw. use "lag" instead of "lack" 😄


I test already. I feel that is the problem of timing. If can try modify my vi see how it works. Thank you.

0 Kudos
Message 27 of 29
(2,100 Views)

Hi Ambrose,

you need to implement ALL conditions.

And you need to implenent the edge detection in your main loop - do not hide them inside case structures (THINK DATAFLOW!)…

Best regards,
GerdW


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

There is some fundamentel that you need to look. 
You need to take a step back and look at your signals, and look at the wiki and the text code that GerdW posted. 

 

Lets take the first step. 

When A leads B you need to count up. 

When A lag B you need to count down. 

 

We start by only look at the signals when A changes from False to True, a rising edge. 

What is the value of B, when A leads B ? 

What is the value of B, when A lag B? 

 

( Dont use your mode button for the counting, only rely on the signals) 

0 Kudos
Message 29 of 29
(2,089 Views)