Print to MAX485

i was trying to communicate with arduino (board mega2560) via 485. my connection was like arduino hardware serial port 1<-> Max485 <----- 485 cable --------> usb 2 485 module <-> com port tool on PC. i got unreadable message on PC when i print some char on arduino. pls, anyone help in this case? any hints,
i am quite sure the buad rate was correct, and both parties were working in 8N1.

is the RS485 terminated correctly at each end - I seem to remember 120ohm
I assume you take the DE & RE high to enable transmit then call the print function - do you then give sufficent time for the text to be transmitted before taking DE & RE low?
can you transmit from the PC to Arduino OK?
post your code?

well, problem fixed. a delay(50) is applied before writing the DE-RE pin low.

thank you

using a delay() is a bit hit and miss - delay() may be too short and you loose some transmission or too long and waste time
after printing try calling flush which the documentation states waits for the serial transmission to complete
never attempting to use Arduino RS485 for anything serious - always used Microchip PIC24 and checked the hardware interface to make sure transmission was complete

following your recommendation, the delay() i hired before is replaced by flush() and it works perfectly. for MIcrochip PIC24, probably i should find some documentation to learn more.
thank you,

Dear horace,

i am still working with MAX485 module. however got a problem taking me a whole day trying to fix it. i am exhausted. could you please have a look to the description i raised some hours ago and kindly leave me some advice. thank you very much.

the link to my question.

the TX should normally be disabled when using 485. i did add a 1msec delay after enabling it.

i waited for the flush() to return before disabling it

of course make sure the pair of wires are connected with the correct polarity. the wrong polarity may look like continual transmission besides inverting the data

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.