Quadrature Signal Measurement on T7-Pro | LabJack
 

Quadrature Signal Measurement on T7-Pro

3 posts / 0 new
Last post
wil1277
wil1277's picture
Quadrature Signal Measurement on T7-Pro

I have the following configuration for DIO0 and DIO1 as quadrature inputs:  

MB.W(44000, 1, 0) --disable DIO0

MB.W(44002, 1, 0) --disable DIO1

MB.W(44100, 1, 10) --set DIO0 index

MB.W(44102, 1, 10) --set DIO1 index

MB.W(44000, 1, 1) --enable DIO0 for phase A

MB.W(44002, 1, 1) --enable DIO1 for phase B

I'm using FIO0 for phase A and FIO1 for phase B connections on the labjack T7-Pro and I'm trying to measure (count) the rising and falling edges of both pulses.  I'm able to count the rising edge on phase A but not the falling edge.

I use this register to read the count:

phaseACount = MB.R(3000, 1) --read DIO0 phase A count

How do I read (count) the falling edge of the pulse on FIO0 which is my DIO0?  I'm using LUA.

 

LabJack Support
labjack support's picture
I ran a quick test with the

I ran a quick test with the below script and encoder: HRPG-ASCA-#16R

MB.W(44000, 1, 0) --disable DIO0
MB.W(44002, 1, 0) --disable DIO1
MB.W(44100, 1, 10) --set DIO0 index
MB.W(44102, 1, 10) --set DIO1 index
MB.W(44000, 1, 1) --enable DIO0 for phase A
MB.W(44002, 1, 1) --enable DIO1 for phase B

LJ.IntervalConfig(0, 500)
while true do
 
  if LJ.CheckInterval(0) then
    count = MB.R(3000, 1)
    print(count)
  end
 
end

 

The result counts up and down as expected.

The LabJack is using 4x decoding. Every edge is counted and two successive edges on the same line are considered a change in direction. Here is a pretty good description: http://www.creative-robotics.com/quadrature-intro

 

wil1277
wil1277's picture
Thank you, I appreciate the

Thank you, I appreciate the quick response.  It worked.