A little background: When the distance from computer to Arduino reached 150 feet, I had to switch from a USB-based Arduino to a MaxSerial (which uses a Max232 chip to communicate using standard old-skool RS-232 serial).
Everything worked great for a week or two, but then the board started resetting itself sponatenously after only a few seconds of uptime. I isolated the problem to the Max232 chip - with it removed from the socket, the Arduino worked perfectly, though (obviously) with no serial communication. With the Max232 back in place, it resumed its spontaneous resetting. I tried different Max232 chips and they all have this problem, so I suspect it is related to noise in the long serial line. I looked at how the Max232 connects to the Arduino's reset pin (necessary so that the IDE can tell the Arduino to reset prior to uploading new software, the great new Diecimila feature), and I see it goes to pin 12 (RS1) through a 0.1microfarad capacitor and that the reset line is held to 5volts through a 10k resistor. are there any modifications i should attempt to keep spontaneous resets to a minimum?
You might trying asking the designers / manufacturers of the MaxSerial board. They probably have a better sense of how its auto-reset feature works.
This leads into a question that I have about the Diecimila generally. Could someone give a concise description of what the Arduino IDE does that causes the USB chip on the Arduino to reset? Understanding this mechanism a little better would be helpful in fixing problems of this sort. I know I’m using a slightly off-brand Arduino in this case, though I’m sure the knowledge I seek would be helpful to everyone.
I've confirmed that the source of my problems is pin 12 on the Max232 chip. With it kept out of the socket, all was well.
Actually, the problem seems to be coming from a USB-to-serial adapter i'm using 150 feet away on the computer end of the serial cable. Plugged directly into the computer's god-given rs-232 ports, it works fine, but with the serial cable either plugged into the USB-to-serial adapter or removed from the Arduino (technically it's a Freeduino) it spontaneously resets. perhaps i need to try some sort of termination of the cable on one end or the other. i've been doing this stuff for 25 years but i've never really understood termination. perhaps someone could break it down for me.
Isn't 150' a stretch for even RS-232? It's seems it's more in RS-422 territory. There used to be "short haul" modems that handled this type of thing.
actually the 150 feet of rs-232 was working great until the usb-to-serial adapter blew (lightning??). still, i'm guessing i should terminate it and perhaps take surge-arresting measures to keep such adapter blowouts to a minimum. also, i'd like to make it so the maxserial doesn't spontaneously reboot when there is no serial cable plugged into it at all. perhaps there's a defect in the way i made that particular board (which i did from a kit), but it seems to require a serial connection to a computer or else it reboots spontaneously every seven or eight seconds.
bigfun, check this thread out: looks like the choice of cable is key to having a 150 foot run work reliably.
There's a description of the auto-reset in the Diecimila documentation: http://www.arduino.cc/en/Main/ArduinoBoardDiecimila, but I don't know how much of that applies to your board.
Maximum distance on RS232 is 50 ft. See:-
Remember. the problem isn't reliability of communication with this 150 foot RS-232 setup (it uses unshielded CAT3 cable), it's the propensity to randomly trigger the Diecimila autoreboot-before-software-upload routine. I'm using a Freeduino/MaxSerial, so an actual Arduino might not have this problem. Then again, an actual Arduino can't communicate this far, because USB over these distances is a mess (believe me, I've been there, tried lots of niche products). I do see that the MaxSerial reset only looks at the RS1 pin (pin 12 of the Max232) whereas the actual Diecimila's reset looks at two pins on its USB chip (DTR -pin 2, and RTS - pin 3). And, at least with my particular MaxSerial Freeduino, the propensity to reboot spontaneously exists in either of two situations, only one of which involves long cable: when there is a long RS-232 cable attached via a USB-to-Serial adapter to a distant computer, or when the there is no cable attached at all. It seems to be reliable when using a short RS-232 cable or when a long RS-232 cable connects directly to a distant computer's RS-232 port.
Official Arduino Diecimila schematic:
MaxSerial Freeduino schematic:
the propensity to reboot spontaneously exists in either of two situations, only one of which involves long cable: when there is a long RS-232 cable attached via a USB-to-Serial adapter to a distant computer, or when the there is no cable attached at all.
Ok forgetting that 150 foot unshielded cat5 cable is like a huge vacuum cleaner for noise and all manner of garbage ( in ham radio, a 150 foot antenna is the pretty much what you would need for talking to Moscow on the 80 metre band)... anyway...
I am looking at the fact that DTR passes through the MAX232 chip. The MaxSerial does not seem to have any power supply bypassing near the chip, which is recommended in the datasheets. Try putting a 1Uf cap on the power pins of the 232'. (+side to pin 16, negative side to pin 15.)
Failing that, it takes quite a bit of current to drive through that 150 feet of inductance, and potentially makes for all kinds of nasty spikes on the power supply, so I would beef up the 5V power supply with 47Uf and a few more .1's for high frequency noise suppression. But I am betting that the lack of close bypassing on the MAX232 is the problem for both reset conditions described above.
Good advice on the caps. I still don’t know enough about the Diecimila reset protocol to know what combination of levels on the serial cable would result in a reset on the Freeduino end. Might it be the sort of thing that would crop up frequently in noise? My question, I guess, boils down to this: does anyone know what exactly causes the RS1 pin (pin 12) to change state on the Max232 chip?
so, did adding some caps fix it?
The 'what causes a reset' question is easy enough; when the arduino IDE opens a serial port (or pretty much any other com program), it asserts (pulls high) the DTR line, the MAX232 dutifully duplicates this by pulling it's pin 12 low, the 'CRS' 100nF cap AC couples this into a short low pulse on the ATmega's reset pin (pin 1).
Through experimentation, the MAX232 has shown adequate decoupling through C10, and the remainder or the filter caps, this said, more decoupling shouldn't hurt. Try an 0.1uF cap across pins 15 and 16 of the MAX232.
The DTR line's rise time is not crucial and you may experience less noise by pulling the line toward -10v with a high-value resistor between pins 13 and 6. In theory you may be sinking current from the PC into the MAX232s negative charge pump or vice-versa, but with a reasonably high resistor (say 1K+) you shouldn't have a noticeable issue. You may also try a small value cap between pin 12 and GND (pin 15).
A 1K resistor between on DTR line (DB9 pin 4) may help suppress noise on the line without pushing rise-times too far out of spec. Obviously terminating the line against it's own impedance may help.
Plugged directly into the computer's god-given rs-232 ports, it works fine
A great many USB-Serial converters are just barely RS232 compatible (if that), they use FTDI chips with inverted outputs to drive the signal between 5V and GND. Virtually all source there power from the USB port as well which greatly limits the amount of current they can drive into a long cable and their noise immunity. I would strongly suggest switching to either the computers native RS232 port or finding a serial converter that does real-rs232 with +/- 9v to 15v drive capability and it's own power-supply.
I was playing with this tonight, and have isolated the issue:
If you transmit data, while the DB9 shield is unterminated, any activity radiates energy through the shield and into the RX and DTR lines. Since they're normally pulled low on the RS232 side, transmitting a '0' sends the TX line high, which radiates a high into the DTR and RX lines, the MAX232 inverts this into a low pulse on the reset line, and the chip resets.
The solution is simple, connect the DB9 shield to the arduino's ground, the easiest way is with a short wire/jumper between pin 5 of the connector and the adjacent mounting lug. It's likely non-kosher to terminate the shield on the DCE end, but it shouldn't do any harm.
...RS-232 cable attached via a USB-to-Serial adapter...
Perhaps the USB-to-Serial adaptor is either leaving the shield unterminated or terminating it with a non-trivial impedance to ground.
...or when the there is no cable attached at all
In this case nothing was terminating the shield.
My MaxSerial Diecimila has been working nicely now for some weeks, although it occasionally resets spontaneously because of noise coming down that very very long 100 foot RS-232 cable (which is now shielded, by the way).
I noticed that lots of spontaneous resets seemed to happen under certain conditions the moment I turned on the light in the boiler room (it's a 23 watt compact fluorescent - 100 watt incandescent equivalent). Those who have been following this thread might find my solution to this problem helpful. I wrapped the 12 volt DC power line (containing a +12volt and Ground pair) around a donut-shaped ferrite toroid approximately seven times. This was totally a cargo-cult science experiment, because electro magnetic inductance is still basically magic to me. But the spontaneous resets, which had been so common before, are now completely gone.
Actually, scratch that about the ferrite toroid. Something I wasn’t paying attention to had fixed that problem and I unscientifically attributed it to the toroid (which I’m keeping just as a good luck charm). What really fixed my problem was spiffed’s idea of soldering pin 5 of the DB-9 connector to its mounting lug. Now my MaxSerial Freeduino is rock solid across its 100 foot RS-232 connection, performing as reliably as a toaster. I can even unplug the serial port and plug it back in again without triggering a reset.
Did you try a simple 4.7K pull-up resistor on the reset line? that way it would take at least 1 mA to cause a reset, your 150 foot wire may be less of an antenna with a little termination.
Have you considered rs-232 over rj-45? You get a much more solid AND better range this way.
Have you considered rs-232 over rj-45? You get a much more solid AND better range this way.
How does the connector make a difference?
I assume you mean CAT5 twisted pair network cabling? I've read one opinion that states twisted pair could actually induce noise on an rs232 connection since signals are single ended, not differential pairs like CAT5 is designed for. I don't think I buy it, unless you run at high speeds, but CAT5 is at best no better for rs232 than a standard rs232 cable.