Newer
Older
# Demo Programs
The following programs show the use of this canopen library. For all three programs we use the setup as shown in the picture below.
The demo programs run on a x86 machine, which is connected through a PEAK CAN adapter to the CAN bus. Two different Maxon drives sit on the CAN bus.
- EPOS2 module 36/2, nodeId=2, no termination
- EPOS module 24/4, nodeId=1, with 12 0Ohm termination
Both module are equipped with a small motor with gear and encoder as well as some digital buttons and leds.
Make sure to select the right node identifiers with the dip switches. The last drive in the chain has to terminate the bus.
<img src="pic2.png" alt="[Switch Setting First Node" width="300"/><img src="pic3.png" alt="[Switch Setting Last Node" width="300"/>
## Demo 1
The master configures RPDOs and TPDOs on the two drives and selects velocity mode for both of them. While doing this, the drives must be in network management pre-operational mode. The drives themselves follow a state machine as defined in DS402 profile specification. They start up being in _Switched On Disabled_ state. Next, they are brought into _Operation Enable_ state. Now, the network management state will be switched to operational mode where no further SDO transfers should happen but only PDOs are transmitted or received. Both motors will turn slowly and their positions are printed out once per second. In case of an error, e.g. when the supply voltage is too low, one or both drives change their status, which is transmitted in its TPDO. The master will then switch into network management pre-operational mode and the error condition can be queried by SDO transfer.
In our example we configure TPDO1 of both drives that they transmit as follows
- status word, 2 bytes
- state of digital inputs, 2 bytes
- actual motor position, 4 bytes
TPDO2 to TPDO4 are disabled. Further, both drives receive RPDO1 with
- control word, 2 bytes
- velocity setpoint, 4 bytes
## Demo 2
The identity object is read from both drives through SDO transfers. This includes vendor id, product code, revision and serial number. This information is necessary for changing the node id of a drive with LSS as shown in demo3.
Layer settings services allow to change the node id of a drive on the fly. Beware that our Maxon drive with node id = 1 as shown above in the experimental setup does not support LSS. Therefore, this demo only changes the node id of the second drive.
The Maxon drive with node id = 2 is the one we want to change this node id. For this purpose, you have to change the dip switches to all zero. Now, the demo changes to whatever node id is set in the program and permanently stored in the memory.