Hello,
I want to measure the surface flow velocity of a torrent with a CR1000.
Therefore i have got a radar velocity sensor that is usually used for speed measurement of vehicles in traffic flow.
In a pretest i have checked if the sensor works for this kind of application, connected it via RS232 to a laptop an read out the sensor with hyperterminal (9600-8-N-1). The measuring values are sent like this in a constant string:
" ... 4.7;4.3;3.5;4.4;3.7;3.8;3.7;3.4;3.5;5.1;4.4; ... "
The test showed that the values are not sent in defined intervals. Dependent of the positioning of the sensor the intervals vary due to the mounting angle, grade of reflectivity, intensity of turbulence, etc. in a range of about 5 measurements/second in good conditions to one measurement every 2-3 seconds in suboptimal configuration.
Nevertheless i want to write the measured data every second into the data table, even if the measuring interval differs.
As i am not a very experienced programmer i don´t really know how to implement the sensor into the CR-Basic program.
Has anybody got a good idea (or even better a code snippet) of getting the sensor to work?
Thanks for any hints.
Give this a try. The tx from the RS232 will go to C2 on the CR1000. This code will drop out a lot of the data values, but will give the most recent number that was between two semicolons.
Public Speed
Public NbytesReturned As Long
Dim tempString As String
'Main Program
BeginProg
SerialOpen (Com1,9600,0,0,50)
Scan (1,Sec,0,0)
SerialInRecord (Com1,tempString,59,0,59,NbytesReturned,01)
Speed = tempString 'converts the string to a numeric variable
NextScan
EndProg
Thanks for your reply - I'll give this a shot!