ECMC: EtherCAT open source motion control.
Motion control based on the open source EtherCAT master (www.etherlab.org). The motion package is integerated into the ESS EPCIS environment (E3).
|
Misc. commands. More...
Go to the source code of this file.
Macros | |
#define | CHECK_COMMAND_LIST_RETURN_IF_ERROR(commandListIndex) |
#define | CHECK_EVENT_RETURN_IF_ERROR(indexEvent) |
#define | CHECK_STORAGE_RETURN_IF_ERROR(indexStorage) |
#define | CHECK_RECORDER_RETURN_IF_ERROR(indexRecorder) |
Functions | |
int | createEvent (int index) |
Create an event object. | |
int | linkEcEntryToEvent (int indexEvent, int eventEntryIndex, int slaveBusPosition, char *entryIDString, int bitIndex) |
Links an EtherCAT entry to an event object. . | |
int | setEventType (int indexEvent, int type) |
Set event type. . | |
int | setEventSampleTime (int indexEvent, int sampleTime) |
Set event sampling time (cycle counts). . | |
int | setEventTriggerEdge (int indexEvent, int triggerEdge) |
Set event trigger edge. . | |
int | setEventEnable (int indexEvent, int enable) |
Enable event. . | |
int | getEventEnabled (int indexEvent, int *enabled) |
Get event enabled. . | |
int | setEventEnableArmSequence (int indexEvent, int enable) |
Enable arm sequence. . | |
int | setEventEnablePrintouts (int indexEvent, int enable) |
Enable diagnostic printouts from event object. . | |
int | triggerEvent (int indexEvent) |
Force trigger event. . | |
int | armEvent (int indexEvent) |
Arm event. . | |
int | createDataStorage (int index, int elements, int bufferType) |
Create a data storage object. | |
int | clearStorage (int indexStorage) |
Clear data storage buffer. | |
int | getStorageDataIndex (int indexStorage, int *index) |
Get current index of data in storage buffer. . | |
int | setStorageEnablePrintouts (int indexStorage, int enable) |
Enable diagnostic printouts from data storage object. . | |
int | printStorageBuffer (int indexStorage) |
Print contents of buffer. . | |
int | readStorageBuffer (int indexStorage, double **data, int *size) |
Reads contents of storage buffer. . | |
int | writeStorageBuffer (int indexStorage, double *data, int size) |
Writes data to storage buffer. . | |
int | appendStorageBuffer (int indexStorage, double *data, int size) |
Appends data to the end of storage buffer. . | |
int | setDataStorageCurrentDataIndex (int indexStorage, int position) |
Set current data index of storage buffer. . | |
int | createRecorder (int indexRecorder) |
Create recorder object. | |
int | linkStorageToRecorder (int indexStorage, int indexRecorder) |
Link storage object to recorder object. | |
int | linkEcEntryToRecorder (int indexRecorder, int recorderEntryIndex, int slaveBusPosition, char *entryIDString, int bitIndex) |
Links an EtherCAT entry to a recorder object. . | |
int | linkAxisDataToRecorder (int indexRecorder, int axisIndex, int dataToStore) |
Links an axis data source to a recorder object. . | |
int | setRecorderEnable (int indexRecorder, int enable) |
Enable recorder. . | |
int | getRecorderEnabled (int indexRecorder, int *enabled) |
Get recorder enabled. . | |
int | setRecorderEnablePrintouts (int indexRecorder, int enable) |
Enable diagnostic printouts from recorder object. . | |
int | linkRecorderToEvent (int indexRecorder, int indexEvent, int consumerIndex) |
Link recorder object to event object. . | |
int | triggerRecorder (int indexRecorder) |
Force trigger recorder. . | |
int | createCommandList (int indexCommandList) |
Create a command list object. | |
int | linkCommandListToEvent (int indexCommandList, int indexEvent, int consumerIndex) |
Link command list object to event object. . | |
int | setCommandListEnable (int indexCommandList, int enable) |
Enable command list. . | |
int | setCommandListEnablePrintouts (int indexCommandList, int enable) |
Enable diagnostic printouts from command list object. . | |
int | addCommandListCommand (int indexCommandList, char *expr) |
Add command to command list. . | |
int | triggerCommandList (int indexCommandList) |
Force trigger command list. . | |
int | createShm () |
Create SHM Object. . | |
Misc. commands.
#define CHECK_COMMAND_LIST_RETURN_IF_ERROR | ( | commandListIndex | ) |
#define CHECK_EVENT_RETURN_IF_ERROR | ( | indexEvent | ) |
#define CHECK_RECORDER_RETURN_IF_ERROR | ( | indexRecorder | ) |
#define CHECK_STORAGE_RETURN_IF_ERROR | ( | indexStorage | ) |
int addCommandListCommand | ( | int | indexCommandList, |
char * | expr ) |
Add command to command list.
.
[in] | indexCommandList | Index of command list object to address. |
[in] | expr | Command string. |
int appendStorageBuffer | ( | int | indexStorage, |
double * | data, | ||
int | size ) |
Appends data to the end of storage buffer.
.
[in] | indexStorage | Index of data storage object to address. |
[in] | data | Pointer to data. |
[in] | size | Number of data elements to write. |
int armEvent | ( | int | indexEvent | ) |
Arm event.
.
Manually execute arm sequence, see command setEventEnableArmSequence().
[in] | indexEvent | Index of event to address. |
int clearStorage | ( | int | indexStorage | ) |
Clear data storage buffer.
Erases all data within a data storage object.
[in] | index | Index of data storage object to clear. |
int createCommandList | ( | int | indexCommandList | ) |
Create a command list object.
The command list object consists of a list of commands that can be executed. Currently any command can be added to the command list. The execution of the command list can be triggered by an event or by the command triggerCommandList().
[in] | index | Index of command list object to create. |
int createDataStorage | ( | int | index, |
int | elements, | ||
int | bufferType ) |
Create a data storage object.
The data storage object is a data buffer.
Currently only the recorder object utilizes the data storage object. However, it's foreseen that it will also be useful to store trajectory array data in
.
[in] | index | Index of data storage object to create. |
[in] | elements | Size of data buffer. |
[in] | bufferType | Data buffer type. bufferType = 0: Normal buffer (fill from beginning stop when full). bufferType = 1: Ring buffer (fill from beginning start over when full). bufferType = 2: FIFO buffer (fill from end. old values shifted out). |
int createEvent | ( | int | index | ) |
Create an event object.
An event can be trigger actions based on hardware related events (changes of values on the EtherCAT bus (entries)).
The events needs to be configured with atleast a subset of the below commands:
Currently two kinds of objects can be linked to an event:
[in] | index | Index of event to create. |
int createRecorder | ( | int | indexRecorder | ) |
Create recorder object.
The recorder object stores data, from an EtherCAT entry, in a data storage object. The recording of a data point can be triggered by an event or by the command triggerRecorder().
An EtherCAT data entry needs to be linked to the object with the command linkEcEntryToRecorder().
The data recorder object needs a data storage object to store data in. The data storage object needs to be linked to the recorder object with the command linkStorageToRecorder().
[in] | index | Index of recorder object to create. |
int createShm | ( | ) |
Create SHM Object.
.
Creates a shared memory object for master 2 master communication
int getEventEnabled | ( | int | indexEvent, |
int * | enabled ) |
Get event enabled.
.
Event evaluation and triggering is only active when the enable bit is high.
[in] | indexEvent | Index of event to address. |
[out] | enabled | Enabled. |
int getRecorderEnabled | ( | int | indexRecorder, |
int * | enabled ) |
Get recorder enabled.
.
Recording of data is only active when the enable bit is high.
[in] | indexRecorder | Index of recorder to address. |
[out] | enabled | Enabled. |
int getStorageDataIndex | ( | int | indexStorage, |
int * | index ) |
Get current index of data in storage buffer.
.
[in] | index | Index of data storage object to clear. |
[out] | index | Current data element index. |
int linkAxisDataToRecorder | ( | int | indexRecorder, |
int | axisIndex, | ||
int | dataToStore ) |
Links an axis data source to a recorder object.
.
[in] | indexRecorder | Index of recorder object to link to. |
[in] | axisIndex | Index of axis to get data from. |
[in] | dataToStore | data to record from axis object. dataToStore = 0 : No data choosen. dataToStore = 1 : Position Setpoint (from trajectory generator). dataToStore = 2 : Position Actual (scaled). dataToStore = 3 : Position Error. dataToStore = 4 : Position Target. dataToStore = 5 : Controller Error. dataToStore = 6 : Controller Output. dataToStore = 7 : Velocity Setpoint. dataToStore = 8 : Velocity Actual. dataToStore = 9 : Velocity Setpoint Raw. dataToStore = 10: Velocity Setpoint Feed Forward Raw. dataToStore = 11: Error Code. dataToStore = 12: Enable (command). dataToStore = 13: Enabled (status). dataToStore = 14: Execute (command). dataToStore = 15: Busy (status). dataToStore = 16: Sequence state. dataToStore = 17: At Target (status). dataToStore = 18: Interlock type. dataToStore = 19: Limit Switch forward. dataToStore = 20: Limit Switch backward. dataToStore = 21: Home switch. dataToStore = 22: Command. dataToStore = 23: Command Data (cmdData). dataToStore = 24: Trajectory setpoint source. 0 = Internal Source. >0 = External Source. dataToStore = 25: Encoder setpoint source. 0 = Internal Source. >0 = External Source. dataToStore = 26: Axis Id. dataToStore = 27: Cycle counter. dataToStore = 28: Position Raw. dataToStore = 29: Encoder homed. |
int linkCommandListToEvent | ( | int | indexCommandList, |
int | indexEvent, | ||
int | consumerIndex ) |
Link command list object to event object.
.
[in] | indexCommandList | Index of command list object to address. |
[in] | indexEvent | Index of event object to address. |
[in] | consumerIndex | Event consumer index (one event can have a list with consumers). |
int linkEcEntryToEvent | ( | int | indexEvent, |
int | eventEntryIndex, | ||
int | slaveBusPosition, | ||
char * | entryIDString, | ||
int | bitIndex ) |
Links an EtherCAT entry to an event object.
.
[in] | eventIndex | Index of event object to link to. |
[in] | eventEntryIndex | Index of event objects entry list. eventEntryIndex = 0: Event trigger data input. eventEntryIndex = 1: Arm output (to re-arm latching hardware). |
[in] | slaveBusPosition | Position of the EtherCAT slave on the bus. slaveBusPosition = -1: Used to address the simulation slave. Only two entries are configured, "ZERO" with default value 0 and "ONE" with default value 1. slaveBusPosition = 0..65535: Addressing of normal EtherCAT slaves. |
[in] | entryIdString | String for addressing purpose (see command "Cfg.EcAddEntryComplete() for more information"). |
[in] | entryBitIndex | Bit index of EtherCAT entry to use. entryBitIndex = -1: All bits of the entry will be used. entryBitIndex = 0..64: Only the selected bit will be used. |
int linkEcEntryToRecorder | ( | int | indexRecorder, |
int | recorderEntryIndex, | ||
int | slaveBusPosition, | ||
char * | entryIDString, | ||
int | bitIndex ) |
Links an EtherCAT entry to a recorder object.
.
[in] | indexRecorder | Index of recorder object to link to. |
[in] | recorderEntryIndex | Index of recorder objects entry list. recorderEntryIndex = 0: data input. |
[in] | slaveBusPosition | Position of the EtherCAT slave on the bus. slaveBusPosition = -1: Used to address the simulation slave. Only two entries are configured, "ZERO" with default value 0 and "ONE" with default value 1. slaveBusPosition = 0..65535: Addressing of normal EtherCAT slaves. |
[in] | entryIdString | String for addressing purpose (see command "Cfg.EcAddEntryComplete() for more information"). |
[in] | entryBitIndex | Bit index of EtherCAT entry to use. entryBitIndex = -1: All bits of the entry will be used. entryBitIndex = 0..64: Only the selected bit will be used. |
int linkRecorderToEvent | ( | int | indexRecorder, |
int | indexEvent, | ||
int | consumerIndex ) |
Link recorder object to event object.
.
[in] | indexRecorder | Index of recorder object to address. |
[in] | indexEvent | Index of event object to address. |
[in] | consumerIndex | Event consumer index (one event can have a list with consumers). |
int linkStorageToRecorder | ( | int | indexStorage, |
int | indexRecorder ) |
Link storage object to recorder object.
[in] | indexStorage | Index of storage object. |
[in] | indexRecorder | Index of recorder object. |
int printStorageBuffer | ( | int | indexStorage | ) |
Print contents of buffer.
.
[in] | indexStroage | Index of data storage object to address. |
int readStorageBuffer | ( | int | indexStorage, |
double ** | data, | ||
int * | size ) |
Reads contents of storage buffer.
.
[in] | indexStorage | Index of data storage object to address. |
[out] | data | Pointer to data. |
[out] | size | Number of data elements. |
int setCommandListEnable | ( | int | indexCommandList, |
int | enable ) |
Enable command list.
.
Command list will only be executed when the enable bit is high.
[in] | indexCommandList | Index of command list to address. |
[in] | enable | Enable. |
int setCommandListEnablePrintouts | ( | int | indexCommandList, |
int | enable ) |
Enable diagnostic printouts from command list object.
.
[in] | indexCommandList | Index of command list object to address. |
[in] | enable | Enable diagnostic printouts. |
int setDataStorageCurrentDataIndex | ( | int | indexStorage, |
int | position ) |
Set current data index of storage buffer.
.
This function can be used to set teh current index of a data storage buffer. A subsequent append of data will start at this position index in the buffer array.
[in] | indexStorage | Index of data storage object to address. |
[in] | position | Position index of data. |
int setEventEnable | ( | int | indexEvent, |
int | enable ) |
Enable event.
.
Event evaluation and triggering is only active when the enable bit is high.
[in] | indexEvent | Index of event to address. |
[in] | enable | Enable. |
int setEventEnableArmSequence | ( | int | indexEvent, |
int | enable ) |
Enable arm sequence.
.
Some hardware require that the input card is re-armed after each value have been collected (typically latched I/O). The arm sequence will, if enabled, write a 0 followed by a 1 the following cycle to the arm output entry, see command linkEcEntryToEvent().
[in] | indexEvent | Index of event to address. |
[in] | enable | Enable arm sequence. |
int setEventEnablePrintouts | ( | int | indexEvent, |
int | enable ) |
Enable diagnostic printouts from event object.
.
[in] | indexEvent | Index of event to address. |
[in] | enable | Enable diagnostic printouts. |
int setEventSampleTime | ( | int | indexEvent, |
int | sampleTime ) |
Set event sampling time (cycle counts).
.
Sets the sample rate at which events will be triggered.
Note: This parameter is only valid for sample rate triggered event type (type = 0), see setEventType().
[in] | indexEvent | Index of event to address. |
[in] | type | Type of event. type = 0: Sample rate triggered (see setEventSampleTime()). type = 1: Trigger on data source edge (see setEventTriggerEdge()). |
int setEventTriggerEdge | ( | int | indexEvent, |
int | triggerEdge ) |
Set event trigger edge.
.
[in] | indexEvent | Index of event to address. |
[in] | triggerEdge | Type of event. triggerEdge = 0: Trigger event on positive edge. triggerEdge = 1: Trigger event on negative edge. triggerEdge = 2: Trigger event on on change. |
int setEventType | ( | int | indexEvent, |
int | type ) |
Set event type.
.
[in] | indexEvent | Index of event to address. |
[in] | type | Type of event. type = 0: Sample rate triggered (see setEventSampleTime()). type = 1: Trigger on data source edge (see setEventTriggerEdge()). |
int setRecorderEnable | ( | int | indexRecorder, |
int | enable ) |
Enable recorder.
.
Recording of data is only active when the enable bit is high.
[in] | indexRecorder | Index of recorder to address. |
[in] | enable | Enable. |
int setRecorderEnablePrintouts | ( | int | indexRecorder, |
int | enable ) |
Enable diagnostic printouts from recorder object.
.
[in] | indexRecorder | Index of recorder object to address. |
[in] | enable | Enable diagnostic printouts. |
int setStorageEnablePrintouts | ( | int | indexStorage, |
int | enable ) |
Enable diagnostic printouts from data storage object.
.
[in] | indexStroage | Index of data storage object to address. |
[in] | enable | Enable diagnostic printouts. |
int triggerCommandList | ( | int | indexCommandList | ) |
Force trigger command list.
.
All commands in the command list object will be executed.
[in] | indexCommandList | Index of command list to address. |
int triggerEvent | ( | int | indexEvent | ) |
Force trigger event.
.
Any subscriber functions to an event will be executed.
[in] | indexEvent | Index of event to address. |
int triggerRecorder | ( | int | indexRecorder | ) |
Force trigger recorder.
.
The recorder object will store data in the linked data storage object.
[in] | indexRecorder | Index of recorder to address. |
int writeStorageBuffer | ( | int | indexStorage, |
double * | data, | ||
int | size ) |
Writes data to storage buffer.
.
[in] | indexStorage | Index of data storage object to address. |
[in] | data | Pointer to data. |
[in] | size | Number of data elements to write. |