This is an old revision of the document!
CANopen Send
This block sends PDO packets over a CAN bus to one or several drives. The drives itself must be initialized by SDO transfers and brought into operational state where PDO transfer is possible. The control system must incorporate a block for sending and another one for receiving CAN messages.
The block for sending will periodically (given by its time domain) send a synq
message followed by several PDO's. It is important that this block is run after the block for receiving CAN messages. This ensures that the drives can send their messages upon receiving the synq
message and the receive block already has these messages in its receive buffer and does not block when running.
Data Transfer
Each time the block is run by its time domain, a sync
message is sent followed by one or several RPDOs to all connected nodes. Each PDO carries one or more CANopen objects. See https://gitlab.ost.ch/tech/inf/public/canopenlib/-/blob/master/demo/demo.md#demo-1 for the configuration of the PDOs. Make sure, that you send the RPDO exactly as your drive expects it. The CANopen Send block has several inputs as shown below.
After the block has been created you have to configure the PDOs which are sent to each drive. While doing this you must specify which of the signal inputs (floating point or fixed point) get included into which PDO. The method
configureRPDO(uint8_t nodeId, uint8_t RPDOnr, std::vector<coObject_t> objs, std::vector<int8_t> idx))
includes a vector of all CANopen objects which are mapped into this RPDO together with a corresponding vector of indices. These indices determine which signal is taken for this RPDO. To give an example: idx=1 takes the floating point signal at index 1, idx=1 takes the floating point signal at index 1
and RPDO2 (velocity). While the control word can be set by the method
setCtrl(Matrix<nofNodes,1,uint16_t>);
the velocity is taken from its input vel
.
The velocity input expects a signal in SI units, e.g. rad/s. To account for encoder resolution of the actual drive together with a gearbox, it is possible to set a scaling factor with
setVelScale(Matrix<nofNodes,1,double>);
This blocks uses the CANopen Library. Make sure to install this library following https://wiki.eeros.org/getting_started/install_wrapper#canopen.