3 digital i/o triggered canbus measurements – Campbell Hausfeld SDM-CAN User Manual

Page 45

Advertising
background image

Section 4. Programming the CR9000 and CR5000

'\\\\\\\\\\\\\\\\\\ ALIASES & OTHER VARIABLES //////////////////

Public Flag(8) 'General Purpose Flags
Dim TRef(1) 'Declare Reference Temp variable

'\\\\\\\\\\\\\\\\\\\\\\\\\\\ 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)

4-5

Advertising