3 digital i/o triggered canbus measurements, Digital i/o triggered canbus measurements – Campbell Scientific SDM-CAN Datalogger to CANbus Interface User Manual

Page 47

Advertising
background image

SDM-CAN Datalogger-to-CANbus Interface

'\\\\\\\\\\\\\\\\\\\\\\\\\\\ PROGRAM ///////////////////////////
BeginProg 'Program begins here

'MainSequence
Scan(PERIOD,P_UNITS,0,0) 'Scan once every 1 Secs, non-burst
'__________________________ Temp Blocks __________________________

ModuleTemp(TRef(),1,5,100)
TCSE(TBlk1(),TREP1,TRNG1,5,1,TTYPE1,TRef(1),
TSETL1,TINT1,TMULT1,TOSET1)

'__________________________ CAN Blocks __________________________
'When Flag 1 is high set SDM-CAN switches to transmit mode
If Flag(1) Then

'Load variable with value for switches
Switches = 3

'Send switch settings to SDM-CAN
CanBus(Switches,ADDR1,TQUANT,TSEG1,TSEG2,0,
DTYPE1,STBIT1,NBITS1,NVALS1,CMULT1,COSET1)

'Set flag 1 low after sending switch settings
Flag(1) = False

EndIf

'Transmit Data on to CAN network
CanBus(TBlk1(),ADDR2,TQUANT,TSEG1,TSEG2,1,
DTYPE2,STBIT2,NBITS2,NVALS2,CMULT2,COSET2)

Next Scan 'Loop up for the next scan
EndProg 'Program ends here

The default setting for the SDM-CAN internal software switches
is 0. The switches must be set by using the data type 32
parameter to enable data transmission. Also remember to check
the jumper settings inside the SDM-CAN if enabling
transmission, as the default setting is for transmission to be
disabled in hardware.

NOTE

4.2.3 Digital I/O Triggered CANbus Measurements

Although the CR5000 and CR9000 do not have the interrupt feature that is
available on the CR10X, CR7 and CR23X it is possible to connect the I/O line
from the SDM-CAN to a Digital I/O port. A program control instruction can
then be used to trigger the retrieval of new CAN data from the SDM-CAN
when the port is high. An example of this is shown below

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



'\\\\\\\\\\\\\\\\\\\\\\\\\ CANBUS CONSTANTS //////////////////////
'------------------- Physical Network Parameters -----------------

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

'---------------------- Data Frame Parameters --------------------
'___________________________CANbus Block1_________________________
Const CANREP1 = 1 'Repetitions

Const ADDRESS1 = 0 'SDM address of SDM-CAN Module
Const DATATYPE1 = 1 'Collect and retrieve data values
Const STARTBIT1 = 1 'Start position in data frame

Const NUMBITS1 = -16 'Number of bits/value – for interrupt
Const NUMVALS1 = 1 'Number of values

Dim CANBlk1(CANREP1) 'Dimensioned source
Dim NewData

39

Advertising