Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Measure frequencies with fast scan rates


Karsten Jan 16, 2012 01:08 PM

Hi, I tried to scan Frequency samples received from a Geonor Precipitation Gauge by a cr1000 data logger. I am using the pulse input P1 and want to send the frequency samples and some average frequency values over RS-232 to a PC. It seems to work fine if the scan rate is not faster than 1000ms. If it's faster, e.g. 100ms, my resolution decreases (e.g. by 100ms scan rate the resolution is only 10 Hz. This means that measured frequencies can be e.g. 1050 Hz, 1060 Hz, 1070 Hz, ... in steps of 10 Hz).

Thanks for your reply!

My CRBasic code is as follows:


Public Freq
Public SerialOutString As String * 20
Public avArray(1,1)

DataTable (Test,1,1000)
DataInterval (0,10,Sec,5)
Average (1,Freq,FP2,False)
FieldNames ("Avg_Freq")
EndTable

BeginProg
Scan (200,mSec,0,0)
SerialOpen (ComRS232,38400,0,0,10000)
PulseCount (Freq,1,1,0,1,1.0,0)
SerialOutString = Freq & ","
SerialOut (ComRS232,SerialOutString,"",0,100)

If Test.Output(1,1) Then
GetRecord (avArray,Test,1)
SerialOut (ComRS232," * " + avArray(1,1) + "
* ,", "",0,100)
EndIf

CallTable Test
NextScan
EndProg


aps Jan 16, 2012 02:14 PM

I am afraid what you are seeing is a simple limitation of physics caused by trying to measure a low frequency to quickly. If the frequency is around 1000 Hz, then in 100 msec the logger will only see 99, 100, or 101 pulses depending on where the pulses fall relative to the scanning of the logger. Multiplied up to frequency, the logger will multiply by X10, which gives you the steps of 10 in Hz.

To avoid this you can either:

a) switch to using the periodavg instruction, but setting the cycles to be the lowest count ever expected within the 100 ms scan interval (acutally set it a bit lower than that to allow the logger to do the remaining tasks in the scan). In this mode the logger measures the time it takes for that number of cycles, rather than count the number of pulses it sees in 100 msec.

b) using the special pulse count option in the standard Pulsecount instruction to do a running average over a longer timescale, although this may defeat the object of outputting the data so fast.


TweedleDee Jan 16, 2012 09:20 PM

You can use the TimerIO instruction using one of the 8 I/O ports on the logger (C1 trhough C8). These are limited to higher voltage levels and frequencies under 1000 hz, but I see from your program that the signal is set as High Frequency, so the voltage level is adequate. Now just as long as the frequency is lower than 1000 Hz ...., you will be able to get far better measurement resolution.


Karsten Jan 18, 2012 02:34 PM

Thanks aps and TweedleDee for your answers.
Yes, now I realized that I can’t use the pulse count method with scan rates < 1s to get resolutions of 1 Hz.
My measured frequency is in the area of 1000 Hz to 3500 Hz.
I also thought about a TimerIO usage and read about the limitation of f <= 1000Hz.
Perhaps an additional frequency divider would be a solution. But to avoid further devices I have tested the way a) aps mentioned. This is working well. I have used a scan rate of 40 ms and have averaged over 4 periods (perhaps some more periods are possible but I have to consider that some computation power is needed for the serial output).
I will go on testing.

Log in or register to post/reply in the forum.