Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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 i want to receive ASCll from rs485 but i get nothing and the putty stop
what's wrong? thanks very much~
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.... }
Try including a wait(0.1) after the for loop.
posted by WB Tan 03 Nov 2016This 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.