Files | |
file | CO_trace.h |
CANopen trace object for recording variables over time. | |
Data Structures | |
struct | CO_trace_dataType_t |
structure for reading variables and printing points for specific data type. More... | |
struct | CO_trace_t |
Trace object. More... | |
Macros | |
#define | OD_INDEX_TRACE_CONFIG 0x2301 |
Start index of traceConfig and Trace objects in Object Dictionary. | |
Functions | |
void | CO_trace_init (CO_trace_t *trace, CO_SDO_t *SDO, uint8_t enabled, uint32_t *timeBuffer, int32_t *valueBuffer, uint32_t bufferSize, uint32_t *map, uint8_t *format, uint8_t *trigger, int32_t *threshold, int32_t *value, int32_t *minValue, int32_t *maxValue, uint32_t *triggerTime, uint16_t idx_OD_traceConfig, uint16_t idx_OD_trace) |
Initialize trace object. More... | |
void | CO_trace_process (CO_trace_t *trace, uint32_t timestamp) |
Process trace object. More... | |
CANopen trace object for recording variables over time.
In embedded systems there is often a need to monitor some variables over time. Results are then displayed on graph, similar as in oscilloscope.
CANopen trace is a configurable object, accessible via CANopen Object Dictionary, which records chosen variable over time. It generates a curve, which can be read via SDO and can then be displayed in a graph.
CO_trace_process() runs in 1 ms intervals and monitors one variable. If it changes, it makes a record with timestamp into circular buffer. When trace is accessed by CANopen SDO object, it reads latest points from the the circular buffer, prints a SVG curve into string and sends it as a SDO response. If a SDO request was received from the same device, then no traffic occupies CAN network.
void CO_trace_init | ( | CO_trace_t * | trace, |
CO_SDO_t * | SDO, | ||
uint8_t | enabled, | ||
uint32_t * | timeBuffer, | ||
int32_t * | valueBuffer, | ||
uint32_t | bufferSize, | ||
uint32_t * | map, | ||
uint8_t * | format, | ||
uint8_t * | trigger, | ||
int32_t * | threshold, | ||
int32_t * | value, | ||
int32_t * | minValue, | ||
int32_t * | maxValue, | ||
uint32_t * | triggerTime, | ||
uint16_t | idx_OD_traceConfig, | ||
uint16_t | idx_OD_trace | ||
) |
Initialize trace object.
Function must be called in the communication reset section.
trace | This object will be initialized. |
SDO | SDO server object. |
enabled | Is trace enabled. |
timeBuffer | Memory block for storing time records. |
valueBuffer | Memory block for storing value records. |
bufferSize | Size of the above buffers. |
map | Map to variable in Object Dictionary, which will be monitored. Same structure as in PDO. |
format | Format of the plot. If first bit is 1, above variable is unsigned. For more info see Object Dictionary. |
trigger | If different than zero, trigger time is recorded, when variable goes through threshold. |
threshold | Used with trigger. |
value | Pointer to variable, which will show last value of the variable. |
minValue | Pointer to variable, which will show minimum value of the variable. |
maxValue | Pointer to variable, which will show maximum value of the variable. |
triggerTime | Pointer to variable, which will show last trigger time of the variable. |
idx_OD_traceConfig | Index in Object Dictionary. |
idx_OD_trace | Index in Object Dictionary. |
void CO_trace_process | ( | CO_trace_t * | trace, |
uint32_t | timestamp | ||
) |
Process trace object.
Function must be called cyclically in 1ms intervals.
trace | This object. |
timestamp | Timestamp (usually in millisecond resolution). |