SDMCan (SDM Can Interface)

The SDMCAN instruction is used to measure and control the SDM-CAN interface.

Syntax

SDMCAN ( Dest, SDMAddress, TimeQuanta, TSEG1, TSEG2, ID, DataType, StartBit, NumBits, NumVals, Multiplier, Offset )

Remarks

Multiple SDMCAN instructions may be used within a program. The initial function of the instruction is to configure the SDM-CAN interface when the datalogger program is compiled. Subsequent instructions can be used to determine what data is passed between the CAN-bus network and the datalogger, set and/or read the SDM-CAN's internal switches, and read and/or reset detected errors.

The parameter dialog box for the SDMCAN instruction has a Select .PCK Values button, which when selected allows the user to specify a PCK file from which to select the CAN-bus value to be returned. When a value is selected from the pick list the Destination, ID, DataType, StartBit, NumBits, Multiplier, and Offset parameters are populated from the data in the file. PCK files are generated by the DBC to SDMCan converter.

The SDMTrigger instruction can be used to trigger simultaneous measurements from one or more SDM-CANs and other SDM devices connected to the datalogger. When the SDMTrigger instruction is encountered in a program, it broadcasts a special SDM message which causes all the SDM-CAN devices to copy the last data values captured from the CAN-bus into the working data buffers. Refer to the SDM-CAN manual for additional help.

NOTE: If more than one CANBUS instruction is used within a datalogger program, the values used for TimeQuanta, TSEG1 and TSEG2 must be the same for each instruction.

Parameters

Dest

A variable array in which to store the results of the measurement. It must be an array of sufficient size to hold all of the values that will be returned by the function chosen (defined by the DataType parameter).

Type: Variable array

SDMAddress (Address of Device)

Defines the address of the device with which to communicate. Valid ClosedSDM Synchronous Device for Measurement. A processor-based peripheral device or sensor that communicates with the datalogger via hardwire over a short distance using a protocol proprietary to Campbell Scientific. addresses are 0 through 14. Address 15 is reserved for the SDMTrigger instruction.

Some SDM instructions support repetitions. If a Reps parameter is present and it is greater than 1, the data logger will increment the SDM address used in the instruction for each subsequent device with which it communicates.

TimeQuanta

Three time segments are used to set the bit rate and other timing parameters for the CAN-bus network, TimeQuanta, TSEG1, and TSEG2. These parameters are entered as integer numbers. The relationship between the three time segments is defined as:

The first time segment, the synchronization segment (S-SG), is defined by the TimeQuanta parameter. To calculate a suitable value for TiimeQuanta, use the following equation:

where tq = the TimeQuanta. There are between 8 and 25 time quanta in the bit time. The bit time is defined as 1/baud rate.

TSEG1

The second time segment, TSEG1, is actually two time segments known as the propagation segment and phase segment one. The value entered is determined by the characteristics of the network and the other devices on the network. It can be calculated as:

TSEG2

The third time segment, TSEG2 (the phase segment two), is defined by the TSEG2 parameter. The value of TSEG2 can be calculated using the equation:

The relative values of TSEG1 and TSEG2 determine when the SDM-CAN samples the data bit.

ID

Each device on a CAN-bus network prefaces its data frames with an 11 or 29 bit identifier. The ID parameter is used to set this address. The ID is entered as a single decimal equivalent. Enter a positive value to signify a 29 bit ID or a negative value to signify an 11 bit ID. Any value < -2047 will set the ID to an 11 bit ID of 0.

DataType

Defines what function the CANBUS instruction will perform. This instruction can be used to collect data, buffer data for transmission to the CAN-bus, transmit data to the CAN-bus, read or reset error counters, read the status of the SDM-CAN, read the SDM-CAN's OS signature and version, send a remote frame, or read or set the SDM-CAN's internal switches. Enter the numeric value for the desired option:

Value Description
1 Retrieve data; unsigned integer, most significant byte first
2 Retrieve data; unsigned integer, least significant byte first
3 Retrieve data; signed integer, most significant byte first
4 Retrieve data; signed integer, least significant byte first
5 Retrieve data; 4-byte IEEE floating point number; most significant byte first
6 Retrieve data; 4-byte IEEE floating point number; least significant byte first
7 Build data frame in SDM-CAN memory; unsigned integer, most significant byte first. Overwrite existing data
8 Build data frame in SDM-CAN memory; unsigned integer, least significant byte first. Overwrite existing data.
9 Build data frame in SDM-CAN memory; signed integer, most significant byte first. Overwrite existing data.
10 Build data frame in SDM-CAN memory; signed integer, least significant byte first. Overwrite existing data.
11 Build data frame in SDM-CAN memory; 4-byte IEEE floating point number; most significant byte first. Overwrite existing data.
12 Build data frame in SDM-CAN memory; 4-byte IEEE floating point number; least significant byte first. Overwrite existing data.
13 Build data frame in SDM-CAN memory; unsigned integer, most significant byte first. Logical "OR" with existing data.
14 Build data frame in SDM-CAN memory; unsigned integer, least significant byte first. Logical "OR" with existing data.
15 Build data frame in SDM-CAN memory; signed integer, most significant byte first. Logical "OR" with existing data.
16 Build data frame in SDM-CAN memory; signed integer, least significant byte first. Logical "OR" with existing data.
17 Build data frame in SDM-CAN memory; 4-byte IEEE floating point number; most significant byte first. Logical "OR" with existing data.
18 Build data frame in SDM-CAN memory; 4-byte IEEE floating point number; least significant byte first. Logical "OR" with existing data.
19 Transmit data value to the CAN-bus; unsigned integer, most significant byte first.
20 Transmit data value to the CAN-bus; unsigned integer, least significant byte first.
21 Transmit data value to the CAN-bus; signed integer, most significant byte first.
22 Transmit data value to the CAN-bus; signed integer, least significant byte first.
23 Transmit data value to the CAN-bus; 4-byte IEEE floating point number; most significant byte first.
24 Transmit data value to the CAN-bus; 4-byte IEEE floating point number; least significant byte first.
25 Transmit previously built data frame to the CAN-bus.
26 Set up previously built data frame as a Remote Frame Response.
27 Read Transmit, Receive, Overrun, and Watchdog errors. The errors are placed consecutively in the array specified by the Dest parameter.
28 Read Transmit, Receive, Overrun, and Watchdog errors. The errors are placed consecutively in the array specified by the Dest parameter. Reset error counters to 0 after reading.
29

Read SDM-CAN status; result is placed into the array specified in the Dest parameter. The result codes are as follows:

Status Description
0000 The SDM-CAN is involved in bus activities; error counters are less than 96.
0001 The SDM-CAN is involved in bus activities; one or more error counters is greater than or equal to 96.
0002 The SDM-CAN is not involved in bus activities; error counters are less than 96.
0003 The SDM-CAN is not involved in bus activities; one or more error counters is greater than or equal to 96.
30 Read SDM-CAN operating system and version number; results are placed in two consecutive array variables beginning with the variable specified in the Dest parameter.
31 Send Remote Frame Request.
32

Set SDM-CAN's internal switches. The code is stored in the array specified in the Dest parameter and is entered in the form of ABCD.

Switch Code Description
A 0 Currently not used; set to 0.
B 0 SDM-CAN returns the last value captured from the network, even if that value has been read before (default).
  1 SDM-CAN returns -99999 if a data value is requested by the datalogger and a new value has not been captured from the network since the last request.
  2-9 Currently not used.
C 0 Disable I/O interrupts (default).
  1 Enable I/O interrupts, pulsed mode.
  2 Enable I/O interrupts, fast mode.
  3-7 Currently not used.
  8 Place the SDM-CAN into low power stand-by mode.
  9 Leave switch setting unchanged.
D 0 Listen only (error passive) mode. CAN transmissions are not confirmed.
  1 Transmit once. Data will not be retransmitted in case of error or loss of arbitration. Frames received without error are acknowledged.
  2 Self-reception. A frame transmitted from the SDM-CAN that was acknowledged by an external node will also be received by the SDM-CAN but no retransmission will occur in the event of loss of arbitration or error. Frames received correctly from an external node are acknowledged.
  3 Normal, retransmission will occur in the event of loss of arbitration or error. Frames received correctly from an external node are acknowledged. This is the typical setting to use if the SDM-CAN is to be used to transmit data.
  4 Transmit once; self-test. The SDM-CAN will perform a successful transmission even if there is no acknowledgment from an external CAN node. Frames received correctly from an external node are acknowledged.
  5 Self-reception; self -test. The SDM-CAN will perform a successful transmission even if there is no acknowledgment from an external CAN node. Frames received correctly from an external node are acknowledged. SDM-CAN will receive its own transmission.
  6 Normal; self-test. The SDM-CAN will perform a successful transmission even if there is no acknowledgment from an external CAN node. Frames received correctly from an external node are acknowledged.
  7 Not defined.
  8 Not defined.
  9 Leave switch setting unchanged.
33 Read SDM-CAN's internal switches. Place results in the array specified in the Dest parameter.

StartBit

Used to identify the least significant bit of the data value within the CAN data frame to which the instruction relates. The bit number can range from 1 to 64 (there are 64 bits in a CAN data frame). The SDM-CAN adheres to the ISO standard where the least significant bit is referenced to the right most bit of the data frame. If a negative value is entered, the least significant bit is referenced to the left most bit of the data frame.

NumBits

The NumBits parameter is used to specify the number of bits that will be used in a transaction. The number can range from 1 to 64 (there are 64 bits in a CAN data frame).

The SDM-CAN can be configured to notify the datalogger when new data is available by setting a control port high. This allows data to be stored in the datalogger tables faster than the program execution interval. This interrupt function is enabled by entering a negative value for this parameter.

NOTE: This parameter may be overridden by a fixed number of bits, depending upon the data type selected.

NumVals

The NumVals parameter defines the number of values (beginning with the value stored in the Dest array) that will be transferred to or from the datalogger during one operation. For each value transferred, the Number of Bits (NumBits) will be added to the Start Bit number so that multiple values can be read from or stored to one data frame.

Mult, Offset (Multiplier and Offset)

Factors by which to scale the raw results of the measurement. Typically used to convert the raw measurement to engineering units or to units other than which is output. For example, the TCDiff instruction measures a thermocouple and outputs temperature in degrees C. A multiplier of 1.8 and an offset of 32 will convert the temperature to degrees F.

For temperature measurements, a multiplier (mult) of 1 and an offset of 0, would output in degrees Celsius. For analog measurements, a multiplier (mult) of 1 and an offset of 0, would output the measured voltage in millivolts divided by the excitation voltage in volts.

If Repetitions of greater than 1 are used for this instruction, Repetitions can also be used for the Multiplier and Offset. See Multipliers, Offsets, and Disable Variables with Repetitions for more information.

Type: Constant, Variable, Array, or Expression