CANopenNode
CANopen protocol stack
Loading...
Searching...
No Matches

CANopen trace object for recording variables over time. More...

+ Collaboration diagram for Trace:

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.
 
void CO_trace_process (CO_trace_t *trace, uint32_t timestamp)
 Process trace object.
 

Detailed Description

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.

Function Documentation

◆ CO_trace_init()

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.

Parameters
traceThis object will be initialized.
SDOSDO server object.
enabledIs trace enabled.
timeBufferMemory block for storing time records.
valueBufferMemory block for storing value records.
bufferSizeSize of the above buffers.
mapMap to variable in Object Dictionary, which will be monitored. Same structure as in PDO.
formatFormat of the plot. If first bit is 1, above variable is unsigned. For more info see Object Dictionary.
triggerIf different than zero, trigger time is recorded, when variable goes through threshold.
thresholdUsed with trigger.
valuePointer to variable, which will show last value of the variable.
minValuePointer to variable, which will show minimum value of the variable.
maxValuePointer to variable, which will show maximum value of the variable.
triggerTimePointer to variable, which will show last trigger time of the variable.
idx_OD_traceConfigIndex in Object Dictionary.
idx_OD_traceIndex in Object Dictionary.

◆ CO_trace_process()

void CO_trace_process ( CO_trace_t * trace,
uint32_t timestamp )

Process trace object.

Function must be called cyclically in 1ms intervals.

Parameters
traceThis object.
timestampTimestamp (usually in millisecond resolution).