Hi this is my circuit :
and when i coennect it to my laptop via RS485 to USB Converter(com7) i have this result on Qmodbus software:
But if i Connect Arduino via USB Adapter to my laptop and choose USB Arduino (COM6) for Serial port
I have this result , in this case everything work fine and without any error or problem
i use same program for arduino in both case , This is the arduino code for test:
my modbus library for arduino is Modbus-Master-Slave-for-Arduino
/**
* Modbus slave example 3:
* The purpose of this example is to link a data array
* from the Arduino to an external device through RS485.
*
* Recommended Modbus Master: QModbus
* http://qmodbus.sourceforge.net/
*/
#include <ModbusRtu.h>
// assign the Arduino pin that must be connected to RE-DE RS485 transceiver
#define TXEN 2
// data array for modbus network sharing
uint16_t au16data[16] = {
3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };
/**
* Modbus object declaration
* u8id : node id = 0 for master, = 1..247 for slave
* u8serno : serial port (use 0 for Serial)
* u8txenpin : 0 for RS-232 and USB-FTDI
* or any pin number > 1 for RS-485
*/
Modbus slave(1,0,TXEN); // this is slave @1 and RS-485
void setup() {
slave.begin( 9600 ); // baud-rate at 9600
}
void loop() {
slave.poll( au16data, 16 );
}
So What's the problem ?