OSD

How to Make an SS Recorder (2/4)

Record settings

Here the following data is traced, output to files and then imported into Sysmac Studio data trace
Data to trace 16 bits, plus one each of INT, DINT, LINT, REAL and LREAL
Ring buffer capacity 65,535
Trace period 2ms

The record start flag accumulates data in the ring buffer
If left as is, the latest data keeps overwriting the ring buffer
At any time, turn the record write flag ON to write the accumulated data to a file

Step 1: Create the Ring Buffer

  • 1-1. Create the ring buffer structure

    Click the image to enlarge

  • Create the sData structure to hold the data you want to trace
    Put the Data structure into the ring buffer structure and set the array to the size needed for buffering
    The number of array elements is the buffer size

    Name Data type Description
    sRingBuffer

    Top

    UINT Add position

    Bottom

    UINT Read position

    Count

    UINT Number of stored records

    Data

    sData[65535] Buffer

    RecTime

    DATE_AND_TIME

    SamplingNo

    UINT

    Idx

    UINT

    B

    BOOL[16]

    INT16

    INT

    INT32

    DINT

    INT64

    LINT

    R

    REAL

    LR

    LREAL

  • 1-2. Copy functions from the sample

  • Copy the RingBufPut and RingbufGet functions into Functions from the ring buffer sample

Step 2: Store in the Ring Buffer

  • 2-1. Create the program

  • Turning ON the record start flag (Rec) sets the data to trace into RecData, an sData structure
    The RecData with data set is added to the ring buffer with the RingBufPut function
    Here global variables named Dummy... are used as the data to trace

  • 2-2. If an error occurs

  • If an error like 'Cannot convert from SRINGBUFFER to ST_STRING_LITERAL.' appears, open the function's variable table, delete the data type of RingBuf on the In-Out tab once, then set the sRingBuffer type again

On the next page

Output the trace data accumulated in the ring buffer to a file