hi,
I m using arduino UNO to read delta plc register through RS485. M using Simple modbus master v10 code
#include <SimpleModbusMaster.h>
//////////////////// Port information ///////////////////
#define baud 9600
#define timeout 1000
#define polling 200 // the scan rate
#define retry_count 10
#define TxEnablePin 2
enum
{
PACKET1,
// PACKET2,
TOTAL_NO_OF_PACKETS // leave this last entry
};
Packet packets[TOTAL_NO_OF_PACKETS];
packetPointer packet1 = &packets[PACKET1];
unsigned int readRegs[1];
void setup()
{//address for D2 register is 4098(decimal) its hex is 1002
modbus_construct(packet1, 2, READ_HOLDING_REGISTERS, 4098, 1, readRegs);
modbus_configure(&Serial, baud, SERIAL_8N1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);
}
void loop()
{
char i;
modbus_update();
if(Serial.available() >0);
{
Serial.print("requests: ");
Serial.println(packet1->requests);
Serial.print("successful_requests: ");
Serial.println(packet1->successful_requests);
Serial.print("failed_requests: ");
Serial.println(packet1->failed_requests);
Serial.print("exception_errors: ");
Serial.println(packet1->exception_errors);
Serial.print(readRegs[0]);
Serial.println("");
delay(2000);
}
}
the output is 0 insted i should get 29H
kindly help for this problem
Thank you
ratna