I'm using an mbed micro-controller to retrieve register from Integra 1630 energy meter with modbus via a SIPEX SP485CS chip (RS485 level shiftier).
All the component and connection are working correctly.(Double checked) Using the same program with different reigster, i'm able to get good modbus reply from other type of energy meter with modbus.
I always a register of 0x00 instead of good modbus reply. Why am i always getting 0x00???
Code:
#include "mbed.h"
Serial RS485(p28,p27);
DigitalOut ho(p26);
int regvalue[9];
int main()
{
ho = 0;
while(1) {
RS485.baud(9600);
printf("Starting\n");
ho = 1;
RS485.putc(0x01); // slave
RS485.putc(0x04); // function code
RS485.putc(0x00); // Hi add
RS485.putc(0x48); // low add
RS485.putc(0x00); // Hi N reg
RS485.putc(0x02); // Lo N reg
RS485.putc(0xf1); // Hi CRC
RS485.putc(0xdd); // Lo CRC
wait(0.2); // Silent interval
printf("Getting data\n");
ho = 0;
for (int count = 0; count < 8; count++) {
regvalue[count] = RS485.getc();
printf("%X - ", regvalue[count]);
}
wait(1);
}
}