I am using a Schneider Energy meter EM6400 along with RS485<>RS232 LC module and Arduino UNO. The connections are as shown in the image. Pin 6 and 7 of MAX 485 are connected to pins 7 and 14 of the Energy meter which are meant for RS485 Serial Communication.
All other pins of Energy meter are left disconnected.
I am trying to Read Holding Register whose Function Code is 0x03 in Modbus Protocol.
I have tried using many libraries but am not getting any success.
I think I should be getting the values as 0 since I have not connected Energy Meter with Current and Potential Transformers.
But I am getting garbage values.
Library used is Simple ModbusMasterv2rev2 as attached below .
#include <SimpleModbusMaster.h>
#define baud 19200
#define timeout 1000
#define polling 200 // the scan rate
#define retry_count 10
#define TxEnablePin 2
#define TOTAL_NO_OF_REGISTERS 1
enum
{
PACKET1,
TOTAL_NO_OF_PACKETS // leave this last entry
};
Packet packets[TOTAL_NO_OF_PACKETS];
unsigned int regs[TOTAL_NO_OF_REGISTERS];
void setup()
{
modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 3900, 1, 0);
modbus_configure(&Serial, baud, SERIAL_8E1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
void loop()
{
int i;
modbus_update();
regs[0] = analogRead(0); // update data to be written to arduino slave
for (i=0;i<11;i++)
{
Serial.println(regs[i]);
}
Serial.println("**");
}
}
Attachments:
1)Library
2)Circuit Diagram
3)Data Sheet of Energy Meter
4)Output image on Serial Monitor
5)Library Manual
hello, TomGeorge , i am using rs485 to ttl converter between arduino serial and EM6400 from schneider to i used different examples from google and arduino forum but things not working, please help
That picture is almost useless. We can't see the manufacturer or model number on it. We can't see how you wired it to the Arduino. We can't see how you wired it to the 485 device. A schematic is so much more useful because we can see the connections without following coloured wires and you can write the exact name of each component next to the component.
Which "different examples" did you try? What exactly didn't work? What were you expecting each example to do and what was the actual result?
Hi, @Ashokjay you would be better off starting a new thread with full explanation of your project and the problems you have, rather than use an old thread.