2 simple can data transmission – Campbell Hausfeld SDM-CAN User Manual

Page 44

Advertising
background image

SDM-CAN CAN-Bus Interface User Guide

4.2.2 Simple CAN Data Transmission

The following example transmits a 16 bit temperature value to a CAN network
running at 250K baud.

'Set scan rate
Const PERIOD = 1 'Scan interval number
Const P_UNITS = 2 'Scan interval units (Secs)

\\\\\\\\\\\\\\\\\\\\ THERMOCOUPLE CONSTANTS ////////////////////

'__________________________ Temp Block1 __________________________

Const TRNG1 = 17 'Block1 measurement range (50 mV)
Const TTYPE1 = 0 'Block1 thermocouple type (T)
Const TREP1 = 1 'Block1 repetitions
Const TSETL1 = 30 'Block1 settling time (usecs)
Const TINT1 = 20000 'Block1 integration time (usecs)
Const TMULT1 = 1 'Block1 default multiplier
Const TOSET1 = 0 'Block1 default offset
Dim TBlk1(TREP1) 'Block1 dimensioned source
Units TBlk1 = Deg_C 'Block1 default units (Deg_C)

'\\\\\\\\\\\\\\\\\\\\\\\\\ CANBUS CONSTANTS //////////////////////

'------------------- Physical Network Parameters -----------------

Const TQUANT = 4 ')Set SDM-CAN to 250K
Const TSEG1 = 5 ')Network speed
Const TSEG2 = 2 ')

'---------------------- Data Frame Parameters --------------------

'___________________________CANbus Block1_________________________

'Send switch value Data type 32

Const CANREP1 = 1 'Repetitions
Const ADDR1 = 0 'SDM address of SDM-CAN Module
Const DTYPE1 = 32 'Send switch value
Const STBIT1 = 0 'Start position in data frame
Const NBITS1 = 0 'Number of bits/value
Const NVALS1 = 0 'Number of values
Const CMULT1 = 1.0 'Multiplier
Const COSET1 = 0 'Offset
Dim Switches(CANREP1) 'Dimensioned source

'___________________________CANbus Block2_________________________

'Transmit 16 bit data value

'Data type 20, unsigned integer, least significant byte first

Const CANREP2 = 1 'Repetitions
Const ADDRESS2 = 0 'SDM address of SDM-CAN Module
Const DTYPE2 = 20 'Tx, unsigned int, LSB 1st
Const STBIT2 = 49 'Start position in data frame
Const NBITS2 = 16 'Number of bits/value
Const NVALS2 = 1 'Number of values
Const CMULT2 = 1 'Multiplier
Const COSET2 = 0 'Offset

4-4

Advertising