Campbell Hausfeld SDM-SIO4 manual Example of Using Received Data Filters, 2 CR10X Program Example

Page 59

Section 6. Data Error Detection

6.2.1 Example of Using Received Data Filters

If a sensor transmitted the following string:

Frequency=12.34567HzBB3DCrLf

then a user defined filter string would have to be used. The BB3D part of the string is the CRC sent in hex. from the sensor. To produce a filter string to deal with the sensor output you could type in the following command:

FLTST 100 “T[Frequency=]xg2n10fCCG8”

FLTST is the command to store a user defined filter from the command line.

100 is the string number you want to store it under this can be 0-255.

is the start of the filter string.

T[Frequency=] is a filter which looks for an exact string match for “Frequency=”. The next filter will only start if this string matches what is sent from the sensor. “Frequency=” is not removed from the receive buffer.

x this filter marks the start of a data set; in other words the data will only be available for the datalogger to collect when the complete string is received correctly.

g2 this is the filter that tells the SDM-SIO4 to use the CRC16-CCITT algorithm. It initialises the CRC16-CCITT algorithm to start calculation on any characters from this point.

n10 This filter discards the 10 ASCII characters that make the word “Frequency=”. Note: The word is discarded after filter g2. This is to ensure that the discarded word will be included in the CRC calculations.

f this filter gets the numeric value from the sensor and converts it into a format the datalogger can use. Because filter “x” was used this converted value will not be available for the datalogger to collect until the CRC16-CCITT signature check is done. In this case the value converted is “12.34567”.

C this filter removes the char “H”.

C this filter removes the char “z”.

G8 this filter tells the SDM-SIO4 that the next ASCII hex is the start of the checksum from the sensor. It also defines the data type to be ASCII hex 16 bit. This filter will wait until enough characters have been received to make the hex number up, in this case four bytes of ASCII hex. When the characters have been received, the SDM-SIO4 will compare it with the check sum it calculated on the received data. If they match then the value converted with the “f” filter is made available for the datalogger to get. If the checksums do not match then the value is discarded as soon as any error is detected.

marks the end of the filter string.

The above example is just one way of using a filter to achieve the required result.

6.2.2 CR10X Program Example

A typical CR10X datalogger program to work with the above filter is shown below.

Assume the SDM-SIO4 is set to address 0, the sensor is connected to port 1 of the SDM-SIO4 and the port settings, baud rate, etc. have been set. The sensor outputs its string every second. Only the parameter values to be entered into the appropriate instructions are shown.

6-3

Image 59
Contents Issued Page Guarantee Page Contents Appendix A. Ascii Table Data Error DetectionIntroduction What is the SDM-SIO4?Datalogger Command Control Serial Port Buffers SpecificationsSDM-SIO4 Serial Port Pin Configuration Serial PortsEnvironmental Operating Range Power RequirementsSDM Port CaseOther Key Features Page Selector Block Settings SDM Address Installation and Hardware Set-UpSetting the SDM Address Address SettingsTransient Protection and Grounding Selecting RS232 or 5V Logic for Each PortConnections to the SDM-SIO4 No. of Flashes Description of error/status Power-on Tests the Status LEDStatus LED Error Codes Page Method of Entering Special / Control Characters Understanding How the SDM-SIO4 Handles DataIntroduction Simple Filters Input FiltersFilter Types Filter Strings Ibn8Ficn8F Filter No Filter String Used Output FormattingSimple Output Formatter Predefined Filter StringsOutput Format Strings CR10X Program Example Fmtst 123 z261 f62 iBattery z257 f61z273Get panel temperature Get battery voltageProgramming the SDM-SIO4 Command Line Operation and StructureEntering Commands Basic Commands Advanced Commands WD n Wderr n Wdaddr n ErrorresHexdump start address number of bytes Bytewr address byteTestio returns Testio test#Page Instruction 113 Parameters Programming the DataloggerParameters 9 and 10 Multiplier and Offset Commands and Options Parameters 4, 5Parameter 7 Values per Rep Parameter 8 Starting Input LocationUnderstanding Parameter Options and Returned Values Command 1 Poll of Available DataCommand 5 Status Command 2 SignaturesCommand 3 Flush all Receive Buffers Command 4 Send Data to DataloggerCommand 9 Flush Converted Data Buffer Command 6 Flush Transmit BufferCommand 7 Activate Command Line Command 8 Poll Tx Buffers for DataProgram Example for P113 Command Command 67 Get Return CodeCommand 320 Send Byte Data to SDM-SIO4 Command 321 Execute Command Line CommandExecute the command line string First Value Returned Command 1024 Send String to DeviceCommand 1025 Transmit a Byte Command 1026 Serial Port StatusFourth Value Returned First Command Option Reset Error CountersSecond Value Returned Third Value ReturnedCommand 2049 Set Communications Parameters Command 1027 ‘Manual’ Handshake ModeSecond Command Option Parameter First Command Option ParameterCommand 2054 Set Up Receive Filter String Number or Character Code Example CR10X Program SDM-SIO4 Configuration ExamplesCommand 2305 Transmit Bytes Get two floating point numbers into locations 1 End of serial and filter setupSet flag one high so the above will only be done once Strst 101 Send DataJM Example CR10X Program Using Instruction P113 CommandWait long enough for sensor to send data Set up the filter and then send stringInstantaneous sample form the sensor Sensors Which Send Data Out Without PromptingGet data from SDM-SIO4 and put into locations 1 Time stampFltst 200 tdataA5xff Example CR10X Program without Polling or InterruptsInstantaneous values stored to final storage Example CR10X Program using the Polling MethodEnd of set up Get the two floating point values from the SDM-SIO4Set flag one high so the filter set-up is only done once Set up string filterDelay required by filter set-up command Do filter set-up only if flag one is clearInstantaneous value stored into final storage Example CR10X Program using InterruptsGet voltages into locations 3 and 4 if poll was true Set control port 8 to i/p so it can be used as an interrupt Do filter setup only if flag one is clearDelay required by filter setup command End of interrupt routine Interrupt routine for control portGet voltages into locations 3 Instantaneous readings stored into final storageOutputting Datalogger Data Flushing the Input and Output Buffers Return Error CodesReceived Data Data Error DetectionError Detection with the SDM-SIO4 SDM-SIO4 User Guide Fltst 100 TFrequency=xg2n10fCCG8 Example of Using Received Data Filters2 CR10X Program Example Tell the SDM-SIO4 to use filter string Minimum delay of 4ms is required by the above P113End of filter setup End of get data CRC32 Transmitted DataFmtst 100 g1i123456789G8 Example of Using Transmitted Data FiltersFmtst 100 g1 Fmtst 101 isome data Fmtst 102 f62 G8 Alternative CR10X ProgramSend the Ascii characters ‘Y’ and ‘Z’ to port Use formatter string 100 to set up the CRC16 on portMinimum delay of 1ms is required after this command Minimum delay of 3.8ms is required after this commandCRC16-CCITT-IBM Data Error Detection Page Dec Char Appendix A. Ascii TablePage Data Length Appendix B. Serial Port Data Transfer ModesBaud rates Stop BitsSerial Handshake Modes Parity Bits