background image

Section 4.  Programming the SDM-SIO4

4-3

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.

portset 

[port#] [baud#] [data length] [stop bits] [parity] [handshake mode]

[delay]

This sets up the port 1..4 to the communication format you require.

‘port #’ means the port number (1..4) to set up. For details of the other parameters
(baud #...delay) see Appendix B.

reset

The SDM-SIO4 is set to a known default state. All strings, filters and formatters
are erased, ports are set to 9600 baud, 1 stop bit, no parity and no handshake. All
transmit and receive buffers are flushed. All error counts are zeroed.

ramtest

The system RAM is tested and the SDM-SIO4 is then reset. The string ‘

Ram test

pass

’ is returned if the RAM is OK or ‘

Ram test fail

’ if some part of the

memory failed.

changeport [port #]

This command changes the port for which the command line is available. This
command line port setting will stay in effect for further sessions until a new port is
chosen or power is removed and then re-applied, in which case the command line
reverts to port 1.

status

This outputs the general status of the SDM-SIO4. The results are as follows:

BATT 0 or 1

If the value is 0 the battery needs replacing.

If the value is 1 the battery is good.

ADDR 0 to 15

This is the current SDM-SIO4 hardware address.

Summary of Contents for SDM-SIO4

Page 1: ...SDM SIO4 4 Channel Serial I O Interface User Guide Issued 17 3 97 Copyright 1997 Campbell Scientific Ltd...

Page 2: ......

Page 3: ...in lieu of all other guarantees expressed or implied including those of suitability and fitness for a particular purpose Campbell Scientific is not liable for consequential damage Please inform us bef...

Page 4: ......

Page 5: ...2 3 3 Output Formatting 3 5 3 3 1 Simple Output Formatter 3 5 3 3 2 String Output Formats 3 6 Section 4 Programming the SDM SIO4 4 1 4 1 Command Line Operation and Structure 4 1 4 2 Entering Commands...

Page 6: ...nfiguration Examples 5 14 5 3 1 Sensors Where the Datalogger Can Request Data by Sending a Prompt or Using a Handshaking Line 5 16 5 3 2 Sensors Which Send Data Out Without Prompting 5 18 5 4 Outputti...

Page 7: ...ard textbooks on this subject 1 1 What is the SDM SIO4 The SDM SIO4 is a device that is connected to a datalogger through the datalogger SDM port The SDM port is specific to Campbell Scientific datalo...

Page 8: ...er Command Line Control Datalogger Command Control CRC SIG Driver Format Driver User Strings CRC SIG Driver Filter Driver Converted Data Buffer 1 0 0 K K K Handshake Line Command Line Switch Status LE...

Page 9: ...act Campbell Scientific for further details Serial Port Buffers Each serial port has a receive Rx buffer a transmit Tx buffer and a processed data storage buffer It is important to understand these bu...

Page 10: ...typical transfer speed to and from the SDM is one byte per millisecond Multiple SDM SIO4s can be connected to the datalogger in parallel with other SDM SIO4s or other SDM devices The only difference w...

Page 11: ...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 This allows...

Page 12: ......

Page 13: ...the 12V supply and take static prevention precautions before removing the lid 2 1 Setting the SDM Address The 4 x 2 way block of jumpers close to the D connectors selects the SDM address of the SDM SI...

Page 14: ...r SDM terminals as described under SDM Port in Section 1 Use a short low capacitance screened cable The 12V supply can normally be taken from the 12V supply input to the datalogger Make up cables for...

Page 15: ...ew tens of metres the exact length depending on the RS232 driver hardware and the cable used Short haul modems can be added to the SDM SIO4 to allow cables up to several kilometres to be used and in a...

Page 16: ......

Page 17: ...sing 3 1 Introduction For collection of data from an intelligent sensor the datalogger programming is typically broken down into several steps which might be 1 Set up and configure the serial ports e...

Page 18: ...floating point number which the datalogger can use The datalogger will then collect this value and place it into an input location in this case as 171 decimal You must always set up a filter if you w...

Page 19: ...er of bits from 0 to 255 but more than 23 bits is beyond the floating point range of the datalogger so the value returned to the datalogger will be invalid There can be any number of bit fields only l...

Page 20: ...pbell Scientific floating point format until the termination character string between is seen n can be 1 3 The termination character string is removed from the buffer wn Convert n byte binary data int...

Page 21: ...It would be impractical for the datalogger to store text labels in this way and so you could use the SDM SIO4 to send a label to the display along with the data from the datalogger The final result m...

Page 22: ...n is the number of decimal places to use within the field width If the integer part of the n number is bigger than the field width the SDM SIO4 still sends it even though it is longer than the set fi...

Page 23: ...2 on the SDM SIO4 using the SDM SIO4 Output Formatter The user defined format string which is entered in the command line mode see Section 4 is as follows fmtst 123 z261 f6 2 i Battery z257 f6 1z273 T...

Page 24: ...al Temperature P17 1 1 Loc Temp_C send battery voltage and temperature to port 2 on the SDM SIO4 3 SDM SIO4 P113 1 1 Reps 2 0 Address 3 2 Send Receive Port 2 4 2304 Command see Section 5 for explanati...

Page 25: ...talogger is running a program which communicates with the SDM SIO4 However all datalogger activity related to port 1 is ignored Complicated or long string definitions are best set up by editing a text...

Page 26: ...The above example stores the string definition This is a string crlf in string 22 This string will include the two quotation marks as shown fmtst string number format definition This command will stor...

Page 27: ...strings filters and formatters are erased ports are set to 9600 baud 1 stop bit no parity and no handshake All transmit and receive buffers are flushed All error counts are zeroed ramtest The system R...

Page 28: ...ming error count Overrun error count Line break error count DTR handshake line status 0 low 1 high RTS handshake line status 0 low 1 high CTS handshake line status 0 low 1 high DSR handshake line stat...

Page 29: ...st 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...

Page 30: ......

Page 31: ...ter 1 Reps This specifies the number of times you wish this command to repeat for each SDM SIO4 connected to the datalogger with sequential addresses This will normally be set to one 5 1 2 Parameter 2...

Page 32: ...he command options listed below it is necessary to leave a small delay before calling another instance of the instruction which communicates with the SDM SIO4 This is required to allow the SDM SIO4 to...

Page 33: ...econd value returned shows whether or not data is available from a specific port A non zero digit indicates that data is available whereas a zero signifies that no data is available Command 5 is expla...

Page 34: ...5 2 6 Command 5 Status This command returns the SDM SIO4 general status lithium battery level errors and data available flags The data is supplied as two floating point values First value Number of wa...

Page 35: ...buffers to see if they have data This command has no additional options after the command The SDM SIO4 returns one Campbell Scientific floating point number to indicate if it has data as below Port 4...

Page 36: ...guring a remote SDM SIO4 as changes can be made by downloading programs using the 321 command which can change the SDM SIO4 setup The datalogger can send other commands to the SDM SIO4 while the comma...

Page 37: ...ute command line command 5 0 6 0 7 15 Length of command line string no of datalogger input locations 8 1 9 1 10 0 delay large enough 10ms to allow SDM SIO4 instruction 321 to finish P22 1 1 2 0 3 1 4...

Page 38: ...RS232 device If the specified string has not been allocated then string not allocated is transmitted Values per repetition 0 Minimum delay characters 0 26 ports in milliseconds 5 2 16 Command 1025 Tra...

Page 39: ...s have been lost due to data being sent too quickly for the SDM SIO4 to process the data Fourth Value Returned NOT USED SET TO ZERO Line break errors x x x x Line break errors is a count from 0 99 Thi...

Page 40: ...x x x x XON XOFF 0 Leave as set previously 1 XOFF data stop data transmission from SDM SIO4 2 XON data restart data transmission from SDM SIO4 RTS 0 Leave as set previously 1 Clear RTS to low 2 Set R...

Page 41: ...arity 5 1 5 2 stop bits even parity 6 1 5 2 stop bits odd parity Data Length 0 Leave as set previously 1 5 data bits 2 6 data bits 3 7 data bits 4 8 data bits Baud Rate 0 Leave as set previously 1 300...

Page 42: ...nation character if set 8 Transmit a user defined string 0 255 or fixed string 256 511 9 String filter type See Filter Strings in Section 2 3 String Number or Character Code If input mode 9 is chosen...

Page 43: ...ter character as an ASCII code 0 255 999 means character not enabled Second Command Option Parameter 6 This is used for filter set up if data is expected back after output Input mode String number or...

Page 44: ...line many users may prefer to set up the ports from their program This would normally be done once when the program is first compiled The instruction can be placed within a logical block which only r...

Page 45: ...mmand 5 1999 1st Parameters 6 0 2nd Parameters 7 0 Values per Rep 8 0000 Loc _________ 9 1 0 Mult 10 0 0 Offset the set up filter command requires a delay of 4ms the nearest we can get is 10ms with P2...

Page 46: ...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 per...

Page 47: ...nd so 11 characters could take 12ms for the sensor command and another 20 characters 21ms for output data from the sensor The total time before the datalogger can get the data would therefore be 2 86...

Page 48: ...ps 2 1 Loc number Table 2 Program 02 0 0000 Execution Interval seconds Table 3 Subroutines End Program 5 3 2 Sensors Which Send Data Out Without Prompting It can be very difficult to acquire data from...

Page 49: ...be long enough for the sensor to transmit all of its data 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 AS...

Page 50: ...inal storage 9 Sample P70 1 2 Reps 2 1 Loc Voltage Table 2 Program 02 0 0000 Execution Interval seconds Table 3 Subroutines End Program Example CR10X Program using the Polling Method This program will...

Page 51: ...er 2 SDM SIO4 P113 1 1 Reps 2 0 Address 3 1 Send Receive Port 1 4 2054 Command 5 9200 1st Parameters 6 0 2nd Parameters 7 0 Values per Rep 8 0 Loc _________ 9 1 0 Mult 10 0 0 Offset delay required by...

Page 52: ...e P70 1 2 Reps 2 3 Loc voltage1 end of IF 12 End P95 Table 2 Program 02 0 0000 Execution Interval seconds Table 3 Subroutines End Program Example CR10X Program using Interrupts Sensors with fast data...

Page 53: ...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 set control port 8 to i p so...

Page 54: ...ers 7 2 Values per Rep 8 3 Loc voltage1 9 1 0 Mult 10 0 0 Offset set the output flag so that readings can be stored into final storage 3 Do P86 1 10 Set Output Flag High Flag 0 time stamp 4 Real Time...

Page 55: ...nd word for storing the formatter sting in area 123 z261 This outputs the fixed string Temperature space This outputs an ASCII space f6 2 This takes the value from location 1 and outputs it The output...

Page 56: ...ers used specifically flush the input buffer it is advisable to include instructions to flush the buffers within the configuration section of the program 5 6 Return Error Codes These return error code...

Page 57: ...cksums CRCs or Signatures are then compared and if the two match exactly then the data received should be error free 6 2 Received Data No checksum will detect 100 of all errors The more sophisticated...

Page 58: ...be set up to do one of the following 1 Poll the SDM SIO4 to see if data is available 2 Read the corrupt values as 99999 or 255 into locations and just store them as normal 3 Read the values check to s...

Page 59: ...ord 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 wi...

Page 60: ...t 10 0 Offset a minimum delay of 4ms is required by the above P113 3 Excitation with Delay P22 1 1 Ex Channel 2 0 Delay W Ex units 0 01 sec 3 1 Delay After Ex units 0 01 sec 4 0 mV Excitation set flag...

Page 61: ...ng the SDM SIO4 to see if any data is waiting If you decided not to poll the SDM SIO4 then you would get 99999 in the locations if data was not available to collect When the Checksum CRC or Signature...

Page 62: ...wing The extra time in milliseconds you must wait before trying to get the data from the SDM SIO4 a one from b one from c d if applicable 6 3 Transmitted Data The SDM SIO4 can also do transmission sig...

Page 63: ...fail 10 255 reserved for future use 6 3 1 Example of Using Transmitted Data Filters A sensor requires the string 123456789 but also requires a CRC16 appended to the end in 16 bit ASCII Hex which in th...

Page 64: ...es per Rep 8 0000 Loc _________ 9 1 Mult 10 0 Offset Table 2 Program 02 0 0000 Execution Interval seconds Table 3 Subroutines End Program The program shown above will output to port 1 the string 12345...

Page 65: ...01 sec 4 0 mV Excitation use formatter string 101 to transmit the string get data to port 1 3 SDM SIO4 P113 1 1 Reps 2 0 Address 3 1 Send Receive Port 1 4 2304 Command 5 9101 1st Parameters 6 0 2nd Pa...

Page 66: ...sed The timings for the algorithms are shown below These timings are in addition to the normal formatter delay times a Time to set up an algorithm using formatter g is No of Ports 0 0656ms b The time...

Page 67: ...ms The above timings are preliminary d With the CRC32 and CRC16 CCITT there is a extra 0 19ms for an additional calculation This is required as part of the CRC algorithm The total extra processing tim...

Page 68: ......

Page 69: ...I 105 i 10 CONTROL J 42 74 J 106 j 11 CONTROL K 43 75 K 107 k 12 CONTROL L 44 76 L 108 l 13 CONTROL M 45 77 M 109 m 14 CONTROL N 46 78 N 110 n 15 CONTROL O 47 79 O 111 o 16 CONTROL P 48 0 80 P 112 p...

Page 70: ......

Page 71: ...400 baud 11 4800 baud 12 9600 baud 13 19200 baud 14 38400 baud 15 76800 baud If the baud rate is higher than 9600 on two or more ports the SDM SIO4 may not be able to reliably collect data when there...

Page 72: ...transmission stops if CTS falls 3 DTR and RTS are always set ignore CTS 4 XON XOFF software handshake The SDM SIO4 will XON again if no more XOFFs are sent after a time out of n x 50ms This mode is on...

Reviews: