We made custom error codes for this model, represented by the Error Code
variable.
The isError
variable detects if any of the variables are 1
, and if so, also is equal to 1
.
The errors are calculated using a 16-bit representation where each bit represents a specific check in the system. If a check fails, the corresponding bit is set to ‘1’, otherwise, it remains ‘0’. The error code can be interpreted by decoding the binary value.
The Error Code
is calculated as:
(Error Code = Error Type * 2^8 + Specific Error
)
Here, Error Type
is a numeric value representing the type of check, and Specific Error
is the bitwise representation of the checks within that type.
Underneath, each error type and corresponding error code is explained.
Position Redundancy Check
Error Type: 0 (Shifted by 0 bits)
Bit1: Position redundancy check Hips - RA
Bit2: Position redundancy check Hips - RI
Bit3: Position redundancy check Hips - LI
Bit4: Position redundancy check Hips - LA
Bit5: Position redundancy check Knees - Right
Bit6: Position redundancy check Knees - Left
Bit7: Position redundancy check BWS
Bit8: Position redundancy check Pelvis
Position Limit Check
Error Type: 1 (Shifted by 8 bits)
Bit1: Position limits check Hips - RA
Bit2: Position limits check Hips - RI
Bit3: Position limits check Hips - LI
Bit4: Position limits check Hips - LA
Bit5: Position limits check Knees - Right
Bit6: Position limits check Knees - Left
Bit7: Position limits check BWS
Bit8: Position limits check Pelvis
By decoding the error code to binary (dec2bin
, or use programmer calculator in Windows), one can easily identify the failing checks based on which bits are set to ‘1’.
With a larger model it makes sense to set some conventions for the way signals etc are named. These are as follows:
Scope Manager
camelCase
notation where
enable
or pos
Knee
R
and L
.Acronyms should be all capitals, e.g.
BWS
.
Tags: use PascalCase
Parameters: use snake_case
, but keep acronyms as capitals. E.g. RI_pot_offset
R
- Right
L
- Left
rot
- rotation
pos
- position
ang
- angular
vel
- velocity
acc
- acceleration
pot
- potentiometer
avg
- average
filt
- Filtered
There are several control modes defined in the state machine of the model. These are listed below for easy reference:
Positive axes are defined as (from perspective of patient in lokomat):
(0,0,0)
is the point in the center and at the front of the MUCDA plate.
The model has different colors for the background of blocks to indicate how it should be used:
Contains the state machine and all the enable booleans used to enable/disable actuators seperately.
Contains the main blocks that make EtherCAT work in Simulink.
Has the EtherCAT init block where the ENI file is selected. Outputs are sent to an xPC scope.
All the signals come in here. Can be uncommented and sent to scope for easier debugging etc.
Here the main safety checks are done. The error codes are generated here.
Checks done:
Blocks for UDP communication. Currently only used for the treadmill speed.