Well, I made a start and at least have some pins displaying (see attached text file). Still so much to do after a full day on this!
Not sure if this is final but the states should look like
Code:
// CiA 402 states
typedef enum {
STATE_NOT_READY_TO_SWITCH_ON,
STATE_SWITCH_ON_INHIBITED,
STATE_READY_TO_SWITCH_ON,
STATE_SWITCHED_ON,
STATE_OPERATION_ENABLED,
STATE_QUICK_STOP_ACTIVE,
STATE_FAULT_REACTION_ACTIVE,
STATE_FAULT,
STATE_HOMING
} DriveState;
I need to make sure everything is seperated into readall and writeall functions.
We rtapi_malloc structured data storage when we loadrt so I hope that will work.
The statusword structure looks something like this so the bit fields are mapped overthe status word
Code:
// CiA 402 Statusword union
typedef union {
hal_u32_t raw;
struct
{
unsigned char ready_to_switch_on :1; // 0
unsigned char switched_on :1; // 1
unsigned char operation_enabled :1; // 2
unsigned char faulted :1; // 3
unsigned char voltage_enabled :1; // 4
unsigned char quick_stop :1; // 5
unsigned char switch_on_inhibited :1; // 6
unsigned char warning :1; // 7
unsigned char manufacturer_specific1 :1; // 8
unsigned char remote_cmd :1; // 9
unsigned char target_reached :1; // 10
unsigned char internal_limit_active :1; // 11
unsigned char opmode_specific1 :1; // 12 (homing attained / target reached)
unsigned char opmode_specific2 :1; // 13 (homing error)
unsigned char manufacturer_specific2 :2; // 14-15
} bits;
} StatusWord;
When I get a bit further, I'll share via github