Drive profile (CiA 402) on a CANopen node.
More...
|
| enum | pbl_cia402_mode {
PBL_CIA402_MODE_NONE = 0
, PBL_CIA402_MODE_PROFILE_POSITION = 1
, PBL_CIA402_MODE_PROFILE_VELOCITY = 3
, PBL_CIA402_MODE_PROFILE_TORQUE = 4
,
PBL_CIA402_MODE_CYCLIC_POSITION = 8
, PBL_CIA402_MODE_CYCLIC_VELOCITY = 9
, PBL_CIA402_MODE_CYCLIC_TORQUE = 10
} |
| | Modes of operation. More...
|
| |
| enum | pbl_cia402_state {
PBL_CIA402_NOT_READY_TO_SWITCH_ON
, PBL_CIA402_SWITCH_ON_DISABLED
, PBL_CIA402_READY_TO_SWITCH_ON
, PBL_CIA402_SWITCHED_ON
,
PBL_CIA402_OPERATION_ENABLED
, PBL_CIA402_QUICK_STOP_ACTIVE
, PBL_CIA402_FAULT_REACTION_ACTIVE
, PBL_CIA402_FAULT
} |
| | States of the drive. More...
|
| |
|
| int | pbl_cia402_init (struct pbl_cia402 *drive, struct pbl_canopen *co, const struct pbl_cia402_ops *ops, void *arg) |
| | Attach a drive to a node, initialized and not started, in switch on disabled.
|
| |
| enum pbl_cia402_state | pbl_cia402_state (struct pbl_cia402 *drive) |
| | Get the state of a drive.
|
| |
| enum pbl_cia402_mode | pbl_cia402_mode (struct pbl_cia402 *drive) |
| | Get the mode of operation of a drive.
|
| |
| int | pbl_cia402_fault (struct pbl_cia402 *drive, uint16_t code) |
| | Report a fault: the drive goes to fault reaction active, sets the error code (0x603f) and raises an emergency.
|
| |
| void | pbl_cia402_fault_reaction_done (struct pbl_cia402 *drive) |
| | End the fault reaction: the drive goes to fault, until the master resets it.
|
| |
| void | pbl_cia402_quick_stop_done (struct pbl_cia402 *drive) |
| | End a quick stop: the drive goes to switch on disabled, or stays in quick stop active with quick stop option codes 5 to 8.
|
| |
| void | pbl_cia402_set_status (struct pbl_cia402 *drive, uint16_t mask, uint16_t bits) |
| | Set statusword bits the application owns, PBL_CIA402_SW_* ones.
|
| |
Drive profile (CiA 402) on a CANopen node.
A drive runs the CiA 402 state machine of a node whose object dictionary has a cia402 section: the controlword (0x6040) the master writes moves it from state to state, and the statusword (0x6041) reports it. The application drives the motor from its callbacks, all called with the node locked:
static int prv_enable(
struct pbl_cia402 *drive,
void *arg) {
motor_enable();
return 0;
}
A drive.
Definition cia402.h:124
int pbl_cia402_init(struct pbl_cia402 *drive, struct pbl_canopen *co, const struct pbl_cia402_ops *ops, void *arg)
Attach a drive to a node, initialized and not started, in switch on disabled.
int pbl_canopen_init(struct pbl_canopen *co, const struct pbl_canopen_config *cfg)
Initialize a node, stopped.
int pbl_canopen_start(struct pbl_canopen *co)
Start the node: join the bus, restore every default and go pre-operational.
Drive callbacks, each optional.
Definition cia402.h:97
int(* enable)(struct pbl_cia402 *drive, void *arg)
Enable the motor, to follow its targets.
Definition cia402.h:103
The motor follows its targets, e.g. 0x607a or 0x60ff, while the drive is operation enabled. The functions lock the node, so they are called from a thread or a callback, never an interrupt.
◆ pbl_cia402
◆ PBL_CIA402_CONTROLWORD
| #define PBL_CIA402_CONTROLWORD 0x6040U |
◆ PBL_CIA402_MODES_OF_OPERATION
| #define PBL_CIA402_MODES_OF_OPERATION 0x6060U |
◆ PBL_CIA402_MODES_OF_OPERATION_DISPLAY
| #define PBL_CIA402_MODES_OF_OPERATION_DISPLAY 0x6061U |
Modes of operation display.
◆ PBL_CIA402_STATUSWORD
| #define PBL_CIA402_STATUSWORD 0x6041U |
◆ PBL_CIA402_SW_INTERNAL_LIMIT
| #define PBL_CIA402_SW_INTERNAL_LIMIT PBL_BIT(11) |
◆ PBL_CIA402_SW_MANUFACTURER
Manufacturer specific bits.
◆ PBL_CIA402_SW_MODE_SPECIFIC
Operation mode specific bits.
◆ PBL_CIA402_SW_TARGET_REACHED
| #define PBL_CIA402_SW_TARGET_REACHED PBL_BIT(10) |
◆ PBL_CIA402_SW_WARNING
| #define PBL_CIA402_SW_WARNING PBL_BIT(7) |
◆ pbl_cia402_mode
Modes of operation.
| Enumerator |
|---|
| PBL_CIA402_MODE_NONE | |
| PBL_CIA402_MODE_PROFILE_POSITION | |
| PBL_CIA402_MODE_PROFILE_VELOCITY | |
| PBL_CIA402_MODE_PROFILE_TORQUE | |
| PBL_CIA402_MODE_CYCLIC_POSITION | |
| PBL_CIA402_MODE_CYCLIC_VELOCITY | |
| PBL_CIA402_MODE_CYCLIC_TORQUE | |
◆ pbl_cia402_state
States of the drive.
| Enumerator |
|---|
| PBL_CIA402_NOT_READY_TO_SWITCH_ON | |
| PBL_CIA402_SWITCH_ON_DISABLED | |
| PBL_CIA402_READY_TO_SWITCH_ON | |
| PBL_CIA402_SWITCHED_ON | |
| PBL_CIA402_OPERATION_ENABLED | |
| PBL_CIA402_QUICK_STOP_ACTIVE | |
| PBL_CIA402_FAULT_REACTION_ACTIVE | |
| PBL_CIA402_FAULT | |
◆ pbl_cia402_fault()
| int pbl_cia402_fault |
( |
struct pbl_cia402 * |
drive, |
|
|
uint16_t |
code |
|
) |
| |
Report a fault: the drive goes to fault reaction active, sets the error code (0x603f) and raises an emergency.
- Parameters
-
| drive | Drive. |
| code | Error code, e.g. 0x2310 for a continuous over-current. |
- Returns
- 0, or
-EALREADY if the drive is in fault.
◆ pbl_cia402_fault_reaction_done()
| void pbl_cia402_fault_reaction_done |
( |
struct pbl_cia402 * |
drive | ) |
|
End the fault reaction: the drive goes to fault, until the master resets it.
- Parameters
-
◆ pbl_cia402_init()
| int pbl_cia402_init |
( |
struct pbl_cia402 * |
drive, |
|
|
struct pbl_canopen * |
co, |
|
|
const struct pbl_cia402_ops * |
ops, |
|
|
void * |
arg |
|
) |
| |
Attach a drive to a node, initialized and not started, in switch on disabled.
- Parameters
-
| drive | Drive. |
| co | Node. |
| ops | Callbacks, or NULL. |
| arg | Callback argument. |
- Returns
- 0, or
-ENOENT if the node's object dictionary has no drive.
◆ pbl_cia402_mode()
Get the mode of operation of a drive.
- Parameters
-
- Returns
- Mode, as the modes of operation display (0x6061) shows it.
◆ pbl_cia402_quick_stop_done()
| void pbl_cia402_quick_stop_done |
( |
struct pbl_cia402 * |
drive | ) |
|
End a quick stop: the drive goes to switch on disabled, or stays in quick stop active with quick stop option codes 5 to 8.
- Parameters
-
◆ pbl_cia402_set_status()
| void pbl_cia402_set_status |
( |
struct pbl_cia402 * |
drive, |
|
|
uint16_t |
mask, |
|
|
uint16_t |
bits |
|
) |
| |
Set statusword bits the application owns, PBL_CIA402_SW_* ones.
- Parameters
-
| drive | Drive. |
| mask | Bits to change. |
| bits | Their values. |
◆ pbl_cia402_state()
Get the state of a drive.
- Parameters
-
- Returns
- State.