Summary of Contents for Campbell Serial I/O Interface SDM-SIO4
Page 1
SDM-SIO4 4-Channel Serial I/O Interface User Guide Issued 17.3.97 Copyright 1997 Campbell Scientific Ltd.
Page 3
Guarantee This equipment is guaranteed against defects in materials, workmanship, and software. This guarantee applies for twelve months from date of delivery. We will repair or replace products which prove to be defective during the guarantee period provided they are returned to us prepaid. The guarantee will not apply to: Equipment which has been modified or altered in any way without the written permission of Campbell Scientific...
Section 1. Introduction The SDM-SIO4 has four configurable serial RS232 ports which allow it to be connected to intelligent serial sensors, display boards, printers or satellite links. It can also be used in many other applications where the data is transferred in a serial fashion. This device is designed to send data to and receive data from the sensors, and process it in parallel with the datalogger’s own program sequence, thus making the complete datalogging system faster and more efficient.
Page 8
SDM-SIO4 4-Channel Serial I/O Interface User Guide PORT Handshake Line ½ ¾ ¿ Handshake Tx Buffer Control ¿ ¿ CRC/SIG Driver ¿ ¿ Format Driver & User Strings To Other Ports K K K ¾ Control Lines Data Lines Figure 1 Schematic Diagram of the SDM-SIO4 ¾...
1.2 Specifications 1.2.1 Serial Ports The SDM-SIO4 has four serial ports which can be configured independently to use different serial data formats and baud rates (from 25 to 115,200 baud). These ports are 0-5V logic or ±5V for RS232 and are configured similar to a PC ‘AT’...
SDM-SIO4 4-Channel Serial I/O Interface User Guide 1.2.2 SDM Port This serial port is to connect to the SDM port of the datalogger, e.g. via C1, C2 and C3 on a CR10X. The port is a set of screw terminals marked C1, C2, C3, I/O, +12 and G.
Section 1 . Introduction 1.2.6 Other Key Features An internal lithium battery which retains configuration information (estimated life 10 years) A built-in system watchdog which will reset the processor in the event of a crash caused by transients, etc. A multi-tasking operating system allowing concurrent transmission and receipt of data on all ports.
Section 2. Installation and Hardware Set-Up The SDM SIO4 is designed to be mounted on an enclosure chassis plate using the two mounting holes in the tabs on the side of the case Before installation, it is necessary to set up the address of the SDM-SIO4 and also the mode of operation of each serial port.
SDM-SIO4 User Guide 2.2 Selecting RS232 or 5V Logic for Each Port The output voltage levels of each serial port can be set to either: The logic level output is used when driving a logic level compatible device, e.g. an SC32A, or where quiescent current is a concern. This mode is lower power because the idle state is 0V, while the idle state of the RS232 output is -5V which results in current flow to ground via the input resistance of the RS232 device’s inputs.
If it is not possible to prevent a ground loop, or if electrical noise is found to be a problem, it may be necessary to add an opto-isolated interface to the output of the SDM-SIO4 serial port. Please contact Campbell Scientific for further details. Even if ground loops can be prevented, the length of cables that can be used for RS232 signals is limited to a few tens of metres (the exact length depending on the RS232 driver hardware and the cable used).
Section 3. Understanding How the SDM-SIO4 Handles Data For simple applications the SDM-SIO4 can be configured and controlled from the datalogger alone, using the datalogger program instruction P113 (CR10X and CR7 dataloggers only). Future developments will include support for other dataloggers. More complicated applications require configuration of the SDM-SIO4 using the ‘command line’...
SDM-SIO4 User Guide The hex. number must always be two ASCII characters. NOTE Control characters can be entered for all commands in a similar way: 3.2 Input Filters Input filters are used to convert received data into a form that is easy for the datalogger to process.
Page 19
See Section 5 – ‘Programming the Datalogger’. Filter Strings These are used to define how to filter incoming data from a port into a format the datalogger can use. This is done by having a user-defined filter string pre-stored in the battery-backed memory of the SDM-SIO4.
Page 20
SDM-SIO4 User Guide As an example, take the following sensor output string: battery 12.65V,current 12mA The filter string might be: i[b]n8Fi[c]n8F Output to the datalogger would be 12.65 and 12 as Campbell Scientific floating point numbers. This filter string works as follows: 1.
2. n8 discards everything up to 12.65V. 3. F converts the number to Campbell Scientific floating point. If a valid number 4. i[c] waits for the trigger character ‘c’ of ‘current’. 5. n8 discards everything up to 12mA. 6. F converts the number to Campbell Scientific floating point. If a number is not This filter will repeat the above operations on all incoming values.
SDM-SIO4 User Guide See Section 5 – ‘Programming the Datalogger’. 3.3.2 Output Format Strings These allow either just long strings to be sent from the SDM-SIO4 or a combination of string data plus data from a datalogger input location. This type of format is normally set up from the ‘command line’.
Page 23
String number If the datalogger sends more data than is defined in the SDM-SIO4’s formatter string, the SDM-SIO4 starts at the beginning again unless ‘s’ (stop formatting) is used, in which case any extra data within that transmission is ignored. CR10X Program Example This program example will output the battery voltage and panel temperature received from the datalogger input locations to port 2 on the SDM-SIO4, using the...
Page 24
SDM-SIO4 User Guide z273 – This outputs the fixed string ‘CrLf (carriage return line feed)’. *Table 1 Program ;get battery voltage. 1: 2 ;get panel temperature. 1: 1 ;send battery voltage and temperature to port 2 on the SDM-SIO4. 1: 1 2: 0 3: 2 4: 2304...
Section 4. Programming the SDM-SIO4 This section gives both the basic commands and advanced command line options which allow testing and advanced configuration of the SDM-SIO4. 4.1 Command Line Operation and Structure NOTE 4.2 Entering Commands NOTE To use the command line mode, connect a computer to port 1 of the SDM-SIO4. The computer should run a terminal emulation program (e.g.
SDM-SIO4 User Guide Control characters can be entered for all commands in a similar way: 4.3 Basic Commands fltst [string number] ["filter definition"] This command stores a filter definition to a string number 0..255. Example: fltst 22 "ccci[x]Fs" The above example stores the filter definition in filter string 22. See Section 3 for filter types.
because they are compiled. exit This command exits the command line and returns port 1 of the SDM-SIO4 to normal operation. 4.4 Advanced Commands version This returns the internal EPROM part number, signature and the string signature if good or 0 if bad. This will give the same signature as Campbell Scientific’s SIG.COM PC program.
Page 28
SDM-SIO4 User Guide WD n WDERR n WDADDR n WD n is a count of the number of watchdog resets, WDERR is the number of the last task that crashed and WDADDR is the address at which the crash was found. NC 0-9 This is the number of SDM commands the datalogger sent to the SDM-SIO4 that the SDM-SIO4 did not recognise.
Page 29
testio [test#] This is used by Campbell Scientific for test purposes. Each test command is carried out for 2 seconds. Test# can be in the range 0-255; only five test numbers are currently valid, as shown below. testio returns test 0 DTR,RTS,IO=LOW test1 DTR=HIGH,RTS,IO=LOW...
Section 5. Programming the Datalogger The datalogger instruction specific to the SDM-SIO4 is P113 (CR7 and CR10/10X only). (Please check with Campbell Scientific to see if your version of the operating system supports this.) The instruction has the following format: Parameter No.
SDM-SIO4 User Guide 5.1.5 Parameter 7 — Values per Rep This determines how many values to send or receive, starting from the specified input location (parameter 8). Data can be either 4-byte floating point values or single bytes, determined by the SDM-SIO4 command number. Some commands require no input or output of values;...
5.2.1 Understanding Parameter Options and Returned Values In the following examples, ‘x’ indicates a single digit from 0 to 9. NOTE When the command requires or returns values, each digit, or combination of digits, can signify either a value, flag or setting. Using Command 5 as an example: Number of watch dog resets | | Number of invalid commands executed...
SDM-SIO4 User Guide 5.2.3 Command 2: Signatures This command gets the SDM-SIO4 EPROM signature and the string memory area signature; the two values are written into consecutive input locations. If the signatures are zero then there could be corrupt data. Values per repetition = 2 5.2.4 Command 3: Flush all Receive Buffers Stored data in the SDM-SIO4 relevant to the port is also erased with this...
If any of these four digits is greater than zero then data is available. Values per repetition = 2 5.2.7 Command 6: Flush Transmit Buffer This command flushes the SDM-SIO4 transmit buffer of data it is waiting to send. Values per repetition = 0 5.2.8 Command 7: Activate Command Line This command simulates pressing the push button on the SDM-SIO4 which activates the command line mode on the port determined by the mode.
SDM-SIO4 User Guide 5.2.12 Command 67: Get Return Code This command gets the return error code and places it into a specified location. Command 67 is used in conjunction with command 321 and provides a single return code value which indicates if the command was successful or not. See Section 5.6 for the return codes.
Page 37
Bulk load 1:102 f 2:108 l 3:116 t 4:115 s 5:116 t 6:32 ascii space 7:50 8:53 First location to store the first lot of 8 characters. Bulk load 1:32 ascii space 2:34 “ 3:102 f 4:102 f 5:67 6:99 7:34 “...
SDM-SIO4 User Guide ;set flag one so that set-up will only be done once. ;end of set-up. If you use the RAMTEST command you will have to wait a NOTE minimum of 6 seconds for it to complete before you try to execute another P113.
Page 39
Second Value Returned CTS status (0=CTS low, 1=CTS high) | DSR status (0=DSR low, 1=DSR high) | | RI status (see below) | | | DCD status (0=DCD low, 1=DCD high) | | | | x x x x For the RI (Ring Indicator): 0 = no trailing edge seen since last read 1 = trailing edge seen since last read Third Value Returned...
SDM-SIO4 User Guide Break reset: Framing reset: Overrun reset: Parity reset: 5.2.18 Command 1027: ‘Manual’ Handshake Mode In this mode, the datalogger can set DTR, RTS and XON/XOFF as required. Not used - set to zero. | XON/XOFF | | RTS | | | DTR | | | | x x x x...
Page 41
First Command Option (Parameter 5) Handshake mode | Stop bits + parity | | Data length | | | Baud rate | | | | x x x x Handshake Mode: Stop Bits and Parity: Data Length: Baud Rate: Second Command Option (Parameter 6) This option is used to set the handshaking delay in units of 50ms.
SDM-SIO4 User Guide 5.2.20 Command 2054: Set Up Receive Filter This command clears all buffers relevant to the mode number and restarts the filter. Values per repetition = 0 With the string filter type the SDM-SIO4 buffers are not cleared. NOTE First Command Option (Parameter 5) Input mode...
Page 43
Output Mode: 0 No output format string 1 Convert location to ASCII floating point. Add character/delimiter between 2 Convert location to ASCII hex pair. Add character/delimiter between values if 3 Convert location to 8-bit binary. Add character/delimiter between values if 4 Convert location to 16-bit binary.
SDM-SIO4 User Guide 5.2.22 Command 2305: Transmit Byte(s) By using P113 command 2305 it is possible to transmit either one or two bytes from the command options. If any command option is set to 999 then the byte will not be sent. The number range for each command option is 0-255 and 999. An example of its use is below: 1:SDM-SIO4 (P113) 4:2305...
Page 45
;set serial mode to DTR, RTS always set, ignore CTS, 1 stop bit no parity, ;8 bit data length, 9600 baud and no handshake delay. SDM-SIO4 (P113) 1: 1 Reps 2: 0 Address 3: 1 Send/Receive Port 1 4: 2049 Command 5: 3146 1st Parameters...
SDM-SIO4 User Guide *Table 2 Program *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.
Page 47
^J^M – this is a way of entering control characters for carriage return/linefeed into a string The following program example works as follows: 1. The first P113 sets up a simple filter to search for floating point numbers. 2. The first parameter of this command is used to transmit a string which will prompt the sensor into taking measurements and then transmitting the numbers to the SDM-SIO4.
SDM-SIO4 User Guide ;get data from SDM-SIO4 and put into locations 1 and 2. 1: 1 2: 0 3: 1 4: 4 5: 0 6: 0 7: 2 8: 1 9: 1.0 10: 0.0 ;At zero minutes into a 10 minute interval set the output ;so that the data from the sensor will be stored into ;final storage.
Page 49
Example CR10X Program without Polling or Interrupts This simple program is an example for sensors that send data at random intervals. If no data was available when the datalogger asked for it then -99999 will be put into locations 1 and 2. An IF THEN structure could be used in the datalogger program to store only values that are not -99999.
Page 50
SDM-SIO4 User Guide ;end of set up. ;get the two floating point values from the SDM-SIO4. 1: 1 2: 0 3: 1 4: 4 5: 0 6: 0 7: 2 8: 1 9: 1.0 10: 0.0 ;Only set the output flag when the voltage is ;greater than or equal to -99998.
Page 51
x – this filter marks the start of the data set. In this case the data set is two floating point numbers. f – this filter searches for the first ASCII floating point number to convert. f – this filter searches for the second ASCII floating point number to convert. *Table 1 Program 01: 2 Execution Interval (seconds)
Page 52
SDM-SIO4 User Guide ;if value returned from poll is >=1 then data must be available. 1: 2 2: 3 3: 1 4: 30 ;get voltages into locations 3 and 4 if poll was true. 1: 1 2: 0 3: 1 4: 4 5: 0 6: 0...
Page 53
– see ‘SDM Port’ in Section 1 for details. This should be connected to control port 8 for this example. A typical filter that could be used is as follows: fltst 200 "t[data]A5xff" This filter works as follows: t[data] – this filter waits for an exact string match before it starts the next filter. In this case it is waiting for the sensor to send the string ‘data’.
Page 54
SDM-SIO4 User Guide ;end of IF *Table 2 Program *Table 3 Subroutines ;interrupt routine for control port 8 1: 98 ;get voltages into locations 3 and 4 1: 1 2: 0 3: 1 4: 4 5: 0 6: 0 7: 2 8: 3 9: 1.0 10: 0.0...
5.4 Outputting Datalogger Data The SDM-SIO4 can be used to drive displays, printout devices and other output- only systems. In this case after the initial configuration (as above) either simple data can be sent using commands 0320, 1025 or just data strings using 1024 or strings plus formatted data sent using command 2304.
SDM-SIO4 User Guide *Table 2 Program *Table 3 Subroutines End Program 5.5 Flushing the Input and Output Buffers One important aspect of the SDM-SIO4 is that it will continue to collect data and store it in its buffers even if the datalogger program stops running. Care must be taken to ensure that data does not build up in the buffers and as a result either a buffer overflows, or data is collected which relates to a different time than anticipated.
Section 6. Data Error Detection Error detection by checksum, CRC or signatures is a way of detecting errors in data, either transmitted or received. This section gives details on how to use filter strings together with datalogger program examples to implement error detection methods. 6.1 Error Detection with the SDM-SIO4 6.2 Received Data NOTE...
Page 58
SDM-SIO4 User Guide 8-255 This filter type can be added to the filter string to mark the end of the string and the point where the sensor signature should be. It also sets the data type to use. When this filter is done, the signature returned from the sensor will be converted into a standard data type, so the SDM-SIO4 can compare the original signature it calculated to the one the sensor returned.
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”...
Page 60
SDM-SIO4 User Guide *Table 1 Program ;test flag 1 – if not set tell the SDM-SIO4 to use filter string 100 1: 21 2: 30 ;tell the SDM-SIO4 to use filter string 100 1: 1 2: 0 3: 1 4: 2054 5: 9100 6: 0 7: 0...
Page 61
;if the value in location 1 is greater than zero then there must be data ;this assumes only one sensor is connected to the SDM-SIO4 IF (X<=>F) (P89) 1: 1 X Loc [ _________ ] 2: 3 >= 3: 1 4: 30 Then Do ;if data is available then get the value and put into location 2...
SDM-SIO4 User Guide The time for the different data types is shown below. Note that this is the time needed to convert the received signature into a known format and is done at the end of the signature calculation before the compare. The ASCII decimal conversion timing is for a number with ten or more digits.
CSI Signature (CR10X user manual section C-4). Check sum using modulo 256. Check sum using modulo 8192 (CR10X user manual section 5-2). 8-255 reserved for future use. This formatter type can be put into the formatter string to mark the end of the string and the point at which the signature should be transmitted.
SDM-SIO4 User Guide 6.3.2 CR10X Program Example A typical CR10X datalogger program to work with the above formatter is shown below. The program assumes that 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.
Page 65
*Table 1 Program 01: 1.0 Execution Interval (seconds) ;use formatter string 100 to set up the CRC16 on port 1 SDM-SIO4 (P113) 1: 1 Reps 2: 0 Address 3: 1 Send/Receive Port 1 4: 2304 Command 5: 9100 1st Parameters 6: 0 2nd Parameters 7: 0...
Page 66
SDM-SIO4 User Guide ;use formatter string 102 and output datalogger location 1 as ASCII floating point ;to port 1 and then output the calculated ASCII hex CRC16 1: 1 2: 0 3: 1 4: 2304 5: 9102 6: 0 7: 1 8: 0000 9: 1 10: 0...
Page 67
8 bit binary 0.155ms 16 bit binary 0.216ms 32 bit binary 0.334ms ASCII decimal 1.125ms 8 bit ASCII hex 0.226ms 16 bit ASCII hex 0.355ms 32 bit ASCII hex 0.613ms The above timings are preliminary. With the CRC32 and CRC16-CCITT there is a extra 0.19ms for an additional calculation.
Appendix A. ASCII Table American Standard Code for Information Interchange Dec. Char. CONTROL @ CONTROL A CONTROL B CONTROL C CONTROL D CONTROL E CONTROL F CONTROL G CONTROL H CONTROL I CONTROL J CONTROL K CONTROL L CONTROL M CONTROL N CONTROL O CONTROL P...
Appendix B. Serial Port Data Transfer Modes This appendix describes the serial port set-up in some detail. Please note that the numerical option codes vary between the command line set-up and the datalogger command set-up. The ones listed below are those for the command line mode. B.1 Baud rates NOTE B.2 Stop Bits...
SDM-SIO4 4-Channel Serial I/O Interface B.4 Parity Bits Parity can be enabled and set to either odd or even. B.5 Serial Handshake Modes You can select different kinds of handshaking from none at all, hardware (DTR, CTS etc.) and XON/XOFF. On modes 0 and 1 there is a user-set delay (0..254 x 50ms) between CTS being set and data being sent;...
Need help?
Do you have a question about the Serial I/O Interface SDM-SIO4 and is the answer not in the manual?
Questions and answers