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.

Using Serial Sensors


jra Oct 13, 2009 04:31 PM

FYI ~ We have a new Application Note on Interfacing Serial Sensors.

http://www.campbellsci.com/documents/technical-papers/serial.pdf

Janet

* Last updated by: Janet on 10/13/2009 @ 10:32 AM *


GeodeNZ Oct 14, 2009 10:42 PM

Good stuff there, thanks.


Frenk Jun 25, 2010 08:45 AM

Hello!I'm new in the forum and in the world of electronics too..

The link above is very useful but unfortunately I have a CR5000 at which I want to connect Decagon digital sensors (5TM, frequency reflectometers for soil moisture measurements).
CR5000 doesn't recognize, in CRBasic editor, commands like:

SerialOpen, Serialflush,SerialClose (good for CR1000)

Do you know if there are equivalent commands that CR5000 can read?
Does a similar application note but for CR5000 exist?

Many thanks, I need to fix this problem as soon as possible..


aps Jun 25, 2010 08:58 AM

The CR5000 being a slightly older generation logger does not have wide ranging support for serial I/O that the newer designs have.

However, it does support SDI-12 sensors and the 5TM sensors has an SDI-12 compatible mode. For these connect the sensors to the SDI-12 port on the CR5000 and use the SDIRecorder instruction to read the sensors. Decagon can provide more info on using the SDI-12 mode of these sensors.


Frenk Jun 28, 2010 03:59 PM

Thanks a lot!
Actually is exactly what I'm doing, SDI 12 works well.


sbrown5000 Apr 24, 2013 08:56 PM

I'm trying to input a serial signal from a PC to a CR5000. If I download the latest OS for the CR5000 will it have the "wide ranging support" for this? I've got it kind of working using SerialInput, but it looks like from the application note that the newer commands are more useful.


GTProdMgr Apr 24, 2013 09:46 PM

To accomplish this, you either need to get an SDM-SIO1 for your CR5000 or resort to a CR3000/CR1000/CR800 datalogger.

The serial I/O support for the CR5000 was historically quite limited. SerialInput is a "legacy" instruction from that era. With the release of OS Std6 in December 2011, you can now attach an SDM-SIO1 to the CR5000. Only when using the Tx/Rx port of the SDM-SIO1 can you use the "modern" SerialIn, SerialOut, SerialOpen, etc. instructions. These instructions do work quite well in that case.

Check out the "SDM-SIO1" help topic in the CRBasic help system for the CR5000. For the COM port number in the SerialOpen instruction, you would use the sum of 32 + the SDM-SIO1's SDM address.


http://www.campbellsci.com/sdm-sio1
http://s.campbellsci.com/documents/us/manuals/sdm-sio1.pdf


sbrown5000 Apr 29, 2013 05:42 PM

Thanks for the information. The SerialInput function "works" in that I can collect some of the data output from the PC, but since (as I interpret things) the timing between the rate of output from the PC and the sampling rate of the CR5000 aren't syncronized, I miss a lot of points. Does the SDM-SIO1 resolve this?


GTProdMgr Apr 29, 2013 06:24 PM

The SerialInRecord and SerialInBlock instructions were developed beyond the SerialIn instruction to address issues like the ones you are describing. So yes, get the SDM-SIO1, connect it to the CR5000, then use SerialInRecord and SerialInBlock (along with SerialOpen, SerialClose, etc.) and that will all work much much better than the old/archaic SerialInput instruction to solve your problem (or any Serial Data I/O problem !)


GTProdMgr Apr 29, 2013 06:25 PM

You may want to review the details of SerialInBlock and SerialInRecord in the CRBasic help to get a feel for what I am talking about.


sbrown5000 Apr 29, 2013 06:33 PM

Will do, thanks again!


sbrown5000 May 28, 2013 10:21 PM

I'm now using the SDM-SIO1 with the CR5000 (with the updated OS). The data logs in well and doesn't seem to skip data points, but there seems to be a 1-2 minute delay between the sensor's output and the time when it gets logged by the CR5000. Is this a common issue, and if so, how can I resolve this? Thanks!


GTProdMgr May 28, 2013 10:26 PM

What is your scan interval and table output interval ?

If the CR5000 is only active 1x per minute, then there could be a delay of up to 59 seconds between the sensor output event and the time when the datalogger tries to read it.

Your program or snippets of it would be helpful


sbrown5000 May 29, 2013 01:04 PM

The scan interval and table output interval is at 100 mSec. Here is the program (I adapted it from a friend's program for a CR1000):

SequentialMode

Public PTemp, batt_volt, NBytesReturned, NBytesBuffer
Public RawString As String * 1000, SplitStrings(13) As String * 30
Public ZeroBytes As Boolean

Const TimeDelay = 4

DataTable (Table1,1,-1)
DataInterval (0,100,msec,10)
Sample(1,TimeStamp_anlz,String)
Sample(10,SplitStrings(2),IEEE4)
Sample(1,NBytesReturned,UINT2)
Sample(1,NBytesBuffer,UINT2)
EndTable

BeginProg
SerialOpen (32,19200,0,0,8000)

Scan (100,mSec,0,0)

NBytesBuffer = SerialInChk(32)
SerialInRecord(32,RawString,&H0A,0,&H0D,NBytesReturned,11)

If NBytesBuffer < 1500 Then
Delay(0,TimeDelay,mSec)
Else
EndIf

If NBytesReturned = 0 Then
Delay(0,TimeDelay,mSec)
SerialInRecord(32,RawString,&H0A,0,&H0D,NBytesReturned,11)
Else
EndIf
SplitStr([i]SplitStrings[/i(),RawString,",",13,0)
CallTable Table1
NextScan
EndProg


GTProdMgr May 29, 2013 02:36 PM

The program looked fine (except for TimeStamp_anlz which
wasn't declared as a variable before being used).

How are you looking at the logged data on the CR5000 ?
Are you using LoggerNet, PC400 or RTDAQ ?

Could it be you have a 1 minute scheduled collection set up in LoggerNet ? To see data more often than the LN scheduled collection interval, you need to be connected to the datalogger with the ConnectScreen or similar.

How often does the sensor send out data ? If it sends out data only once per second, I would slow down your main scan rate.

Does your program show any watchdogs, skipped scans or skipped records in the Status table ?


sbrown5000 May 29, 2013 06:34 PM

Hello again - the instrument sends data out at a rate of 10Hz. I adjusted one of the settings and restarted the instrument and now the data does not appear to be lagging. Hopefully everything will work smoothly now. Thank you for your help!


sbrown5000 May 31, 2013 12:43 AM

I may have spoken too soon... after running it for a bit there does appear to be a lag in the rate at which the CR5000 is collecting the data. Is there anything that I can change in the program to resolve this?


aps May 31, 2013 09:40 AM

The most likely explanation for this is not that there is not a real lag but the sensor is sending too much data and the logger is pulling data further and further back in its serial buffer...read on.

This is a common issue because you have two systems with independent clocks. If the clocks drift relative to each other and the sensor is sending data with no sychronisation to the logger you either end up with too much data (if the sensor clock is running faster than the logger) or two little data (if slower). This is seen by either a build up of data in the serial buffer of the logger or no data being there when you expect it to be. The rate at which this happens varies with the relative drift of the clocks; it may happen every few minutes or every day.

There is no perfect solution to this if you cannot force the sensor to sync to the logger clock (e.g. where you prompt for data from the sensor).

The practical solution to this is offered by use of the last parameter of the serialinrecord instruction. You can change this to read the most recent record in the datalogger buffer. This will effectively skip over extra records in the sensor is sending them at a higher rate than they are read.

If the sensor is running slower though you will find the opposite problem, i.e. no data in the buffer when you need it. For that we offer the solution of either reporting "NaN" or duplicating the last measurement read. (Neither of these is ideal if processing time series, but the latter is less problematic but scientifically not quite correct.)

If you use these options you will then only need one call of the Serialinrecord in your program.


sbrown5000 May 31, 2013 12:37 PM

I think the problem is that the data is coming in faster than the logger at times. Luckily the sensor does log the data as well since it is a PC, so I'm going to try setting the buffer to a low value (~200). I can fill in any NaN's that get recorded with the data from the sensor. I've set the last parameter in SerialInRecord from 11 to 01 so that it will get the latest output from the sensor. I think that's the best that I can do for now. Thanks!


markspend1 Jul 11, 2013 11:28 AM

Hey Guys well i think that's a great information about serial sensors like SD1,SD2 ETC..


S-Type Beams

* Last updated by: markspend1 on 7/13/2013 @ 6:11 AM *


m125 Aug 7, 2013 11:06 AM

Hey Guys well i think that CR5000 is often operated by its on-board standard rechargeable power supply.When its used, its inner battery power needs a vehicle or ac battery power charger.Thanks!!

S-Type Beams

* Last updated by: m125 on 8/20/2013 @ 8:36 AM *

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