Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I measure the period of one TTL signal and the delay until a second TTL signal?

Hi,
 
I have a PCI 6024E board, the SCB-68 terminal box and am running LabView 6.1.  If needed I could install 7.1.
 
I have two Honeywell sensors (HOA7720) which each consist of an infrared transmitter and a infrared reciever.  When the beam is broken they output 5V, when the beam is open it outputs 0V.  These are sensing the presence of a hole in two discs passing thru the sensors.  
 
So as disc 1 rotates the signal is 5V until the hole passes thru sensor 1, then it drops to 0V until the hole passes.  Then it jumps back to 5 V. 
 
Disc 2 is rotating at exactly the same RPM as disc 1 because they are coupled with a spring loaded coupling.  There is a delay between the first hole passing thru sensor 1 and the second hole passing thru sensor 2.  The delay increases with torque. 
 
Using the oscilliscope function and connecting Signal1 and Signal2 to AIn0 and AIn1, I have verified that the TTL signals are there.  So electrically everything is working.  I just need to know how to measure the period and delay.  I'm familiar with A/D, but not with counters/gates etc and I think that's what is required here. 
 
The first measurement needed is RPM.   Somehow I need to measure the period of the TTL signal. 
 
The second measurement needed is the delay between the 1st falling edge and the 2nd falling edge.  
 
I don't think it's possible to use the millisecond timer for anything, because the accuracy wouldn't be good enough.  At 3600RPM the disc will spin 60 revs per second, or one every 17ms.  A resolution of 17 samples per revolution is not good enough.    
 
Help please!
 
0 Kudos
Message 1 of 8
(4,502 Views)
Hello CIETodd,

First of all, I highly reccomend that you use LabVIEW 7.1 so that you can use the DAQmx driver.

I suggest the following solution...
Use both counters to do buffered edge counting tasks, one for Signal1, the other for Signal2.  These tasks will return the value of the count register (which will simply be counting the edges of the onboard clock) everytime an active edge appears on Signal1 or Signal2.  In software, you can calculate the period of the signal.  For example, if you read a count value of 10 and the onboard clock is running at 10 MHz, then the period of the signal is 10/(10*10^6).  You will also be able to calculate the time between a falling edge on Signal1 and a falling edge on Signal2.  For example, if you read a count value of 10 when there is an active edge on Signal1 and you read a count value of 25 when there is an active edge on Signal2, this means that there where 15 clock ticks between the two edges.  You can find examples of buffered edge counting after you install LabVIEW 7.1 and the DAQmx driver.  They should be installed in this directory:
C:\Program Files\National Instruments\LabVIEW 7.1\examples\DAQmx\Counter\Count Digital Events.llb

I hope this helps!
Eric
DE For Life!
0 Kudos
Message 2 of 8
(4,494 Views)

Actually the pc crashed right after I started playing around with this.  As a result it's getting Windows XP and LabView 7.1 installed right now.

I'm glad to hear you say it can be done.  I have no idea how right now but will read up on 'buffered edge counting'

This seems very dependent on the onboard clock.  Is that something I can set at 10MHz or is it a constant depending on my A/D board? 

Thank you for the help, it is very much appreciated!

Todd

0 Kudos
Message 3 of 8
(4,492 Views)
Hello Todd,

The frequency you set the clock at depends on the onboard clock circuitry of the paritcular board you are using.  One you use a DAQmx Channel constant to specify the source, it should give you a list of the available clocks on your board.
Eric
DE For Life!
0 Kudos
Message 4 of 8
(4,481 Views)

Ok, I've got 7.1 installed, the board seems to be working in MAX.  Now I'm looking at 7.1 and it's very unfamiliar.

Can you tell me how to proceed?

Thanks, Todd

0 Kudos
Message 5 of 8
(4,471 Views)

It looks like my board (pci 6024E) doesn't support this.  Turns out I can't use more than one counter at a time.

What might work is to connect the two signals to analog-in's 14 and 15, which are open.  Then scan the waveforms from them using the multiple analog-in waveform scan at a fixed rate, hopefully 10,000 S/s or more.  Then by using the trigger function which will search for the position in the waveform where 0.5v is crossed with a negative slope (falling edge).  The difference in position between one and the next should be the delay*scan rate.

What do you think? 

The board specs say it can do 200,000 S/s.  Does this mean that I could actually scan the 2 channels at 100,000 S/s?  Or do other pc processes slow this scan rate down?

Message Edited by CIETodd@UB on 08-31-2005 07:56 AM

0 Kudos
Message 6 of 8
(4,467 Views)

It worked!

I ended up figuring it out today.  It's really simple.  I went analog in to AIn14 and AIn15 which were free. Then the program does a multichannel scan of the signals (collects array of 2 waveforms), Signal 1 and Signal 2 at some scan rate.  I used 100,000 S/s for 10,000 samples. Then I split the array into two separate waveforms.  Then I did an edge detect on each one and it returns the position in the array where the falling edge occurs.  The difference is the delay (after correcting for the scan rate), unless Sig2 comes first in which case the delay is the period - (or +) the difference
 
To find the period I used a subset of the Signal 1 waveform from the first falling edge on to the end of the waveform, then did the same edge detect except set the reset setting to true instead of false so it wouldn't detect the low signal which was now at the position 0 in the waveform.  So it would ignore the initial low value, wait for it to go high, then detect the falling edge position.
 
Anyway, it works awesome, seems very accurate and gives very stable readings.  3600rpm no problem.  It detects changes of one or two degrees in angular position, with a range from ~145 degrees to ~280 degrees
0 Kudos
Message 7 of 8
(4,459 Views)
Congratulations Todd! Smiley Happy

You made tremendous progress from a couple of posts up to your most recent post, very impressive!

I'm glad to hear that everything is working well.  Let us know if you need anything else.
Eric
DE For Life!
0 Kudos
Message 8 of 8
(4,452 Views)