Problem with energy meter using Modscan

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???

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#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);
    }
}
Last edited on
What's your definition of wait()? Usually its defined as a system call to join with a terminating child process.
Topic archived. No new replies allowed.