Showing results for 
Search instead for 
Did you mean: 

Ticks/Count from Encoder

I was little reluctant to post this question but then convinced myself that it will favor those who are looking for solution like me.


So,i have a rotary encoder from which i would like to know the ticks/count.The logic i used is subracting the current tick with the initial tick and checking that with a constant value.This being fed to a case structure,if the value obtained is greater then the tick/count is fed 0 otherwise i tried incrementing it by 1 though a shift register.Here is were i am facing problem,that value keeps incrementing --not sure if this is correct.



0 Kudos
Message 1 of 7
Could you post the VI so that it is easier to debug and tell where exactly it is not working?
0 Kudos
Message 2 of 7

the encoder loop in


The problem while finding ticks/count--False case

0 Kudos
Message 3 of 7

I must say this : 


I don't have the FPGA and all the wires are broken Smiley Tongue

-You mentioned shift register and there is no initialization for shift registers. If that is the case please initialize with 0. Similar for feedback nodes.

-If you do not initialize the shift register, the loop uses the value written to the shift register when the loop last executed or, if the loop has never executed, the default value for the data type.



Edit: I did Ctrl+U and it cleared up a little bit and tracked the tick/count and i see that you are checking if it is equal to zero and then using select am i right? which contradicts your first comparing the tick count subtracted and checked with constant value! 

-If that is not the case please create sample vi and try the logic first and let us know where you are stuck instead of integrating bunch of things in single vi and trying to debug.

0 Kudos
Message 4 of 7

With a single VI taking more than one screen, with many (many!) wires going all over the place, no sense of sequential order.  I suggest re-thinking and restructuring your code, perhaps around a State Machine, and "hiding the details" in sub-VIs so that you (and we) can "see the Forest for the Trees". 


Bob Schor

0 Kudos
Message 5 of 7
I thought about state machine but DAQ must happen continuously while other loops must also run in parallel,thus coined this method.
0 Kudos
Message 6 of 7

@krupa wrote:
I thought about state machine but DAQ must happen continuously while other loops must also run in parallel,thus coined this method.

This is called Producer/Consumer, and is well-enough developed that there are even LabVIEW Templates for this!  Open LabVIEW, go to File, New ... (the dots are important), look under VI/From Template/Frameworks/Design Patterns and choose Producer/Consumer Design Pattern (Data).  You can also Create Project and look at Continuous Measurement and Logging (there are two of them) in the Sample Projects.  There's a lot of stuff there, but you can tailor this to fit your needs.  It might merit a day of study, however ...

Bob Schor

0 Kudos
Message 7 of 7