« Close

Datasheets and User Guides

App Notes

Software & Driver

 

3.1.1 Buffer Registers

Most registers are written / read by address, but other registers are a special kind of register known as a Buffer Register. Buffer Registers are for cases when multiple values must be written / read, but the number of values are able to change. Buffer Registers produce multiple values when being read from and consume all values being written. Buffer registers allow users to write a sequence of values to a single Modbus address. Typically buffer registers have a companion _SIZE register that defines how many sequential values are about to be sent to or read from a buffer register. Some would call them array registers, because you basically define the array size, and then pass the array of data into a single Modbus address.

For example, consider the difference between AIN0 and FILE_IO_PATH_READ:

Normal register
  • AIN0 is at address 0 and is followed by AIN1 at address 2
  • AIN0 is a normal register
  • Reading an array of 4 registers starting at address 0 would read 2 registers from AIN0 and 2 registers AIN1 (AIN values are FLOAT32, which each consist of 2 registers)
Buffer register
  • FILE_IO_PATH_READ is at address 60652 and is followed by FILE_IO_WRITE at address 60654
  • FILE_IO_PATH_READ is a Buffer Register
  • Reading an array of 4 registers starting at address 60652 would read 4 registers from FILE_IO_PATH_READ. FILE_IO_WRITE would not be read.
  • Note that users would first designate that 8 bytes are about to be read by writing a value of 8 to FILE_IO_PATH_READ_LEN_BYTES.

In practice, the important differences are:

  1. You don't need to know what registers follow a Buffer Register, you can simply write / read without worrying about colliding with other registers
  2. You can only write / read values sequentially. E.g. you cannot modify previously written values.
  3. Define how much data to send/receive to/from the buffer register using the associated _NUM_BYTES, or _SIZE, or _LEN register.
  4. Often it is necessary to complete the transaction with an action register, such as _GO, or _OPEN, or _ENABLE.

Buffer Registers, and their size definitions:

Serial Comm Systems
  • ASYNCH_DATA_RX
  • ASYNCH_DATA_TX
  • ASYNCH_NUM_BYTES_RX
  • ASYNCH_NUM_BYTES_TX
  • I2C_DATA_RX
  • I2C_DATA_TX
  • I2C_NUM_BYTES_RX
  • I2C_NUM_BYTES_TX
  • ONEWIRE_DATA_RX
  • ONEWIRE_DATA_TX
  • ONEWIRE_NUM_BYTES_RX
  • ONEWIRE_NUM_BYTES_TX
  • SPI_DATA_RX
  • SPI_DATA_TX
  • SPI_NUM_BYTES
File IO System
  • FILE_IO_PATH_READ
  • FILE_IO_PATH_WRITE
  • FILE_IO_PATH_READ_LEN_BYTES
  • FILE_IO_PATH_WRITE_LEN_BYTES
  • FILE_IO_READ
  • FILE_IO_WRITE
  • FILE_IO_SIZE_BYTES
Lua Scripts/Debug Info
  • LUA_SOURCE_WRITE
  • LUA_SOURCE_SIZE
  • LUA_DEBUG_DATA
  • LUA_DEBUG_NUM_BYTES
Stream Out System
  • STREAM_OUT#(0:3)_BUFFER_F32
  • STREAM_OUT#(0:3)_BUFFER_U16
  • STREAM_OUT#(0:3)_BUFFER_U32
  • STREAM_OUT#(0:3)_BUFFER_ALLOCATE_NUM_BYTES
User RAM FIFOs
  • USER_RAM_FIFO#(0:3)_DATA_F32
  • USER_RAM_FIFO#(0:3)_DATA_I32
  • USER_RAM_FIFO#(0:3)_DATA_U16
  • USER_RAM_FIFO#(0:3)_DATA_U32
  • USER_RAM_FIFO#(0:3)_ALLOCATE_NUM_BYTES
WIFI
  • WIFI_SCAN_DATA
  • WIFI_SCAN_NUM_BYTES
Internal Flash
  • INTERNAL_FLASH_READ
  • INTERNAL_FLASH_WRITE

The above buffer registers can be identified in the LJM constants file as buffer registers by the "isBuffer":true designation. The constants file is typically located under C:\ProgramData\LabJack\LJM\ljm_constants.json.

LJM

When using LJM, the LJM_e...Array functions are useful when reading from a buffer (LJM_eReadAddressArray or LJM_eReadNameArray) or writing to a buffer (LJM_eWriteAddressArray or LJM_eWriteNameArray).