Modbus checksum error

Hi all, i am trying to use my arduino as a modbus master to send 1 bit of data through RTU.

When press my digital input from arduino master, modbus poll & modbus tester throw up errors and i cannot receive the data correctly. I have been trying to debug this for many days now and have been unsuccessful, i have re wired my project and checked my code but still cannot figure out these errors.

On Modbuspoll i get " checksum error" and when no inputs pressed "timeout error", i have included my wiring and code below along with pictures of the errors that i am receiving.

I also get read rs port error & or illegal response when using mbustester

I am trying to send the data through the address 0x10001 in order for my slave to read the input of 1 which is sent from the digital input on the arduino.

Hardware:

Arduino Uno
5V TTL to Rs485 Module
SH-U10 USB to RS485 Converter
Push Button
LCD

Code:

#include <ModbusMaster.h>               
#include <LiquidCrystal.h>

#define MAX485_DE      11
#define MAX485_RE_NEG  10

ModbusMaster node;

LiquidCrystal lcd(8, 2, 4, 5, 6, 7);

void preTransmission()            
{
  digitalWrite(MAX485_RE_NEG, 1);
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}
const int button1 = 10;
const int button2 = 11;
const int button3 = 12;
const int button4 = 13;



void setup() {
  lcd.begin(14, 2);
 

  pinMode(button3, INPUT);
  
  pinMode(MAX485_RE_NEG, OUTPUT); //declaring pinmode output for max485
  pinMode(MAX485_DE, OUTPUT); //declaring pinmode output for max485



  lcd.print("Welcome!");
  delay(1000);
  lcd.clear();
  lcd.print("Project Simulation");
  delay(1000);

  digitalWrite(MAX485_RE_NEG, 0); //initialise
  digitalWrite(MAX485_DE, 0); //initialise

  Serial.begin(9600);


  node.begin(1, Serial);     //Slave ID as 1
  node.preTransmission(preTransmission);         //Callback for configuring RS-485 Transreceiver correctly
  node.postTransmission(postTransmission);


}


void loop() {


  int a = digitalRead(button3);
 

  if (a == 1)
  {
  
    node.writeSingleRegister(0x10001, 1);
    delay(1000); 
    lcd.setCursor(0, 1);
    lcd.print("S1: HIGH");
  }

}

I also receive an error whilst compiling although i am able to upload this to the device and other functions work ie, lcd print functioning correct when press digital input

warning: large integer implicitly truncated to unsigned type [-Woverflow]

     node.writeSingleRegister(0x10001, 1);

2.jpg

3.jpg

4.jpg

checksum error.PNG

I am trying to send the data through the address 0x10001 in order for my slave to read the input of 1 which is sent from the digital input on the arduino.

That register address does not exist. Register addresses are 16bit values but 0x10001 is simply 1 as a 16bit value.

When press my digital input from arduino master, modbus poll & modbus tester throw up errors and i cannot receive the data correctly.

I don't know that Modbus Poll but from the screenshot it looks like it's a Modbus master, not a slave.

I also don't know if your Windows machine is able to allow two programs to access the same serial port and handle that correctly.

Usually a slave has the sensors which readings are represented in the register values. The master then requests these values from the slave.

For me it looks like you planned your setup wrongly from the beginning.

Thankyou for the reply pylon, i have also tried using the address 0x40001 and i get compile errors, i am using a rs485 to usb converter from the A and B ports on the rs485 for the master and am trying to use the modbuspoll software as the slave. I am going to be using flexsim software as my actual slave but am trying to intercept the data from modbusspoll first to check it's working correctly i can post more pictures if this helps?

Thankyou for the reply pylon, i have also tried using the address 0x40001 and i get compile errors

Sure, it's also not a 16bit value!

i am using a rs485 to usb converter from the A and B ports on the rs485 for the master and am trying to use the modbuspoll software as the slave.

Does this software support being a slave? Why did you still fail to provide a link to that software?

I am going to be using flexsim software as my actual slave

Another software you mentioned without providing a link to it.

but am trying to intercept the data from modbusspoll first to check it's working

Intercepting Modbus traffic is almost impossible without more information because you never know if a message was from the master or the slave and you have to know that to decode it.

Hello, this is the software that i have been using to try read the data - Modbus Poll Quick start it says on the website it can read/write modbus data

This is the virtual simulation software i am using for the project which is capable of being RTU Modbus master + slave (wanting to use it as slave) - https://www.flexsim.com/

This is the guide which i initially followed to make the Arduino modbus, using the arduino as master and the modbus poll software linked above for reading the data sent from the device -

Also, here is a link to the hardware RS485 and usb converter i am using

RS485 - https://www.amazon.co.uk/HALJIA-MAX485-Module-Converter-Arduino/dp/B06Y2XHSMW/ref=sxts_sxwds-bia-wc-p13n2_0?cv_ct_cx=ttl%20to%20rs485&dchild=1&keywords=ttl%20to%20rs485&pd_rd_i=B06Y2XHSMW&pd_rd_r=4cdbc3f4-1419-4f34-bb86-a6b180eb209c&pd_rd_w=SLjEZ&pd_rd_wg=spOCE&pf_rd_p=4cda869f-2b1a-4e5f-a72b-48315da95bba&pf_rd_r=DS3J4C4S4J49HV2QD545&psc=1&qid=1589542284&sr=1-2-91e9aa57-911e-4628-99b3-09163b7d9294&fbclid=IwAR1qkhPNk9N-bE1CAatQcSGrJX2LgUM3J08ZEZrFbyej0uWuIx0G5rgzWzI

CONVERTER USB - https://www.amazon.co.uk/DSD-TECH-SH-U10-Converter-Compatible/dp/B078X5H8H7/ref=sr_1_1_sspa?dchild=1&keywords=usb%20to%20rs485&qid=1589542317&s=electronics&sr=1-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEySlczV00yTkJYQjE1JmVuY3J5cHRlZElkPUEwMDQ2ODQ0MTY2UE1ZRVJFU1RaTiZlbmNyeXB0ZWRBZElkPUEwNTc4NTI4MkNRTUE5STFRQlBEUyZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU%3D&fbclid=IwAR2-4Gsvge8P0eoAnw8o1-SuFFOAc7X2x7rUlRDOHttn9myuVMUiAsh1Hao

Hello, this is the software that i have been using to try read the data - Modbus Poll Quick start it says on the website it can read/write modbus data

Did you configure that software correctly?

This is the virtual simulation software i am using for the project which is capable of being RTU Modbus master + slave (wanting to use it as slave) - https://www.flexsim.com/

This is a quite complex simulation software. I haven't studied the documentation thoroughly but it seems it can only simulate environments, it cannot actually communicate with actual devices. Maybe you know that software better but then provide a link to that part of the documentation that explains how to connect to a Modbus device.

You should read a bit more about how Modbus works if you want to connect to such software packages.
In a Modbus environment only the master read or writes anything, the slaves just reply to the masters requests.

I am trying to send the data through the address 0x10001 in order for my slave to read the input of 1 which is sent from the digital input on the arduino.

The addresses are specified in decimal, NOT hexadecimal.

If you remove the '0x' from each of the addresses, then that should remove some of your compiler errors.