Showing results for 
Search instead for 
Did you mean: 

Count edges of 2 TTL signals (Heidenhain linear scale)

Go to solution

Hi all,


this is my first post, here. 🙂


I am currently trying to make a VI to use with a linear scale. The linear scale gives 2 TTL signals that have an offset of 90°. The change in distance of the linear scale is given by counting the rising and falling edges of both signals. See the following picture: Ua1 is signal 1 and Ua2 is signal 2. You can disregard the other signals.


2 TTL signals - Heidenhain.jpg


Now, I want to count the 4 edges in order to translate the 2 signals into distance. This means that I need two-edge counters for Rising-Rising, Rising-Falling, Falling-Falling, Falling-Rising for the 2 signals. I tried making 4 two-edge counters in LabVIEW but that obviously does not work, since only one DAQ can access the TTL card or I did it wrong.


Once I manage that, I also want to include the direction.


My TTL card: NI 9402

My Heidenhain interface electronic: IBV 100 ( - also the source of the picture)


Hardware setup: Linear Scale -> IBV (Interface Elektronic) -> NI 9402 -> LabVIEW

Signals: 3 Analog -> 3 TTL -> NI 9402


I hope I did not double-post. Any help would be greatly appreciated.

0 Kudos
Message 1 of 7

What I would do is get them into LabVIEW by normal analog input, and then just perform an edge detection.  that way you know exact postion of each rise/drop.


I don't know whether there is an easier solution with counters, but if there is, somebody will sure post in here.


Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 2 of 7

Your linear scale is essentially a quadrature encoder.


There are a number of help topics on that will help you better understand the concept.

This would be a good starting point (


Message 3 of 7
Accepted by topic author DarkHawk

I have used linear scales from Heidenhain in several applications.


As mentionned by the previous post, the output of your scale is like a quadrature encoder. Therefore you must use a counter input of the DAQ board to measure the position of the scale.

The desired X4 mode is done by the counter itself (not possible with some older boards from NI).


As a starting point, see Measure Angular which ships with the LabVIEW examples. According to your linear scale, change the type of the polymorphic DAQmx Create Channel VI to CI Linear Encoder and the label of Pulses per Revolution to Distance per pulse.


Don't hesitate to post again if you should need further help.

Message 4 of 7

Unfortunately I have never used the NI 9402 and therefore don't know the details about its unique counter.

But, because the NI 9402 is listed as a possible interface for above mentionned example, its counter should be able to interface the quadrature encoder type signals of the IBV 100.

0 Kudos
Message 5 of 7

Thank you all for the answers.


@ ABCPrograms: How would you do that? I am trying to find edge detection in LabView and came up empty so far. It is of interest to me to directly use the analog signals to be able to play around more.


@ JB: Thanks for the hints. So far it seems to work, but I am still working on getting the reference signal in ... let's see if that works.

0 Kudos
Message 6 of 7

In the mentionned example, enable the Z index and the counter will reset with the given value (z index value) each time the scale crosses the reference mark.

Notice that you must configure the Z index phase (levels of A and B when Z is active) according to the signals of the scale.

0 Kudos
Message 7 of 7