{}

Our Brands

Impact-Company-Logo-English Black-01-177x54

Welcome to the Schneider Electric Website

Welcome to our website.

Search FAQs

Setting up a Write_VAR function block in a M340 to write to SDOs in a CAN device.

Goals and Symptoms

M340, CANopen, Write_Var

Causes and Fixes


First your project Configuration and double click on the CAN port to configure it



Configure the CAN port as needed for your application and notice the Channel # of the CAN port (Channel 2)
Note: The Inputs & Outputs configured here are for PDOs not SDOs.



Next open the CANopen Network from the Configuration. Double click on the Node to add a CAN device.



From the available list chose the CAN device you will be using and press OK.
For this example we are using a Altivar 71 drive.



A picture of the device will appear on the network. Double click in the Node box to adjust the Node ID of the device.
Then double click on the device for its configuration.



Configure the CAN Device as needed.
Note: PDOs are memory mapped directly to memory locations within the M340 SDOs are not.



Next open the Project Settings and configure them so that you can directly address arrays in your program.
This step is optional however if you do not do this you will need to declare variables as array's in you program.



Next open you program section and add a ADDM block (for addressing the CAN device) and a
Read_Var block.

The ADDM block for CAN has an input syntax of r.m.c.e (rack.module.channel.equipment) and is
entered as a string so a ' is needed before and after the string. The OUT pin is connected directly to the
ADR pin of the Read_Var.

The remaining parameters of the WRITE_VAR are configured as follow:

OBJ (object type we are reading, string input)
NUM (location in the CAN device we are reading from. Subindex_index for CAN)
NB (length of read in words)
EMIS (location array in the M340 where the information to be written is stored)
GEST (Array of 4 INTs used for the Write Manager Exchange)

In this Example we are writing a value from %MW110 of the M340 to the ACC Acceleration
at Subindex 0002 (hex) and Index 2032 (hex) in the Altivar drive.

Before you can download this to you PLC there is one additional step required.
For CANopen writes to SDOs from a Write_Var block a timeout value and transmission length
need to be configured in the Write Manager Exchange array.

Open the Variable Declaration editor declare variables for the 4 INTs in the Write Manager Exchange array.
The third and fourth INTs are for the timeout value (in tenths of a second) and the transmission length (in Bytes).

In our example we are writing 1 word so the length is 2 bytes.



Finally Build/Download your project and Run the PLC.


Schneider Electric Indonesia

Explore more
Range:
Modicon M340
Explore more
Range:
Modicon M340
Users group

Discuss this topic with experts

Visit our Community for first-hand insights from experts and peers on this topic and more.