Simulating Devices
6 minute read
Motorcortex enables the user to run an application in Simulation
or Production
(see config.json); but even in Production
it is possible to (partially) simulate the behavior of EtherCAT Devices. In Production
, individual EtherCAT Domains can be set to “Simulation” which means that their signals can be linked to a software module that simulated the device’s behavior.
If the application is started in Simulation
mode all EtherCAT devices are in Simulation Mode, and Links that are marked with “Simulation” are enabled. In Production
Mode any EtherCAT Domain that is set to Simulation puts its Devices into Simulation Mode; this allows using the software with some real devices and some simulated Devices.
When a device is in Simulation it re-wires its links so the data sent towards the device can be forwarded to a Simulator software Module that simulates the behavior of the Device. In the same manner, the data received from the Device is actually obtained from the linked Simulator software Module.
A visualization of how signals are linked in the Robot Application
is given below, the arrows point in the direction of the flow of information. As you can see in figure below, the data always goes through simulated etherCAT device, so the main application code does not know the difference between a simulated Device and a Real one.
How to switch between different system modes is explained in the following:
The main purpose of using simulation
mode is to create a application without having your physical hardware connected, for this the following tasks are required:
- Enable simulation mode in config.json
- Set simulation parameters inside linking.json
- Add simulated ECAT-devices inside ECAT-Tool
- Link simulated ECAT-device parameters to motorcortex parameters
Note
For simulation, it can be that some safety parameters need to be overwritten like a physical E-stop button, this is done by set parameter inside linking.json.
The next steps will explain you in detail how to set up your application in simulation mode:
-
Inside config.json, set system mode to
Simulation
. -
In simulation mode, linking with systemMode:
"Simulation",
and"All",
are applied and can be adjusted in the xxx.link.json. -
In the Domain Configuration Panel you can enable the
Simulation
switch, but this is not necessary because the system is inSimulation mode
. Simulation of a domain is only required inproduction
mode, for example if you want tosimulate
one or multiple etherCAT devices. -
Each
domain
can contain multipleetherCAT devices
. In order to simulate the device PDO’s, you have to assign a simulation link to each simulated etherCAT device, so motorcortex knows that the device is included to the simulator. TheLink Simulation
should be assigned to the following path:root/DriveLogic/driveSimulation
.Note
Beware to assign the correct channel to the devices, linking of multiple devices to the same channel will result in improper simulated etherCAT devices!
-
EtherCAT devices contain
rxPDO
andtxPDO
parameters that can be linked to a path, for simulation use:root/Simulator/...
. For example target position should be linked toroot/Simulator/targetPosition
,channel 0
because this is linked to the first axis.Press
simulation switch
theblue
, this means that the link is only used if the system is in simulation mode! -
Step 5 can also be used for all
root/Simulator/...
parameters:
PDOmapping: | Description: | Link to Motorcortex Parameter: |
---|---|---|
rxPDO | ||
0x607A | Target Position | root/Simulator/targetPosition |
0x60B2 | Target Offset | root/Simulator/targetTorqueOffset |
0x6071 | Target Torque | root/Simulator/targetTorque |
txPDO | ||
0x6064 | Position Actual Value | root/Simulator/positionValue |
0x6077 | Torque Actual Value | root/Simulator/torqueValue |
For parameters in an array like root/Simulator/targetPosition
you need to define the index, starting at 0 till 5, respectively for axis 1 till 6.
After linking the PDO entries you are able to run the application in simulation mode.
The main purpose of using production
mode is to test you application on your physical hardware, for this the following tasks are required:
- Enable production mode in config.json
- Set production parameters inside linking.json
- Add ECAT-devices inside ECAT-Tool
- Link ECAT-device parameters to motorcortex parameters
The next steps will explain you in detail, how to set up your application in production mode:
-
Inside config.json, change system mode to
Production
. -
In production mode, linking with systemMode:
"Production",
and"All",
are applied and can be adjusted in the xxx.link.json. -
In the Domain Configuration Panel the
Simulation
switch should be disabled. -
Each
domain
can contain multipleetherCAT devices
. The link simulation should be empty because, the system is inproduction
mode. -
EtherCAT devices contain
rxPDO
andtxPDO
parameters which should be linked to motorcortex parameters. -
Perform
step 5
for all PDO Mappings.
PDOmapping: | Description: | Link to Motorcortex Parameter: |
---|---|---|
rxPDO | ||
0x6040 | Control Word | root/DriveLogic/driveControlWord |
0x6060 | Modes of Operation | root/DriveLogic/driveOpMode |
0x607A | Target Position | root/AxesControl/actuatorControlLoops/actuatorControlLoop0X /motorPositionTarget |
0x60FF | Target Velocity | root/AxesControl/actuatorControlLoops/actuatorControlLoop0X /motorVelocityTarget |
0x60B2 | Torque Offset | root/AxesControl/actuatorControlLoops/actuatorControlLoop0X /motorTorqueOffsetTarget |
0x6071 | Target Torque | root/AxesControl/actuatorControlLoops/actuatorControlLoop0X /motorTorqueTarget |
txPDO | ||
0x6041 | Status Word | root/DriveLogic/driveStatusWord |
0x6064 | Position Actual Value | root/AxesControl/actuatorControlLoops/actuatorControlLoop0X /motorPositionActual |
0x606C | Velocity Actual Value | root/AxesControl/actuatorControlLoops/actuatorControlLoop0X /motorVelocityActual |
0x6077 | Torque Actual Value | root/AxesControl/actuatorControlLoops/actuatorControlLoop0X /motorTorqueActual |
0x2A00 | TorqueSensor Actual Value | root/AxesControl/actuatorControlLoops/actuatorControlLoop0X /sensorTorqueActual |
The X
in actuatorControlLoop0X
can have a value from 1 till 6 (actuatorControlLoop01 till actuatorControlLoop06) respectively for axis 1 till 6. For parameters in an array like root/DriveLogic/driveControlWord
you need to define the index, starting at 0 till 5, respectively for axis 1 till 6.
After linking the PDO entries you are able to run the application in production mode.
Older Version:
The main purpose of using Simulation
in Production
mode is to partially test you application on physical hardware, for this the following tasks are required:
- Enable production mode in config.json
- Set production parameters inside linking.json
- Add (simulated) ECAT-devices inside ECAT-Tool
- Link (simulated) ECAT-device parameters to motorcortex parameters
The next steps will explain you in detail, how to set up your application in production mode with multiple devices simulated:
-
Inside config.json, change system mode to
Production
. -
In production mode, linking with systemMode:
"Production",
and"All",
are applied and can be adjusted in the xxx.link.json. -
In the Domain Configuration Panel you can create two kind of domains one for
simulated devices
and the other forreal devices
check outsimulation tab
andproduction tab
how to establish each domain. -
Each
domain
can contain multipleetherCAT devices
. Forproduction
The link simulation should be empty, as forsimulation
check outsimulation tab
how to set up link simulation. -
EtherCAT devices contain
rxPDO
andtxPDO
parameters each can be linked to user defined path. Check outproduction tab
andsimulation tab
how to establish each link.
Now you are able to run your application in production mode with partially simulated etherCAT devices.