Ring buffer
What Is a Ring Buffer?
A buffer is a storage area that temporarily holds information to absorb and adjust timing differences when communicating with storage devices (such as SD cards) or external devices
This sample introduces a ring buffer (Function Block) that can be used in Sysmac Studio for the OMRON NX/NJ series.
A ring buffer is a typical data structure used for logging, traceability, temporary storage of communication data and more.
Ring buffer example
A ring buffer works as shown above: you can see data being stored into and taken out of 12 buffers
The Top position is the write pointer and Bottom is the read pointer; orange indicates that data is stored
Each data area uses a structure, and the ring buffer is made as an array of structures
Example structure
The ring buffer structure looks like this:
RingBuffer
|
+- Top
+- Bottom
+- Count
+- Data[] (array of any data type)
Data can also be a structure.
Symbols
RingBufPut
FB that stores data in the ring buffer

- RingBuf
- Ring buffer structure
- Data
- Data to buffer
RingBufGet
FB that takes data out of the ring buffer

- RingBuf
- Ring buffer structure
- Data
- Retrieved data
Example
Structures
- sData, sRingBuffer

Ladder logic
-
The buffered data is the contents of structure sData: a duration (Time), 10 bits of data (B) and 10 DINTs (DI) are buffered as one data item
The ring buffer size is 1000, as specified by sRingBuffer.Data
When the PutTrigger contact turns ON, the contents of PutData are stored in RingBuffer
When the GetTrigger contact turns ON, data is taken from RingBuffer and put into GetData
Source
FAQ
What is a ring buffer?
A ring buffer is a data structure that reuses a fixed-length memory area in a circular manner.
What is a ring buffer used for in PLCs?
For logging and temporary storage of communication data.

