10-02-2016 01:11 PM
Tried to use the USB 6001 Counter/Timer channel to monitor around 4 pulses per second but resultant display was not very accurate as the pulse rate changed so have tried to use an analogue input channel instead.
This has improved situation and gives more accurate results.
However the overall program now runs slow and front panel controls are also slow to respond. I assume this is down to the use of hardware 'sample clock' function?
Attached snap of code in case I have something wrong that has slowed the code down.
10-05-2016
07:23 AM
- last edited on
05-14-2025
07:11 PM
by
Content Cleaner
Hi Jack,
The reason this is running slow could be because of the amount of processing occuring on every loop iteration. You could try having one loop for the acquisition of your data and a separate loop for the processing of it.
This is a common design pattern for data acquisition programs such as yours because it removes the possibility of the software processing interfering with the data acquisition part of the code.
Please see here for more details;
10-05-2016 09:54 AM
H Michael,
Thanks fo reply. Yes I use the producer consumer on serial data and barcode scanned data etc but unsure if it woul dhelp here. I had the same thought but there are 2 other loops running in addtion to this one and the tasks they perform has also been reduced by the same amount as the code I posted. So in effect the whole program has been slowed down by using that piece of code.
I have now done a 'work around' where I have gone back to using the counter channel. Using the elapsed time function I basically 'open a gate' (case statement) for a set period of time, count the pulses on falling edge of counter for that period and then calculate the frequency of the signal. Although not ideal and update is slow it works and the longer 'gate' is open the more accurate it becomes.