This is an old revision of the document!
CANopen Receive
This block receives PDO packets over a CAN bus from a drive. 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, see CANopen Send.
Data Transfer
Each time the block is run by its time domain, it reads as many TPDOs sent by its connected drives as has been configured beforehand. Each TPDO 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 receive the TPDO exactly as your drive sends it. The CANopen Receive block has several outputs as shown below.
Each drive has its own node id and its specific input index (0 to N-1). 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. Both signals can be vectors. 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 0, idx=2 takes the floating point signal at index 1, idx=0 takes the control word and idx=-1 takes the integer signal at index 0. How could this be used? Let us assume, that the drive with node id = 37 should receive a RPDO1 with control word and velocity setpoint and RPDO2 with digital output word (steering some enable pins or leds). Let's further assume that the floating point input signal is a vector consisting of position setpoint and velocity setpoint. The configuration would then be
configureRPDO(37, RPDO1, {controlObj, velModeSetValObj}, {0,1}); configureRPDO(37, RPDO2, {digOutStateObj}, {-1});
The control word has no input but can be set by the method
setCtrl(uint8_t index, uint16_t ctrl>);
The floating point input signals expect signals 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
setScale(Matrix<N,M,double>);
This blocks uses the CANopen Library. Make sure to install this library following https://wiki.eeros.org/getting_started/install_wrapper#canopen.