Campbell Hausfeld SDM-SIO4 manual Example CR10X Program Using Instruction P113 Command

Page 46

SDM-SIO4 User Guide

*Table 2 Program

02: 0.0000 Execution Interval (seconds)

*Table 3 Subroutines

End Program

The normal configuration would include setting the speed and serial data format by calling the datalogger instruction with command 2049 and the relevant parameters.

For the majority of sensor applications where data is returned in only one type of format to the SDM-SIO4, the receive data format filters can also be defined once only by using command 2054. Similarly, some sensors may also require set-up strings to be sent once; these actions can also be placed in the same configuration block.

There are two general methods of obtaining data from an intelligent RS232 device, depending on the sensor type, as indicated below:

5.3.1Sensors Where the Datalogger Can Request Data by Sending a Prompt or Using a Handshaking Line

For these sensors the measurement would consist of three phases:

1.For software-controlled sensors, use the datalogger instruction to send out a command string (to request data), using commands 0320, 1024, 1025 or 2304. (Command 2304 also allows you to set up the receive filter to match the expected data; this instruction is useful when several different types of data are being requested from the sensor, i.e. a one-off set-up of the receive filter with command 2054, is not appropriate.) For hardware-controlled sensors, use command 1027 to change the state of the handshaking lines.

2.The datalogger waits for a period long enough for the SDM-SIO4 to process the set-up data (minimum delay), plus time for the data to be transmitted out of the serial port, plus the time for the sensor to respond and the data string to be transmitted back to the SDM-SIO4. The delay can either be instigated by using Instruction 22, or a delay loop, or more efficiently by running some of the other measurement tasks required of the datalogger. After the minimum delay, these tasks could also include further communications with the SDM-SIO4 to deal with one of the other sensors connected to another port.

3.Finally the SDM-SIO4 instruction is used to read the collected data back from the SDM-SIO4. Commands 4 or 66 are used for this function.

Example CR10X Program Using Instruction P113 Command 4

This program is written so that, on every execution interval, the datalogger will send a string out of port 1 to command the sensor to transmit its measurements back to the SDM-SIO4, which has a filter set up ready to receive the data.

The output formatter is set up to transmit a string as follows:

strst 101 "Send Data^J^M"

Here is how the above string works:

strst 101 – this is the command to store a sting in area 101.

Send Data – this is the command string the sensor will execute.

5-16

Image 46
Contents Issued Page Guarantee Page Contents Data Error Detection Appendix A. Ascii TableWhat is the SDM-SIO4? IntroductionDatalogger Command Control Serial Ports SpecificationsSDM-SIO4 Serial Port Pin Configuration Serial Port BuffersCase Power RequirementsSDM Port Environmental Operating RangeOther Key Features Page Address Settings Installation and Hardware Set-UpSetting the SDM Address Selector Block Settings SDM AddressConnections to the SDM-SIO4 Selecting RS232 or 5V Logic for Each PortTransient Protection and Grounding Status LED Error Codes Power-on Tests the Status LEDNo. of Flashes Description of error/status Page Introduction Understanding How the SDM-SIO4 Handles DataMethod of Entering Special / Control Characters Filter Types Input FiltersSimple Filters Filter Strings Ibn8Ficn8F Predefined Filter Strings Output FormattingSimple Output Formatter Filter No Filter String UsedOutput Format Strings Fmtst 123 z261 f62 iBattery z257 f61z273 CR10X Program ExampleGet battery voltage Get panel temperatureEntering Commands Command Line Operation and StructureProgramming the SDM-SIO4 Basic Commands Advanced Commands Bytewr address byte ErrorresHexdump start address number of bytes WD n Wderr n Wdaddr nTestio test# Testio returnsPage Programming the Datalogger Instruction 113 ParametersParameter 8 Starting Input Location Commands and Options Parameters 4, 5Parameter 7 Values per Rep Parameters 9 and 10 Multiplier and OffsetCommand 1 Poll of Available Data Understanding Parameter Options and Returned ValuesCommand 4 Send Data to Datalogger Command 2 SignaturesCommand 3 Flush all Receive Buffers Command 5 StatusCommand 8 Poll Tx Buffers for Data Command 6 Flush Transmit BufferCommand 7 Activate Command Line Command 9 Flush Converted Data BufferCommand 321 Execute Command Line Command Command 67 Get Return CodeCommand 320 Send Byte Data to SDM-SIO4 Program Example for P113 CommandExecute the command line string Command 1026 Serial Port Status Command 1024 Send String to DeviceCommand 1025 Transmit a Byte First Value ReturnedThird Value Returned First Command Option Reset Error CountersSecond Value Returned Fourth Value ReturnedCommand 1027 ‘Manual’ Handshake Mode Command 2049 Set Communications ParametersFirst Command Option Parameter Second Command Option ParameterCommand 2054 Set Up Receive Filter String Number or Character Code Command 2305 Transmit Bytes SDM-SIO4 Configuration ExamplesExample CR10X Program Set flag one high so the above will only be done once End of serial and filter setupGet two floating point numbers into locations 1 Example CR10X Program Using Instruction P113 Command Strst 101 Send DataJMSet up the filter and then send string Wait long enough for sensor to send dataTime stamp Sensors Which Send Data Out Without PromptingGet data from SDM-SIO4 and put into locations 1 Instantaneous sample form the sensorExample CR10X Program without Polling or Interrupts Fltst 200 tdataA5xffGet the two floating point values from the SDM-SIO4 Example CR10X Program using the Polling MethodEnd of set up Instantaneous values stored to final storageDo filter set-up only if flag one is clear Set up string filterDelay required by filter set-up command Set flag one high so the filter set-up is only done onceGet voltages into locations 3 and 4 if poll was true Example CR10X Program using InterruptsInstantaneous value stored into final storage Delay required by filter setup command Do filter setup only if flag one is clearSet control port 8 to i/p so it can be used as an interrupt Instantaneous readings stored into final storage Interrupt routine for control portGet voltages into locations 3 End of interrupt routineOutputting Datalogger Data Return Error Codes Flushing the Input and Output BuffersError Detection with the SDM-SIO4 Data Error DetectionReceived Data SDM-SIO4 User Guide 2 CR10X Program Example Example of Using Received Data FiltersFltst 100 TFrequency=xg2n10fCCG8 End of filter setup Minimum delay of 4ms is required by the above P113Tell the SDM-SIO4 to use filter string End of get data Transmitted Data CRC32Example of Using Transmitted Data Filters Fmtst 100 g1i123456789G8Alternative CR10X Program Fmtst 100 g1 Fmtst 101 isome data Fmtst 102 f62 G8Minimum delay of 3.8ms is required after this command Use formatter string 100 to set up the CRC16 on portMinimum delay of 1ms is required after this command Send the Ascii characters ‘Y’ and ‘Z’ to portCRC16-CCITT-IBM Data Error Detection Page Appendix A. Ascii Table Dec CharPage Stop Bits Appendix B. Serial Port Data Transfer ModesBaud rates Data LengthParity Bits Serial Handshake Modes