Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

count for exact time

Solved!
Go to solution

Hi

 

I made a counter with USB-6343 as following :

johndoe_student_0-1594268920212.png

Delay decides how much time does it count.

when I run this vi with 1000hz input for 1000ms, it counts not only 1000 but also 1001, 1002, 1003.

 

It seems to count for not 1000ms but 1001ms or something.

 

I found a document about Real-Time OS or FPGA, but I'm using a USB-6343 in window10, so It's not help for me.

 

is there any tip for measuring a count in exact time(about 0.1ms or less) with USB-6343 and window10 OS?

 

thanks.

0 Kudos
Message 1 of 15
(3,162 Views)

So, you are well below 1% in error. Seems great for a non-RT OS! 🙂

Message 2 of 15
(3,133 Views)

Thanks for your response

 

In input 1000hz,

if I set a dwell as 100ms, it counts 100~103

if I set a dwell as 10ms, it counts  11~12😂

 

it seems to error is occured not in percent, but in constant ms(1~3ms).

does it happen beacuse code process have a latency that makes a ms error?

 

is 1~3ms error limited for non-RTOS? 

thtat means, should I use a RTOS to measure a ns accuracy?

 

thanks

0 Kudos
Message 3 of 15
(3,129 Views)

First of all, you cannot do software timing with more than a few ms precision. I am not familiar with your hardware, but maybe there is some hardware timing possible? I am not a hardware guy or familiar with your device, so hopefully somebody else will chime in.

 

(Why don't you multiply the array with 1000 before the loop and place index array before the loop? Dong these things once seems sufficient. Delay and dwell could even be an array control with two elements. No, this does is not the cause of your problems, just makes the code simpler.)

 

So your program is waiting for Xms, then sends a command via USB to the device to read the counter. This is not instantaneous.

Can you explain what you are actually trying to measure?  Maybe you could just spin the loop at a regular rate, reading the counter with each iteration, and compare the count difference of successive iterations using a shift register and also measure the actual loop rate. Now average over multiple iterations.

Message 4 of 15
(3,104 Views)

If you really need hardware-level timing precision, you can do it with another counter task on your device.  Configure the other counter to generate a pulse with 1000 msec pulse width and *also* configure the counter you have now to use that pulse signal as a "pause trigger".  Under pause-triggered operation, the action of counting is enabled or disabled by the digital state of the pause trigger signal.

 

You can easily try this using shipping examples.  The example "Counter - Single Pulse Output.vi" lets you configure and send a 1000 msec pulse output to a PFI pin.  The example "Counter - Count Edges.vi" lets you specify that same PFI pin as a Pause Trigger.  (Note: you'll want to set it to "pause when low".)    Start the edge counting task first, then whenever you run the pulse output task you'll be counting for exactly 1000 msec.

 

Note: in your screenshot, I would expect an error from trying to set "initial count" after starting the task.  I can only guess that the error wire passes *under* that property node or else the error would prevent you from reading your counts.  You don't need to set it explicitly anyway -- each stop/start cycle will automatically reset the internal count register to its default initial count of 0.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 5 of 15
(3,090 Views)

thanks for your response

 

what I measure is just how many pulse is signaled in sensor.

 

I change a power supply voltage(not in the code), then it output a pulse which is proportional to the voltage.

then I count the pulse and calculate pulse per second so that I can know how my experimental system react to a supplied voltage.

 

Reason why I want 0.1ms(not percent) accuracy is  I measure the pulse that is less than 1000hz for 0.1~10sec. 

if I measure 10sec and get average of it, then calculated  pulse per sec is  1000.1. It's fine

however if I measure 0.1sec, it  calculated to 1020. It's not fine.

 

 

 

 

0 Kudos
Message 6 of 15
(3,067 Views)

You can measure frequency directly with your board's counters.  There are shipping examples for this too.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 7 of 15
(3,063 Views)

I have some mistake sorry.

 

What I measure is not frequent. 

I mean, it count 1000 counts per sec but not 1 per millisec.

During 1 sec, sometimes it emits  pulses more, sometimes less. that is why I use a count task not a frequency task.

 

I'm sorry to confuse you

0 Kudos
Message 8 of 15
(3,058 Views)

You can easily convert between frequency and #of counts per.time unit.

0 Kudos
Message 9 of 15
(3,050 Views)

 In illustration,

signal and error draw.png

red is real pulse signal,  not 1000hz frequent signal(sorry to make you confused. it was just example).

grean is a time what I want to measure.

brown is error what I want to fix. it seems(not sure but it is caused by latency of vi function) constant. 

 

I make a green time by  wait time.PNG.

But it makes brown error, so I wonder how experts handle a problem when face it. 

0 Kudos
Message 10 of 15
(3,046 Views)