
ADwin-light-16
, manual version 2.2, December 2004
41
Software
ADwin
11 Software
You are programming the
ADwin-light-16
- all expansions included - with sim-
ple
ADbasic
instructions.
All instructions are described in the
ADbasic
manual (which contains a com-
plete instruction list in the appendix).
11.1 Example Program
CAN: Cyclic Read and Send of Messages
This programs describes the initialization of the CAN controller in the section
INIT:
and the cyclic read and send of messages in the section
EVENT:
REM The program initializes the CAN controller,
REM configures one message object as sender
REM and one as receiver. The program exchanges all 10 ms data
REM between CAN controller and transputer.
#INCLUDE ADWL16.INC
DIM result AS INTEGER
INIT:
INIT_CAN()
'Initialize the CAN controller
'Set Baud rate to 125 kBit/s
SET_CAN_BAUDRATE(125000)
EN_RECEIVE(2,385,0) 'configure message object 2 for reading
'with 11 bit identifier 385
EN_TRANSMIT(3,1,0) 'configure message object 3 for writing
'with 11 bit ident. 1
EVENT:
REM read 1 data set and write 1 data set
result = READ_MSG(2)'read data
'If there are new data, they are written into the field
'CAN_MSG.
can_msg[1]=1
'data, which are to be sent,
can_msg[2]=2
'are written into the field
can_msg[3]=3
'CAN_MSG. You are getting the
can_msg[4]=4
'data from this field to be
can_msg[5]=5
'sent later
can_msg[6]=6
can_msg[7]=7
can_msg[8]=8
can_msg[9]=8
'8 data bytes
TRANSMIT(3)
'send message in message object 3