SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By rdg-123
#95540
I've been learning about serial communications for a project, but I think my wiring situation won't really allow clean communication. I have two irrigation controller wires traveling over 1200 ft with multiple connections on my common wire. Clearly, I cannot use a twisted pair or any network structure since irrigation stations aren't laid-out in anyway similar to the rs-XXX protocols. I need to transmit a number, 0-99 say, from one arduino to another. I've looked into half-duplex rs-485, but I don't have twisted pair wires, as I've mentioned.

I was thinking I could use an opto-isolator to level up for the distance, but is there a way to code the arduino to send a number of pulses and then send some sort of terminator before repeating so another arduino could read it and count out a number? I assume if I have it repeat, it could use some sort of error correction by averaging the counts. I don't need crazy fast speeds...10 repeats per second would be plenty fast.

Anyone have any ideas so I don't have to re-invent serial communication?

Thanks
By MichaelN
#95543
I would still use RS485 / RS422 even though you don't have twisted pair, but you'll obviously need to limit the baud rate. The differential signaling used will give MUCH better results than "single ended" signaling. You should have no big problem with the distances and baud rates you're looking at.

There are plenty of driver chips you could use; connect them to UARTs on the Arduinos. You may want to implement CRC or similar to reduce errors.

Make sure there is a common ground wire somewhere in your wiring. I assume there will be, but some people omit this because they assume the differential signaling will be OK without it. In some cases this is correct; the driver chips can tolerate a certain amount of common-mode noise without errors, but no more than a few volts.
By rdg-123
#95544
Unfortunately, I only have access to two lines at a time. My common wire has multiple endings, but my controller wire is a single running from my clock to each valve. Will I need to terminate all of my common wires with resistors? And to what?

I planned on running at 1200 bps...
By MichaelN
#95545
How are you powering the nodes? If you are running power cables, then just use the negative power supply lead as signal ground.

An RS485 circuit MAY work without a common ground, but I wouldn't try it. As I said, you really should have some common "ground" reference between the different nodes. Normally this is a separate wire or shield in the case of shielded cables. In some situations, it is acceptable to use a less-than-ideal "ground" reference such as a building "earth", but note that the "earth" voltages can vary. RS485 specifies the "ground" (common-mode) voltage must be within -7Volts to +12Volts.

It is advisable to put a 100 ohm resistor between the signal "ground" at each node, and whatever common ground you are using, to limit any ground currents.

The following is a useful article on the subject:
http://www.embeddedsys.com/subpages/res ... _RS485.pdf

If there REALLY isn't a common ground you can use, it might be better to try a "single ended" signaling protocol such as RS232. To implement a bi-directional, half-duplex "RS232" protocol would probably require using RS232 driver chips that have "enable" lines for the outputs, and implementing a master / slave protocol in your microcontroller code. You MAY be able to achieve 1200' if you use 1200 baud, but it would depend on other factors in the installation...

As for terminating resistors, RS485 normally only terminates each end of the network (usually 120 ohms, but can be higher to save power).
By rdg-123
#95548
I was hoping to use my 18V DeWalt battery pack and a power regulation circuit for the power. Since I'm running adjacent to about 3000' of copper pipe that runs 2' below grade, would it work to connect all of my common grounds to the mainline copper? Or since I'm landscaping in the dirt 90% of the time, could I drive a metal rod into the actual "earth" and get a consistent reading?

Next time, I'll price out running some CAT5 cable to all of my manifolds!
By MichaelN
#95549
Copper pipe would work well if it's run to all the nodes. Using earth stakes is not good, since the local "earth" voltage can vary considerably, especially over distances of hundreds of feet. The difference in "earth" potential could easily exceed the -7 to +12V common-mode range of the RS485 drivers.

I'm not sure I understand what you mean re the battery pack - I assume each node won't have its own battery? In that case, there must be power cable going to each node?
By MichaelN
#95590
I'm confused about the end result you're trying to achieve. If this is a permanent installation, why are you using battery packs instead of sending power down the cables? If you're worried about not having enough wires, there are schemes for sending power and data over the same wires.
By rdg-123
#95673
I've been trying to set this viewtopic.php?f=14&t=18065 project up for months now. I finally have multiple arduinos for each end of my run and an LCD for a display, so I'm quite eager to figure out the coding/remaining hardware necessary. If I can get serial to work, then my coding is just about done using softserial for multiple pins - or just Tx & Rx for a single set of wires.

I don't know anything, yet, about sending data and power along my two wires.

I really appreciate your trying to help me out.
By theatrus
#95711
In all honesty, it sounds like you need a power line communications system. Your goal is to couple a signal over your power wire.

This is really RF design at this point. You need a modulator, amplifier, demodulator, lots of error correction, and some logic to control who is transmitting. Couple this over your power wire capacitively. You'll only need to run at a few kHz since I doubt this is a data-rate critical application.

If your wiring is point to point, you can do a simpler scheme much like 1-wire, where you charge up a reservoir at the end device, and then initiate communication by pulsing the power wire. This can extend to multiple drops along a wire, but if devices are consuming large amounts of current (like valve solenoids) this may be suboptimal. If you lookup US patent 7358626 and 7619322 Toro already has a system similar to this. Their system involves AC powered end devices, which allows them to switch the polarity of the system for communication, with a current based data return system (if I am reading it correctly).
By rdg-123
#95734
I think I need another take on things...

Previously, I would hook-up a battery to my two wires on one end and light up an LED on the other end. I could wire up a 555 timer and strobe a count of flashes pause repeat, however, couldn't I have an MCU pick up those pulses passively? If I run an optoisolator, is there a way to code in an error checking procedure?

And if so, why can't I have an MCU send the pulses so I can dial-up any number I want?

All I want to do is to tell the Tx what number of pulses to send (1 thru 99, say) and have an MCU at the other end counting, then printing out onto a screen. Would it be that hard to send a nice square wave at less than 1kHz?

I guess I'm just looking to build a smarter version of this: http://www.lashen.com/vendors/tempo/ton ... p#pe77hp6a

which only sends a tone, not a number, and can't really tell me of the three (for example) wires that carry a tone which is 13, 14, or whatever...
By rdg-123
#95737
Maybe it won't work...

Option 2 - XBeePro communication and just iterate a button code to switch terminals on the Tx module lighting up LEDs at the Rx with the "next" button...

Easier, but more expensive?
By MichaelN
#95740
I think we really need more detail on what you're trying to connect to. A schematic would be good - it's hard to visualize what you're looking to do.
By rdg-123
#95788
Okay...a general idea and some thoughts...
I'm a landscaper with very large irrigation installations. Often I have to run my controller wires (1 solid 14gauge per station and 1 solid 14 gauge common) before I can install my controller clock. Sometimes I have over 40 station wires and several common wires all in a bundle coming into a closet in a building. At this point, I have no idea which wire goes to which valve. My current low-level work around is to hook up a battery to the common and one controller wire, go into the closet, and search out which of the 40 wires has power coming through it with an LED that lights up. Label the wire and then walk 3000' to change the battery to another controller wire. Time consuming to say the least.
I'd like to be able to hook-up a Tx device that would send the number of the station to the closet where I can find the signalling wire and then "read" the station number off of it with an Rx unit. Since I have 3 to 4 valves per manifold, I'd love to be able to hook-up all four controller wires (and the common) and then label all of them at once in the closet(hence the need for more than a blinking light).
I know I can run differing levels of power with resistor leveling, but this has some limitations for "transferring" the technology to my crew. They could read a number from an LCD panel, but might not get the idea of differing voltages on a multi-meter.
I've been curious about using serial communication for this, but perhaps I should be looking into a 1-wire solution for power and data. Perhaps I should use an XBEE device for triggering the power send (push button addressing on sending unit?). I seem to have hit a wall due to the random nature of irrigation wiring installations...
By n1ist
#95852
What about going the other way? A box at the controller that sends a different message out each line, and a little box you use in the field with a display on it? That would solve any issues with determining which is the common and which is the signal. Maybe use current pulses rather than voltage to reduce the effect of voltage drop from the wires?
/mike