Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

count leading and falling edges

Hi Dave,

 

I've attached a subVI that should work in LV Base--use this instead of the Extract Single Tone Information.vi.

 

Remember, the resolution of your measurement using this method is approximately 1/(sample time), so if you wanted a 1 Hz resolution you would have to measure for 1 second. 

 

The counter method I mentioned previously would be a more accurate way to make the same measurement, however the hardware would be a bit more costly.  If you already have a cDAQ chassis then it might make more sense to go with one of the digital I/O modules to gain access to the counters.

 

 

Best Regards,

John Passiak
0 Kudos
Message 21 of 40
(1,832 Views)

John,

Thanks for the vi.  Do you think think the USB6501 is a good choice for my application?  I need to count 3 channels, but, I believe the 6008 is only one counter. What do you think?  I was told that there is a "Count Rising Edge"  function built into the Labview Base version that I can use with the counters on the 6501.  Are you familiar with that function?

Dave

0 Kudos
Message 22 of 40
(1,829 Views)

The counters are a function of the hardware and so don't depend on a specific version of LabVIEW.

 

However, the 6501 has the same counter as the 6008.  The count register can only be sampled by software-defined intervals, and it cannot be gated.  So, there is no way to deterministically measure the frequency of your signal using the counter on the 6008 or 6501.  Even if it could, there is still only a single counter per device, and you mentioned you need 3 signals.

 

The counter suggestion I was referring to is the 9171 cDAQ carrier (if you already have a cDAQ chassis then perhaps you can use this instead--all of the latest generation cDAQ chassis have 4 counters), along with a DIO module like a 9401.  This would give you access to 4 full-featured counters which would be the better way to measure frequency assuming the signal confirms to TTL logic levels. 

 

The analog input method on the 6008 might be suitable for you as well, but I wouldn't suggest using the edge counter on the 6008.  If your signal was higher frequency then you might be able to get suitable accuracy with the edge counter, but even then it would only be on a single channel.

 

 

Best Regards,

John Passiak
0 Kudos
Message 23 of 40
(1,827 Views)

John,

 

I see what you are saying.  The 9171 is a chassis.  I currenly own cDAQ chassis 9174.

I guess I misunderstood the NI engineer I spoke with today.  I thought he said the difference between the 6008 and the 6501 is that the 6008 is one-channel, but, the 6501 is 4-channel....hmmm...that is a bad misunderstanding to have in place.  He offer the same alternative you did, to use the counters built into the chassis with the 9401.  I already ordered the 6501.

 

Given that my frequency is going to be in the range of 30-100Hz per sensor, and we want to measure 3 sensors simultaneously, do you think the 6501 can handle that data rate?  Should I change this order and go with the 9401 instead?  My understanding is that my data rates are small enough that the 6501 and software timing would be good enough.  Do you agree that the 6501 can handle 3 sensors at 30-100Hz each, for a potential maximum of 300 signals per second?

 

Just to clarify, we have a photo-sensor that is outputting a voltage pulse, an analog voltage when the light is reflected onto it.  Will the 6501 accept this voltage and count the pulses with an edge counter function?

 

Thanks,

Dave

 

0 Kudos
Message 24 of 40
(1,818 Views)

Hi Dave,

 

The 6501 has software-timing only on the digital lines.  So, each sample will be a few ms apart.  Your 100 Hz signal only has a period of 10 ms, so a few ms resolution for your sample clock makes the 6501 essentially unusable for the task (the better way to measure frequency on the 6501 still involves the counter, but there is only one of them on the device).  Furthermore, since the timing is software-defined, any task that Windows decides to allocate to your CPU could add an indeterminate amount of jitter.  In short, I would avoid using the 6501 to measure frequency.  I believe NI's return policy should allow you to return the 6501.

 

If you already have the 9174, you'd be better off ordering a 9401 to use with it.  You could use a 9402 instead if you wish, it has BNC connectors instead of screw terminal.  Either of these modules will give access to the four counters which are on the 9174 backplane.

 

You didn't mention the voltage levels of your pulse.  All of the hardware discussed so far uses TTL logic levels (except the 6008 analog input example).

 

 

Best Regards,

John Passiak
0 Kudos
Message 25 of 40
(1,805 Views)

John, thanks for the explanation.  Our voltage is about 1-2mV in the OFF state, and about 2000mV in the ON state.  However, with minor modification,we can easily make the ON state 3000 or 4000 or 5000mV, for the TTL. 

 

I understand your explanation, but, I have one question.  If the 6501 is not a good way to measure frequency, what do people use the counter for otherwise? 

 

Thanks,

Dave

0 Kudos
Message 26 of 40
(1,802 Views)

Hi Dave,

 

The counter on the 6501 (which is also used on the 6008/6009) is not the same as the counter on most other NI Hardware.  It cannot be gated, so it can't be used to make deterministic frequency measurements.  You can count TTL pulses and read them back using software-timing. 

 

Off the top of my head, one example use case for this would be to report back the position of a stepper motor to the user.  Of course, there are an indefinite number of use cases that one might come up with, this is just an example.

 

 

Best Regards,

John Passiak
0 Kudos
Message 27 of 40
(1,801 Views)

Hi John,

I received my USB-6501 digital I/O module last week, and I have successfully used some example vi's to demonstrate it to myself.  I understand your comments about using the 6501 as a timer, that it has only 1 counter onboard, and any other counting would be software timed, and of inferior accuracy.  My question is the following:  If there is 1 hardware counter, can I use it, and configure the other digital signals for s/w timing, and sort of "mix" the timer types?  Suppose I have 3 sensors with digital outputs.  Can I wire one of these sensors to the counter on the 6501 and the other 2 sensors to be digital inputs, and use software (like the millisecond timer) to time the other two?  Is there any prohibition to configuring it like this?

 

Dave

0 Kudos
Message 28 of 40
(1,785 Views)

Hi Dave,

 

I'm not sure you read my post carefully when I mentioned that you shouldn't use the 6501 for this task.

 

The counter is not ideal, but it's the best you've got.  You can count edges, but the sampling of the counter is software-timed.

 

The DI lines can only be sampled in software timing.  You'd have to guarantee at least two samples per period of your signal to ensure you don't miss edges.  At 5 ms high and 5 ms low, I don't think you can really make this guarantee.

 

 

Best Regards,

John Passiak
0 Kudos
Message 29 of 40
(1,781 Views)

Yes, John, I did understand that your advice was to not use the 6501 for this application, but, I had already ordered it, and I am going to try to make it work.  If it doesn't, then, I will get the other module that you recommended for the cDAQ chassis backplane counters.  I understand that the DI lines can only be sampled in software.  What I am wondering is if I can do 2 software timed DI lines, and a third that uses the counter in the 6501, essentially "mixing" timing mechanism, two software and one hardware timed.

0 Kudos
Message 30 of 40
(1,777 Views)