LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

two edge seperation counter

Hi,
 
I'm struggling to use the counter on a USB 6251 to count edges - can anyone advise?
 
I need to count edges on the source input between aux and gate inputs, using Two-Signal Edge Seperation Measurement as described on page 7-18 of the M series manual (April 06 371022F-01 release of this document). The device should be capable of this, it was sold to me specifically to perform this task.
 
My problem is that I can get seconds or ticks between edges on the Aux and Gate signals (on PFI 10 and 9 for counter 0), but not a count from the source input.
 
I have verified both in MAX and my own code that the source input works - level changes can be detected there.
 
Is there a setting I have missed that forces the device to read from the Source input (PFI8 for counter 0), instead of using it's own clock?
 
See attachment for code.
 
Bandit
0 Kudos
Message 1 of 8
(3,019 Views)
Hi Bandit,

What exactly do you want to count? What is your application? The Two-Signal Edge Seperation Measurement is meant to give you the time between the rising edge of one signal and the falling edge of another signal. Try searching for "Measuring Period, Semi-Period, Pulse Width, and Two-Edge Separation" in the LabVIEW 8 help for a full explanation. If you want to count the edges of a signal then you need to use a DAQmx Count Edges task.

Regards

Jon B
NIUK Applications Engineer
NIUK
0 Kudos
Message 2 of 8
(2,999 Views)

Hi Jon, thanks for the reply.

I'm measuring dynamic wear on a rotating drive nut. The nut is driven up and down a fixed threaded rod. Start trigger (edge one) is from a fixed position the nut passes. Pulses are counted from regular spaced lines around the nut. An index mark against one of these lines provides the stop trigger (edge 2). As the nut wears, the pulse count between edges will change and so wear in the thread can be measured. For this application a time isn't what I need - it's the fraction of a turn the nut makes between the start and stop trigger that I need to measure.

The USB 6251 was chosen for this task in conjunction with my local NI field engineer. We selected it after reading the M series manual section on Two-Edge Seperation, which describes measuring the seperation of 2 signals either in time, or as a count of source events (as per my original, not very detailed post). I have posted after spending a day trawling help files, product manual, vi libraries, user forum and knowledge base.

Two edge measurement should work from rising or falling edge of aux to rising or falling edge of gate (and it does). You get to choose rising or falling edge for each with the DAQmx Create Channel.vi in it's (CI Two Edge Seperation) variation.

The only problem I have is getting a timing input from the source connection.

I will check the DAQmx Count Edges task as you suggest, though at the moment I don't know how I use both start and stop triggers.

Watch this space for an update, or post any further info you come up with.

Regards,

Bandit. 

 

0 Kudos
Message 3 of 8
(2,996 Views)
Hi Again,

I think by default that task will try and count pulses from the internal timebase of the card. I have modified the code so it specifies an external timebase. Have a go with this one and see if it works.

Regards

Jon B
Applications Engineer
NIUK
Message 4 of 8
(2,990 Views)

 

 

Hi Jon,

Thanks for this - from the schematic it's exactly what I was trying to do - I just couldn't find the property to change.

Sadly it doesn't work though - I get this error message as the triggers don't seem to have any effect and the read function times out...

Error -200474 occurred at DAQmx Read (Counter DBL 1Chan 1Samp).vi:1

Possible reason(s):

Specified operation did not complete, because the specified timeout expired.

Task Name: _unnamedTask<28>

Oddly though if your new timebase source is changed to internal clock, the code works as before. Triggers work fine and the count is read in timebase ticks.

There is something else funny here that I haven't spotted yet.

Bandit.

 

 

 

0 Kudos
Message 5 of 8
(2,986 Views)
Hi again Bandit,

I had this running with two out of phase square waves at 1Hz for the two edges and I provided the timebase ticks from a separate TTL square wave that I could adjust the frequency of. The time out error usually occurs when the two edges you are measuring ticks in between are further apart (in time) than the time out value for the DAQmx read function or you are receiving no timebase ticks from your source for the period between the two edges. As you say it works fine with the onboard clock I would think it is the second case where you are not receiving the timebase ticks from you source. Check that they are going into the right terminal and maybe try also wiring them into an analogue input terminal to check the signals being output by your device.

Regards

Jon B
Applications Engineer
NIUK
Message 6 of 8
(2,983 Views)

Hi Jon,

It's working now.

During fault finding I had disconnected my clocking signal from the source input on PFI8. I had been using it originally, but it was disconnected before you showed me the timebase source property. I thought without a signal I would get a reading of zero, or perhaps a spurious reading from a floating input. Instead I was getting a timeout error. I'm not sure why an error is generated when there isn't a timebase signal connected, I thought the start and stop edges would be enough to get a reading, even if it was zero.

Connecting a proper timebase signal means the system now works.

So in sumary, the solution is to ensure source is connected to PFI 8 using DAQmx Channel property CI.CtrTimebaseSrc, and make sure there is a timebase signal connected to the input.

Thanks for your help with this, I would never have found the right property to change the source without your help.

Best Regards,

Bandit

0 Kudos
Message 7 of 8
(2,980 Views)
Glad that works for you now.

Regards

Jon B
Applications Engineer
NIUK
0 Kudos
Message 8 of 8
(2,971 Views)