7 years, 6 months ago.

Receive data from rs485

i use LPC4088 tx rx to transfer the modbus ASCll command to rs485 this is the code /media/uploads/david8251/100.png i want to receive ASCll from rs485 but i get nothing and the putty stop /media/uploads/david8251/110.png

what's wrong? thanks very much~

Try including a wait(0.1) after the for loop.
This happens when your microcontroller is waiting for your Modbus device to reply. Your Modbus device is most likely not replying.
I wrote a similar program that uses a RS485 to communicate with an energy meter with Modbus. The manual says to include a short wait time between sending and receiving register to and from Modbus device.
Some Modbus device require a 120ohms termination resistor to be connected from RX to TX even though the distance from your microcontroller to Modbus device is short.

posted by WB Tan 03 Nov 2016

1 Answer

7 years, 6 months ago.

My guess is that you aren't receiving any data. If no RS485 data is received then the program will wait forever on line 25 waiting for RS485.getc()

And please don't post code as an image. Post it as text with <<code>> tags so that it is correctly displayed e.g.

<<code>>
#include "mbed.h"
void main () {
   // lots of code....
 }
<</code>>

gives

#include "mbed.h"
void main () {
   // lots of code....
 }

Accepted Answer

Sorry i am new and i will post again. Thanks for your answer~

posted by jajn HA 03 Nov 2016