Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird reply from Modbus energy meter controlled by mbed microcontroller

Status
Not open for further replies.

zenniz

Computer
Mar 25, 2013
6
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 add
        RS485.putc(0x04);   // function code
        RS485.putc(0x00);   // Hi PDUadd
        RS485.putc(0x48);   // low PDU add
        RS485.putc(0x00);   // Hi N reg 
        RS485.putc(0x02);   // Lo N reg
        RS485.putc(0xf1);   // Hi CRC
        RS485.putc(0xdd);   // Lo CRC
        wait_ms(200);          // Silent interval
        printf("Getting data\n");
        ho = 0;
        for (int count = 0; count < 8; count++) {
            regvalue[count] = RS485.getc(); // Retrieve received register from modbus
            printf("%X - ", regvalue[count]);
        }
        wait_ms(1000);
    }
}
 
Replies continue below

Recommended for you

Now that your problem has been resolved, please Red Flag your post above and ask that it be removed.

One question per issue will be sufficient in future. Thanks.


Mike Halloran
Pembroke Pines, FL, USA
 
The Modbus of the energy meter is not responding as expected even thought the terminal resistor was connected. This is a new problem. I was using ModScan32 as a master device previously. For this post, i'm using an mbed microcontroller as a master device.
 
You did store scope traces from the HMI that worked, right?
I'd compare them with the same traces for your micro.
Just to verify that the transceivers are equivalent, and the low level code is tickling something, to get started.



Mike Halloran
Pembroke Pines, FL, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor