background image

CRBasic Example 2: Detecting the state of the input line

'CR1000 example program showing how to detect the state of the input line on an
'SDM-SIO1A using the SDMGeneric instruction

Public

sio1response As Long, Inputstate As Boolean

Const

addr = 0  

'constant sdm address CHANGE with SDM-SIO1A address

Const

cmd = 1  

'constant, command 1 returns the input state in bit 16

Const

bytes_out = 0  

'constant number of bytes out - none sent

Const

bytes_val = 2  

'two bytes returned

Const

big_endian = 1  

'1=(big endian)

Const

delay_usec = -0  

'delay between outgoing bytes (negative means delay also
'for incoming bytes)

Const Values_in = 1

'Main Program

BeginProg

Scan

(1,Sec,0,0)  

'Or whatever scan rate is being used

'Use the SDMGeneric instruction to send command 0x01 which returns the input
'line state as bit 16

SDMGeneric

(sio1response,addr,cmd,bytes_out,

""

,Values_in,bytes_val, _

 big_endian,delay_usec)

'bit 16 set for input line high or low so check the value and set a Boolean
'var TRUE or FALSE accordingly

 Inputstate = sio1response

AND

&H8000

NextScan

EndProg

The input line can accept 0 and 5V logic inputs OR –12 and +12V RS-232 level inputs. The
following table shows a breakdown of the different input voltages allowed and the state of the
input line flag.

Voltage on the input line State of bit 16

+12V

1

–12V

0

5V

1

0V

0

A.2 The output pin (RTS/pin 8)

To set the output pin (RTS/pin 8) you must use the

SerialOutBlock()

instruction.

The spare I/O lines are RS-232 lines, NOT logic lines. This means that the output line voltage is
–12V and +12V (approximately), not 0 and 5V.

SDM-SIO1A and SDM-SIO4A Serial Input/Output Modules

33

Summary of Contents for SDM-SI01A

Page 1: ...Revision 08 2022 Copyright 2016 2022 Campbell Scientific CSL I D 1164 ...

Page 2: ...s under guarantee or not Please state the faults as clearly as possible and if the product is out of the guarantee period it should be accompanied by a purchase order Quotations for repairs can be given on request It is the policy of Campbell Scientific to protect the health of its employees and provide a safe working environment in support of this policy a Declaration of Hazardous Material and De...

Page 3: ... cell phones and aerials may also not be applicable according to your locality Some brackets shields and enclosure options including wiring are not sold as standard items in the European market in some cases alternatives are offered Details of the alternatives will be covered in separate manuals Part numbers prefixed with a symbol are special order parts for use with non EU variants or for special...

Page 4: ...e beginning work Wear a hardhat and eye protection and take other appropriate safety precautions while working on or around tripods and towers Do not climb tripods or towers at any time and prohibit climbing by other persons Take reasonable precautions to secure tripod and tower sites from trespassers Use only manufacturer recommended parts materials and tools Utility and Electrical You can be kil...

Page 5: ...bility 8 6 Installation 8 6 1 Mounting 9 6 2 Connection and wiring 11 6 2 1 Wiring examples for connecting the SDM SIO1A 13 6 2 1 1 RS 485 RS 422 full duplex one to one connection example 14 6 2 1 2 RS 485 full duplex multi drop example 14 6 2 1 3 RS 485 half duplex wiring example 15 6 2 1 4 RS 232 wiring example with handshaking 16 6 2 1 5 RS 232 basic 3 wire example 16 6 2 1 6 Connecting a 9 way...

Page 6: ...ion 26 7 3 Schematic 26 8 Troubleshooting and maintenance 27 8 1 Troubleshooting 27 8 2 Maintenance 29 8 2 1 Upgrading the operating system 29 8 2 2 Operating system signature errors 29 8 2 3 Checking the operating system version and signature 30 Appendix A Using the handshaking lines for general input output 32 A 1 The input pin CTS pin 11 32 A 2 The output pin RTS pin 8 33 Appendix B Example dat...

Page 7: ...IO1A connections to an SDM SIO1 p 39 for more details of the differences Figure 1 1 SDM SIO1A Serial Input Output Module The SDM SIO4A module is functionally the same as four SDM SIO1As fitted inside in a compact case providing four serial ports The SDM SIO4A is used in the same way as the SDM SIO1A and uses the same CRBasic code in the data logger Although it has a similar function to the older S...

Page 8: ...ence connection may be needed to ensure all units are referenced to a common ground voltage This is more often needed with long cable runs It is advisable to check the difference in ground potential with some caution before connecting any wires to ensure the potential differences are reasonably small and excessive current will not flow between the two ground wires There is a current limiting resis...

Page 9: ...from digital sensors and or to send commands to sensors and devices It can also be used to send data to remote display devices The SDM SIO1A will accept serial data and store it in its buffer allowing remote equipment to transmit large amounts of data without needing to stop other processes in the data logger whilst the data is received The SDM SIO1A connects to the data logger via three digital l...

Page 10: ...t ensure that the characters received by the SDM SIO1A have a delay of at least one bit period between them This does not affect any other configuration and does not affect transmissions out of the SDM SIO1A Miscellaneous information The SDM SIO1A does not support auto baud rate detection or use of the serial port for general PakBus communications Modbus and DNP3 communications are supported Buffe...

Page 11: ...ly transmitting 1 All currents are measured with no loads connected For the SDM SIO4A the currents quoted need to be totalized to allow for the state of each active serial port 2 The RS 485 transmit pair is disabled when not transmitting in order to save power Higher value resistors can be used to save power dependent upon the application For many applications especially with shorter cable runs no...

Page 12: ...high level 4 5 V 5 V 5 5 V SDM lines low level 0 V 0 7 V 1 Voltage values are DC 2 It is NOT recommended that the user run their SDM SIO1A at maximum ratings for extended periods of time 3 Assuming a worst case 3 kΩ load 4 It is not recommended that the user allows such low input voltages as there will be an increased chance that external noise may cause errors in the incoming data 5 2 3 Complianc...

Page 13: ...nd weight 5 4 1 SDM SIO1A Main body Height 64 mm 2 51 in Width 62 5 mm 2 46 in Depth 22 mm 0 86 in Main body including base mounting flange Height 64 mm 2 52 in Width 85 mm 3 35 in Depth 23 mm 0 91 in Weight 70 g Mounting centres 76 2 mm 3 0 in 5 4 2 SDM SIO4A Main body Height 64 mm 2 51 in Width 154 mm 6 06 in Depth 22 mm 0 86 in SDM SIO1A and SDM SIO4A Serial Input Output Modules 7 ...

Page 14: ...ntation of the serial device you want to connect to the SDM SIO1A to determine the most appropriate method of connection for the application for example RS 232 or RS 485 RS 422 half or full duplex Generally RS 485 RS 422 connections are used for cable runs over 50 m 164 ft if the device supports them Once decided connect the wires to the relevant SDM SIO1A terminals Make sure a connection is made ...

Page 15: ...erialOpen instruction is used to specify which serial port the speed and mode of operation The speed is set by the BaudRate parameter in the instruction and the mode bits parity duplex RS 232 or RS 485 is set by the SerialOpenFormat parameter Refer to the CRBasic Editor help system for more details of the options With the correct parameters in the SerialOpen instruction the program can be written ...

Page 16: ...s 4 port 2 has SDM address 5 port 3 has SDM address 6 and port 4 has SDM address 7 The equivalent ComPort number of each port corresponds to the SDM address of the port in the same way as for the SDM SIO1A as shown in Table 6 1 p 10 For the SDM SIO4A if the address switch is set to C SDM 12 or above only the ports which would have valid SDM addresses are enabled For example if the switch is set to...

Page 17: ... wire into the round hole Release the clamp and verify the clamp grips the wire rather than the plastic insulation If there is a need to insert more than one wire in each terminal if using multi strand wire twist the conductors together first If using solid wires solder or crimp multiple pairs together before insertion Table 6 2 p 11 shows all the connections on the SDM SIO1A Table 6 2 SDM SIO1A t...

Page 18: ... before connecting 2 The G pin 7 can be used for the RS 232 zero volt reference or any other ground connection needed for example shields The SDM SIO4A has identical wiring for the data logger connections pins 1 to 5 To allow for the extra serial ports pins 6 to 11 are reproduced four times once for each port The connections for different ports are clearly delimited with each labelled with the por...

Page 19: ...vices Check the manual of the device for details on where to connect the screen for maximum effectiveness RS 422 mode is functionally the same as RS 485 mode except the connection is limited to a point to point system Connections and programming for RS 422 are otherwise identical to full duplex RS 485 When operating in RS 232 mode the SDM SIO1A also supports hardware handshaking Wiring examples fo...

Page 20: ...6 2 1 1 RS 485 RS 422 full duplex one to one connection example 6 2 1 2 RS 485 full duplex multi drop example SDM SIO1A and SDM SIO4A Serial Input Output Modules 14 ...

Page 21: ...le device but RS 485 half duplex networks are the most common multi drop configuration If wiring for multiple devices make the three wire connections in parallel similar to that shown in the full duplex multi drop example NOTE As with all RS 485 configurations the use of termination resistors is optional They tend not to be required with shorter cable runs and with modern slew rate limited driver ...

Page 22: ...cting a 9 way socket to the SDM SIO1A for RS 232 devices This configuration may be used if the device is fitted with a standard 9 way D connector as was commonly fitted to computers for their RS 232 port You need to check whether the device is SDM SIO1A and SDM SIO4A Serial Input Output Modules 16 ...

Page 23: ...onnected to the remote equipment RTS and RTS TD to its CTS line l The CTS RD CTS and RTS TD RTS lines can also be used to trigger external circuitry when not being used in handshaking mode Note that when using CTS RD and RT TD lines as input and output the voltage levels are 5V NOT 0 and 5V l CTS RD and RTS TD cannot be used as separate input and output when in RS 485 mode SDM SIO1A and SDM SIO4A ...

Page 24: ...in CRBasic to send and receive data using the SDM SIO1A Please contact Campbell Scientific for further assistance or training The Campbell Scientific user forum is also a useful resource to check if others might have already written code for a specific serial device Only the parameters that need special explanation or whose functionality has changed when used with the SDM SIO1A are listed in the f...

Page 25: ...lex RS 485 or half duplex RS 485 mode as defined in the following tables Table 6 4 Communications port parameters RS 232 SerialOpenFormat Parity No stop bits No data bits 0 None 1 8 1 Odd 1 8 2 Even 1 8 3 default None 1 8 4 Not used 5 Odd 2 8 6 Even 2 8 7 None 2 8 8 Not used 9 Odd 1 7 10 Even 1 7 111 None 1 7 12 Not used 13 Odd 2 7 14 Even 2 7 15 None 2 7 1 This mode is only supported if there is ...

Page 26: ... 18 Even 1 8 19 None 1 8 20 Not used 21 Odd 2 8 22 Even 2 8 23 None 2 8 24 Not used 25 Odd 1 7 26 Even 1 7 271 None 1 7 28 Not used 29 Odd 2 7 30 Even 2 7 31 None 2 7 1 This mode is only supported if there is at least a one bit delay between characters received by the SDM SIO1A SDM SIO1A and SDM SIO4A Serial Input Output Modules 20 ...

Page 27: ... 50 Even 1 8 51 None 1 8 52 Not used 53 Odd 2 8 54 Even 2 8 55 None 2 8 56 Not used 57 Odd 1 7 58 Even 1 7 591 None 1 7 60 Not used 61 Odd 2 7 62 Even 2 7 63 None 2 7 1 This mode is only supported if there is at least a one bit delay between characters received by the SDM SIO1A SDM SIO1A and SDM SIO4A Serial Input Output Modules 21 ...

Page 28: ...M SIO1A unit into shutdown mode where only SDM communications will operate This means any data coming into the SDM SIO1A on the RS 232 RS 485 interface will be lost This is the lowest possible power mode and for optimum power efficiency the SDM SIO1A should be placed in this mode whenever possible 6 3 1 3 SerialIn The primary difference when using this instruction with an SDM SIO1A compared to whe...

Page 29: ...ll Scientific data loggers It is possible to reduce this time and the transfer time by using the SDMSpeed instruction This can be done if using short cable runs between the data logger and all SDM devices 6 3 1 4 SerialOut Transmission from the SDM SIO1A will commence once the first byte of user information is received from the data logger There will be a total delay of 16 bit periods at the SDMSp...

Page 30: ...ree to receive or transmit data This interface is often called RTS CTS hardware handshaking or DTR DTE Automatic handshaking for the SDM SIO1A is activated through use of the BaudRate parameter of the SerialOpen instruction When the BaudRate value is set to a negative number the SDM SIO1A will enable automatic handshaking It is worth noting that normally setting the BaudRate to a negative number w...

Page 31: ...will cause data corruption There is also a delay of at least the time to send one character after the last character has been transmitted before the SDM SIO1A will listen for new incoming data NOTE When in either RS 485 half duplex or full duplex modes the user cannot set or clear the spare I O ports pins 8 and 11 7 1 3 Using the RS 232 link in receive only mode To place the SDM SIO1A into RS 232 ...

Page 32: ... only sends data one way to the data logger run the SDM SIO1A in receive only mode as this does not turn on the output drivers see Using the RS 232 link in receive only mode p 25 If using RS 232 mode also avoid connecting handshaking lines that are not required to avoid an unnecessary 2 mA drain per line The SDM SIO1A will start up with its last set of baud rate and protocol settings This feature ...

Page 33: ...SDM SIO1A 8 Troubleshooting and maintenance 8 1 Troubleshooting If correctly connected the SDM SIO1A normally operates seamlessly However there are some common issues people encounter during setup or sometimes after a period of operation During the setup phase either no data or corrupt data may be received by the data logger When receiving data the character will be returned in place of the expect...

Page 34: ...imes used and transposed Generally for these lines it is safe to try swapping them around if there is doubt as to whether the same terminology is being used If you are sure the configuration and wiring of the data logger and serial device is correct it is possible to check what the data logger thinks it is transmitting and the data it is receiving by connecting to the data logger with a computer a...

Page 35: ...the software New versions can be downloaded from the Campbell Scientific website at www campbellsci eu Follow the instructions for that device to load a new operating system At the end of the process a success message will be shown if successful During the loading of the operating system do not disturb or disconnect power to the SDM SIO1A otherwise it may need to be returned to the factory for rep...

Page 36: ...SIO1A using the preceding procedure If this does not correct the fault the unit may be faulty and will need to be returned to the factory for repair 8 2 3 Checking the operating system version and signature It is not possible to check the current operating system version using Device Configuration Utility as the SDM SIO1A is designed as a transparent RS 232 device Instead the operating system vers...

Page 37: ...stant 1 big endian or 0 little endian Const delay_usec 0 constant delay between outgoing bytes negative means delay also for incoming bytes Const Ver_values_in 20 constant number of values to receive Const Sig_values_in 4 constant number of values to receive SequentialMode BeginProg SDMSpeed 30 Fix the speed Ver_Value Sig_Value Scan 1 Sec 0 0 Use the generic SDM instruction to get extra info from ...

Page 38: ...e user enables automatic handshaking as discussed in Using RTS CTS and automatic handshaking p 24 pins 8 and 11 cannot be accessed A 1 The input pin CTS pin 11 The state of the input line pin 11 can be read by using the special SDMGeneric instruction in CRBasic Bit 16 of a value returned to the data logger using the SDMGeneric instruction reports whether the input is logic high or low The followin...

Page 39: ...neric instruction to send command 0x01 which returns the input line state as bit 16 SDMGeneric sio1response addr cmd bytes_out Values_in bytes_val _ big_endian delay_usec bit 16 set for input line high or low so check the value and set a Boolean var TRUE or FALSE accordingly Inputstate sio1response AND H8000 NextScan EndProg The input line can accept 0 and 5V logic inputs OR 12 and 12V RS 232 leve...

Page 40: ...e will set the output pin on the SDM SIO1A high then low respectively on the SDM SIO1A device set to address 0 on its rotary switch Any value greater than 1 will set the output pin high but usually the number 1 is used as this will improve the readability of the code Value of SerialOutBlock SerialExpression variable Voltage on the output line 1 12V1 0 12V1 1 Approximate voltage do not drive relays...

Page 41: ...gger serial port The program code is the same for all data loggers that support the SDM SIO1A The exact program to be used will vary with the serial device being used Unfortunately the number of possible variations of reading different sensors is almost infinite If you are struggling to write code please contact Campbell Scientific who may already have experience with the sensor and may be able to...

Page 42: ...ly needed Scan 1000 mSec 0 0 Open serial port to RS 232 mode 115200bps 8 bit data 1 stop bit and no parity SerialOpen SensorPort 115200 3 100 10000 open the serial port to the sensor Request data will need to be replaced with the correct command for your sensor In this example we wait for the response Start for up to 1 second before continuing SerialOut SensorPort Request data Start 1 100 Send dat...

Page 43: ...32 Declare the serial port the sensor is set to The sensors address switch should be set to position 0 SDMSpeed 30 Optionally set the SDMSpeed not normally needed Scan 1000 mSec 0 0 Open serial port to RS 485 mode 115200bps 8 bit data 1 stop bit and no parity note that the SerialOpenFormat parameter is 19 for RS 485 mode SerialOpen SensorPort 115200 19 100 10000 open the serial port to the sensor ...

Page 44: ...turnedData add an offset to the returned floating point value ConvertedValue ConvertedValue 100 SerialClose SensorPort Close the serial port to the sensor this places the SDM SIO1A into its lowest power mode Next Scan EndProg SDM SIO1A and SDM SIO4A Serial Input Output Modules 38 ...

Page 45: ...plicates RS 422 and RS 485 devices can be connected to the equivalent multifunction terminals on the SDM SIO1A The labelling for the RS 422 RS 485 functions has also been changed to avoid the confusion caused by different labelling conventions used for the A and B terminals by different manufacturers To avoid this the SDM SIO1A uses the alternative TD TD RD RD scheme of labelling with the TD and T...

Page 46: ... SDM SIO1 to SDM SIO1A SDM SIO1 SDM SIO1A Case text Pin Pin Case text CTS B 8 11 CTS RD RTS Y 9 8 RTS TD TX Z 10 9 Tx TD 0V 11 6 RG Z 12 9 Tx TD Y 13 8 RTS TD B 14 11 CTS RD A 15 10 Rx RD SDM SIO1A and SDM SIO4A Serial Input Output Modules 40 ...

Page 47: ...info campbellsci fr www campbellsci fr Germany Location Phone Email Website Bremen Germany 49 0 421 460974 0 info campbellsci de www campbellsci de India Location Phone Email Website New Delhi DL India 91 11 46500481 482 info campbellsci in www campbellsci in South Africa Location Phone Email Website Stellenbosch South Africa 27 21 8809960 sales campbellsci co za www campbellsci co za Spain Locati...

Reviews: