Go Down

Topic: Use a serial wire for atmega32s communicating over a range of 1000ft (Read 570 times) previous topic - next topic


I want two atmega32s to communicate over a range of 1000ft, so I decided to use a serial wire for it. I know rs232 is not a good way to communicate over this large range, so I decided to use RS485 which is a balanced pair. For this I want to use MAX485 chips like these.

Now I wrote all the code to use it and got it working for short wire communication with a battery powering my ATmegas (and the MAX485 chips) (I cannot produce the code here as it is for a company where I am just an intern, but as it works in short wire the code is not the problem). What the program basically does is, one atmega sends "Paresh" on serial, the other atmega receives it, does a strcmp if it is indeed recieved as "Paresh" it sends out "Mathur". If the first atmega receives "Mathur" it again sends paresh and the cycle continues.

All this works just fine for serial mode, short wire and on a 6V battery. But as soon as I switch to a CAT-5 cable I get packet loss. I printed what ever one receives on an LCD and after a few cycles (and sometimes even for the first transfer) there is strange strings received. The problems are:
  •     It works for short wire but not a 30ft CAT-5 cable
  •     It works for 6V battery but not for 12 volt battery or a 12V adapter.
  •     It works for normal serial wire upto 10ft but not more than that.

The things I have tried are:
  •     Added capacitors to fade out any ripples in the supply. (470uf caps).
  •     Increased delays between switching from transmit to receive modes ( _delay_ms(3); ).
  •     added caps to the supply to the modules.
  •     Adding 120ohm terminal resistance to both modules.

What should I do? Please do no suggest any alternatives to the the thing, it would hurt the hacker in me. Why can't I use an RS485 communication for exactly the purpose it was designed .i.e long distance communication over serial.


based on which documentation have you wired your max485 & arduino and the bus itself?

show a diagramm of your installation.

Are the pullups/pulldown resistors ok,
wire termination 120Ohm?
Ground connection OK?

DE: Wie man Fragen postet:
1. was hat man (Sketch und Hardware)
2. was SOLL es machen
3. was macht es: IST (Fehlverhalten, Fehlermeldungen, Serial.Output ...)
4. Eine Frage stellen bzw. erklären was man erwartet

Go Up