Set Arduino due as slave and read register value using Labview and MODBUS TCP/IP

Hello,

I am just trying to read my holding registers in arduino due, which is set as a slave, and read the registers using the labview example below but I am getting values which do not align with whats in the holding register, “holdingRegs”? I am not sure what I am doing wrong. I have attached my files below including the labview file I am using to test. I would like to get it too where I can read a variable stored in my holding register from my arduino due to the register in the VI to verify Modbus over ethernet is working

I have my holding register set equal to 1 to verify but I am getting zero in labview and unknown values in my serial monitor when the Labview file is running

I found the slave library for the arduino DUE from here Modbus RTU libraries for Arduino - Google Drive

I am using an ethernet shield 2 on my DUE

SimpleModbusSlave_DUE.cpp (9.24 KB)

SimpleModbusSlave_DUE.h (2.56 KB)

MB Ethernet Example Master - Copy.zip (17.2 KB)

ArduinoDueLabviewEthernet_2.ino (5.15 KB)

  modbus_configure(&Serial, 9600, 1, 2, HOLDING_REGS_SIZE, holdingRegs);

You configure Modbus to use the serial interface so your sketch is a Modbus RTU slave, it doesn't do any Modbus TCP. The SimpleModbusSlave library is Modbus RTU only, it cannot do Modbus TCP.
You might give the ArduinoModbus library a try, it should support Modbus TCP, although I never tried it on a Due.

Hi,
Just in passing: you can't read on serial port at the same time with arduino IDE/serial monitor and labview, so be careful to close the IDE before using labview to connect to the visa/serial

:slight_smile: