Examples
CAN-CBM-DP
Software Manual Rev. 2.0
88
8. Examples
8.1 Application Example with Page Mode
The following summary shows the FBs and DBs required to control the CANopen devices:
Example for calling FB 1
---------------------------------
( Setup of CANopen module by means of a list, see below)
Network 7: motor setup
-----------
O #BIT15 // domain-transfer is on ?
O #BIT14
SPB M033 // yes --> jump
L #INIT_LIST_DB
T #t016
AUF DB [#t016] // open DB with init-list
M012: L 127 // maximum 127 motors
L #MOTOR
+ 1
T #MOTOR
<I // 127 < motor ? -> yes ==> configuration ready
SPB M013 // ==> jump to the end
+ -1 // motor 1 starts at byte 0, motor 2 starts at byte 8, ...
SLW 3 // means * 8: motor-index -> byte-number
SLW 3 // means * 8: byte-number -> bit-address
T #t000
L 0 // means: motor not present
L DBW [#t000] // get DB-number to init this motor
T #INIT_DB
==I
SPB M012 // to next motor
L W#16#FFFF // means: motor not needed to initialize
==I
SPB M012 // to next motor
L #t000
+ 16
T #t000
L DBW [#t000] // get offset in the actual init-DB
T #INIT_OFFSET
L #MOTOR // motor no.
L W#16#600
+I
T #TX_ID
L #MOTOR // motor no.
L W#16#580
+I
T #RX_ID
UN #BIT15
S #BIT15
M033: CALL FB 1 , DB101
transfer :=#BIT15
tx_id :=#TX_ID
rx_id :=#RX_ID
write_address_cw:=#WRITE_ADDRESS_CW
read_address_cw :=#READ_ADDRESS_CW
init_db :=#INIT_DB
offset :=#INIT_OFFSET
ret_value :=#t016
U #BIT15
S #BIT14
L W#16#0 // means: configuration in FB1 is off
L #t016 // status of setup
==I
SPB M034
UN #FREIGABE
SPB M014
L #INIT_LIST_DB
T #t008
AUF DB [#t008] // open DB with init-list
L #MOTOR