jocker
Newbie level 1
- Joined
- May 6, 2014
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 7
hi to all
I'm trying to communicate with the energy meter (MODBUS protocol) using st nucelo F401RE via MAXIM MAX485 chip. I'm unable to receive any data from the energy meter. I can confirm that all my hardware is working correctly as i have extra for each component.I'm not sure if is the connection or the program's problem. I using Arduino uno rev.3 for try it. I use a oscilloscope but i don't see nothing, i think the problem is the serial comunication, can you help me?
this in my code:
I'm trying to communicate with the energy meter (MODBUS protocol) using st nucelo F401RE via MAXIM MAX485 chip. I'm unable to receive any data from the energy meter. I can confirm that all my hardware is working correctly as i have extra for each component.I'm not sure if is the connection or the program's problem. I using Arduino uno rev.3 for try it. I use a oscilloscope but i don't see nothing, i think the problem is the serial comunication, can you help me?
this in my code:
Code:
#include "mbed.h"
#include "TextLCD.h"
Serial RS485(D1,D0); // Tx, Rx
DigitalOut ho(D2); // use this pin for able the RS485 trasmission
TextLCD lcd(D12, D11, D9, D8, D7, D6); // rs, e, d4-d7 --
int regvalue[9];
int main() {
lcd.printf("START\n");
RS485.baud(9600);
while(1) {
ho = 1; // hight output from digital out pin
RS485.putc(0x05); // slave add
RS485.putc(0x03); // function code
RS485.putc(0x00); // Hi PDU add
RS485.putc(0x13); // low PDU add
RS485.putc(0x00); // Hi N reg
RS485.putc(0x02); // Lo N reg
RS485.putc(0x34); // Hi CRC
RS485.putc(0x4A); // Lo CRC
wait_ms(200); // Silent interval
ho = 0; // low output from digital out pin
for (int count = 0; count < 8; count++) {
regvalue[count] = RS485.getc(); // Retrieving received register from modbus
lcd.printf(regvalue[count]);
}
lcd.printf("OK\n");
wait_ms(1000);
}
}