Industrial Automation
Industrial Automation | Europe

myKnowledge

Main > Product Type > Software > Programming
Minimize Text   Default    Enlarge Text
 

Print
E-mail

Function Block For Configuring the CAN Open Network


The purpose of this Function Block (FB) is to simplify the immediate configuration of the CJ1W-CORT21 card for communication devices with CAN-Open. The Function Block sets the buffer for transmission and reception, setting the ID and the transmission method in a way that is transparent to the user. Instead of using complex Cmnd instructions Cmnd just three tables will show the necessary parameters.


The card can send messages with a 11Bit identifier directly, with the command Cmnd 2907, or via a buffer. In this second case it is also possible to set the method for sending messages. You can choose between three modes, with trigger bits, at intervals, or on the status change of the field data.

The reception of CAN messages is done solely through the buffer, of which a maximum of 280 buffers can be set for reception. For each buffer we can match a different ID.
The establishment of buffer areas, the building blocks to be sent and the definition of filters receipt, is affected by FINS commands addressed to the card CORT21. For sending commands to the card you must use the instructions Cmnd.

Structure of the buffer CORT21

A maximum of 280 buffers for both the input and output can be defined within the memory of the PLC. Each buffer consists of 5 words, the first word contains the length of data field in bytes (0 to 8), the next 4 words represent the data field with two bytes per word. It is also possible to select the order of bytes within the word between Big Endian (least significant byte precedes the most significant byte) which is the default and Little Endian which is more suited to the internal representation in the Omron PLC.

Used Variables

Admission

EN  BOOL  Enables the FB, always ON
Unit_n  INT  Number of units of the CORT21 (0 to 16)
Buffer_table  UINT  Address of DM in which there is a table of memory areas (0-19999
Send_table  UINT  Address of DM of the first table of the transmission buffer
Recv_table  UINT  Address of DM of the first table of the receiving buffer
execute  BOOL  Performs the configuration

Exit

ENO BOOL Follows the enabled state of the FB
Busy BOOL ON during the execution of the configuration
Comms_error BOOL ON if an error occurs in the transfer of parameters
Error_Code WORD Error code of the transfer
done BOOL Go to ON to indicate the completion of the configuration

Table for memory allocation

m = DM allocated first to the table (Buffer_table)

m Memory code for the buffer transmission (see table)
m+1 Starting address of the buffer transmission (hex)
m+2 Memory code triggers for transmission (see table)
m+3 Address initial transmission flag (hex)
m+4 Number of the transmission buffer in HEX (max 280)
m+5 Memory code for the receive buffer (see table)
m+6 Initial address of receive buffer (hex)
m+7 Memory code of the receipt flag (see table)
m+8 Address initial reception area flags (hex)Address initial reception area flags (hex)
m+9 Number of receive buffer in HEX (max 280)
Memory Area Description Address Maximum
#0001h CIO Area #17FFh (6143)
#0002h DM Area #7FFFh (32767)
#0003h W Area #1FFh (511)
#0004h H Area #1FFh (511)
#0008h EM0 Dock #7FFFh (32767)
#0009h EM1 Dock #7FFFh (32767)
#000Ah EM2 Dock #7FFFh (32767)
#000Bh EM3 Dock #7FFFh (32767)
#000Ch EM4 Dock #7FFFh (32767)
#000Dh EM5 Dock #7FFFh (32767)
#000Eh EM6 Dock #7FFFh (32767)
#000Fh EM7 Dock #7FFFh (32767)
#0010h EM8 Dock #7FFFh (32767)
#0011h EM9 Dock #7FFFh (32767)
#0012h EM A Dock #7FFFh (32767)
#0013h EM B Dock #7FFFh (32767)
#0014h EM C Dock #7FFFh (32767)

Transmission Buffer table definition

k=first word of the definition table of the transmission buffer (Send_table)

k Buffer 0 CAN ID - identifier of the message to 11Bit CAN
k+1 Buffer 0 Transmission method (see table)
k+2 Buffer 0 Transmission interval in milliseconds 1-65535ms (if required)

....

k+3 × buffer number_TX - 1
The three words are repeated for each buffer 

Value Transmission Method
1 Enter the corresponding rising trigger bits
2 Cyclic sending of messages (set in period k +2)
4 Sending the state change

Receiving Buffer table definition

z = first word of the definition table of the receiving buffer (Recv_table)

z Buffer 0 CAN ID 11Bit identifier of a CAN message
z+1 Buffer 1 CAN ID  
z+2 Buffer 2 CAN ID  

...

z + buffer number-1

Transmission Buffer

T = first word in the transmission buffer as specified in word m +1 me.

Trigger for the transmission
For each buffer transmission there is a corresponding bit in the Trigger, the Bit 0 of the first word matches buffer 0, the next bit buffer 1 and so on. If you have already selected how you want to send 1, resulting in a Bit On, the trigger will send the message stored in the buffer's corresponding transmission. CORT21 will replace the Bit Off used.

word R 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
word R+1 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
word R+L 16*L + 15 16*L + 14 16*L + 13 16*L + 12 16*L + 11 16*L + 10 16*L + 9 16*L + 8 16*L + 7 16*L + 6 16*L + 5 16*L + 4 16* L + 3 16*L + 2 16* L + 1  

R = first word in the transmission buffer as specified in word m +2 and m +3

Receiving Buffer

U = first word in the receiving buffer as specified in word m +5 and m +6.

Receipt Flag

Each receiving buffer has a flag, Bit 0 of the first word matches buffer 0, the next time the buffer 1 and so on.
The status of the flag has the following meanings:
ON: It has received a message with the ID set to the last I / O refresh
OFF: It has not received any message within the defined ID. 

word S 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
word S+1 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
word S+L 16*L + 15 16*L + 14 16*L + 13 16*L + 12 16*L + 11 16*L + 10 16*L + 9 16*L + 8 16*L + 7 16*L + 6 16*L + 5 16*L + 4 16* L + 3 16*L + 2 16* L + 1  

S = first word in the receiving buffer as specified in word m +7 m +8.

Use
The card can only be configured when the CAN interface is not active. If you try to configure the card while it is in any other state, the configuration will be ignored and it will activate the output error of the block function. This situation corresponds to the error code 0401 hex. 
The status of the card can be changed on the Bit 04 of the first word on the Bus CPU module (eg if the card has the number of units 0, the corresponding bit is 1500.04).

Word Bit Meaning
n 04 Check the status of the CAN.
On = active interface
Off = disable interface
n+3 02 State of
On = active interface
Off = inactive interface


n = 1500 + 25 × Unit number

The configuration is maintained until the PLC is shutdown. Each time you need to configure the card you activate the CAN interface. If you do not want to use the communication buffer it is necessary to configure it, setting the number of buffers for transmission to 0.
To start the CAN network you must then:
1. Configure the CORT21 card using the blocking function Set_buffers " 
2. Choose a Bit On status for the CAN 
3. Send to all nodes of the network the activation signal for the operating condition (operational state), for this function you can use the lock function Start_all_nodes "

Activation of the Function Block must be done with the bit always On.  Launching the configuration is done on the rising edge of the bit related to "execute". Before starting the configuration it is necessary to prepare the tables for configuration. MOV instructions can be used for doing so. You can also use the editor of the CX-Programmer and transfer data on the PLC. For the input parameters of the block may be used instead of a constant. 

Completing the configuration will take several scans, the number of them depends on the number of buffers configured. During processing the exit "Busy" term is On. Once completed the "Busy" Bit switches to off and, if there are no errors,  The "Done."  Bit switches on. In case of error, the "Done" bit will not come on and instead the "Error" bit will open with Exit "ERROR_CODE" returning the error code of the last operation performed. For error codes refer to the manual card CORT21.

Correct Configuration

Incorrect Configuration

Starting the CAN Open network (FB Start_all_nodes)


All CAN Open devices are based in a state called "Pre operational state", in this mode, the devices are waiting for configuration and data exchange network. To start the network and start the data exchange it is necessary to send a message that orders CAN Open nodes to move to the "Operation" state. The operational nodes exchange data over the network and can not accept a new configuration. The function block Start_all_nodes sends a message on the network. Operating is very simple, just specify the Unit Number tab of the PLC and CAN lead to the Input On "start_comm".

Variables used
Admission

EN BOOL Enables the FB,  Always ON
Unit_n INT Number of units of the CORT21 card (0 to 16)
Start_comm BOOL Performs the configuration

Exit

ENO BOOL Following the FB status
Busy BOOL ON during the execution of the configuration
Comms_error BOOL ON if an error occurs in the transfer of parameters
Error_code WORD Error code

Application example
The configuration considered in this example includes a CJ1 PLC CORT21 card set to 0 units, two inverter 3G3MV with PCORT interface, a module I / O to 16 digital inputs and a module for 16 digital outputs.

For defining the buffer it is necessary to derive the CAN identifiers used in the exchange data. Open devices in the CAN data are organized into objects, to send and / or receive data, the device relies on the special item the PDO (Process Data Object); PDO exists for the transmission of data, TPDO for receiving data, and the RPDO. TPDO and RPDO are assigned an identifier called COB-ID (Communication Object ID) and one or more objects contain the data I / O of the slave. Each PDO can send or receive a maximum of 8 bytes. All devices have CAN Open PDO defaulting to the default COB-ID. The CAN Open protocol defines a minimum set of two TPDO and two RPDO. Mapping of default and related PDO COB-ID can be derived from the documentation accompanying the device. Each manufacturer is free to add additional PDO to the default configuration.

PDO COB-ID (Hex)
TPDO0 180 + NodeID
TPDO1 280 + NodeID
RPDO0 200 + NodeID
RPDO1 300 + NodeID

Default mapping of an I / O device.
The documentation can be found in the following IDs

PDO COB-ID (Hex) Description
RPDO0 200 + NodeID Command word
RPDO1 300 + NodeID Speed reference
RPDO2 400 + NodeID Mailbox command
TPDO0 180 + NodeID Inverter status
TPDO1 280 + NodeID Actual speed
TPDO2 380 + NodeID Motor current
TPDO3 480 + NodeID Mailbox response

Inverter 3G3MV with PCORT21

PDO COB-ID (Hex) Description
TPDO0 180 + NodeID Input state

Input module to 16 points

PDO COB-ID (Hex) Description
RPDO0 200 + NodeID Output state

Output module to 16 points

Note: This will not be used as the mode of the mailbox Inverter

Network Configuration

Inverter 1 Node 1
Inverter 2 Node 2
16in Card Node 7
16out Card Node 10
Monitoring data of the inverter will be operated on the status change, while the speed will be sent using trigger bits. The slave output is updated every 100ms.

All Data

Buffer area for transmission From CIO0100
Buffer area for receiving From CIO0200
Trigger area From CIO0150
Receipt flag area From W050
Buffer configuration table From D00100
Send buffer table definition From D00200
Receive buffer table definition From D00300

Contents of the Buffer configuration table

Address Content Description
D00100 #0001 Memory area for the transmission buffer area = CIO
D00101 #0064 Memory buffer start address of transmission = word 100
D00102 #0001 Memory area to trigger the transmission area = CIO
D00103 #0096 Start address of transmission flag word = 150
D00104 #0005 Number of transmission buffers in HEX = 5
D00105 #0001 Area of memory for the receive buffer = CIO Area
D00106 #00C8 Starting address of memory buffer receiving word = 200
D00107 #0003 Memory area of the flag receiving area = W
D00108 #0032 Address initial reception area flag = word 50
D00109 #0007 Number of receive buffer in HEX = 7

Contents of the transmission buffer definition table

Address Content   Buffer  Description
D00200   #0201  0
 
 
 CAN ID - RPDO0 node 1 (inverter control word 1)
D00201  #0004  Transmission method, on the status change
D00202  #0000  Not used
D00203  #0301  1
 
 
 CAN ID - RPDO1 nodo1 (speed inverter 1)
D00204  #0001  Transmission method, on trigger
D00205  #0000  Not used
D00206   #0202  2
 
 
 CAN ID - RPDO0 node 2 (inverter control word 2)
D00207  #0004  Transmission method, on the status change
D00208  #0000  Not used
D00209  #0302  3
 
 
 CAN ID - RPDO1 node 2 (speed inverter 2)
D00210  #0004  Transmission method, on trigger
D00211  #0000  Not used
D00212  #0204  4
 
 
 CAN ID - RPDO0 node 4 (exit module 16out)
D00213  #0002  Method of transmission, periodic sending
D00214  #0064  Period = 100ms

Contents of the receive buffer definition table

Address Content Buffer Description
D00300 #0181 0 CAN ID - TPDO0 node 1 (the inverter 1)
D00301 #0281 1 CAN ID - TPDO1 node 1 (frequency inverter output 1)
D00302 #0381 2 CAN ID - TPDO2 Node 1 (current inverter motor 1)
D00303 #0182 3 CAN ID - TPDO0 node 2 (the inverter 2)
D00304 #0282 4 CAN ID - TPDO1 node 2 (frequency inverter output 2)
D00305 #0382 5 CAN ID - TPDO2 node 2 (current motor inverter 2)
D00306 #0183 6 CAN ID - TPDO1 node 3 (the state of the inputs tab 16in)

Test Program

 



Attachments

Set_Buffers.cxf - Size: 5142
Start_all_nodes.cxf - Size: 2385


Comments (View All Comments / Add Comment)

Related Articles
No related articles found.
Created 2009-05-13
Modified 2009-05-18
Views 11456

 

You are not logged in.