07-26-2016 10:26 PM
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)?
Solved! Go to Solution.
07-27-2016 01:24 AM - edited 07-27-2016 01:24 AM
07-27-2016 03:08 AM
@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)?
07-27-2016 04:10 AM - edited 07-27-2016 04:12 AM
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?
07-27-2016 04:25 AM
@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)
my problem is how to detect the rising or falling edge for the both channel A and B ?
07-27-2016 04:33 AM
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…)
07-27-2016 05:12 AM
@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
07-27-2016 06:07 AM - edited 07-27-2016 06:07 AM
07-27-2016 06:51 AM
@GerdW wrote:Hi Ambrose,
what have you tried so far?
Two solutions, both mentioned before:
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.
07-27-2016 07:24 AM
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!