Line Driver needed?
RichardF
Posts: 168
I want to communicate between two BS2's on 6 conductor AWG24 5E· (LAN) wire using SERIN and SEROUT over a distance of 100 feet. Do you think·the line losses will cause a drop in data? I don't know what the current flow will be so I can't compute the voltage drop. Any suggestions would be appreciated.
Comments
-Phil
Please start me in the correct direction. Obviously I need a converter for translation from SEROUT with flow control to RS422, and then back again to SERIN. This is for my submersible ROV project (see Completed·Projects forum). I need a hardware device and documentation to get me started, and perhaps some help on interface with my BS2-SX.
Thanks,
Richard·
TI and National Semiconductor make interface ICs.
Here's one example that might work: focus.ti.com/lit/ds/symlink/sn75als180.pdf
You might go to TI's website and search for application notes on RS422 signaling as well.
Kind of a new question but related and helps me understand where I am headed:
If I was to use RS-232, I would need 3 TI SN75150P Driver/Receivers·at each BS2-SX. Is this correct? These converters are just raising and lowering the 5 volts to 12 and back. Is this a correct understanding?
Thanks,
Richard
I would avoid RS232 over those distances. RS422 is much more appropriate. I've used the LTC490 IC for years. It's extremely easy to implement. To save power, I recommend the AC-coupled termination illustrated in Figure 10 in the referenced datasheet.
-Phil
Meanwhile the RS423 standard is good to 4,000 feet, with no external capacitors. Rather than implement a MAX232 solution, then find you'd have to go to RS423, you might start at RS423 to begin with.
On the other hand, the MAX232 driver's aren't that expensive, and have transmitter and reciever gates in the same package. So it might be a nice simple solution for you if it worked.
You meant RS422, not RS423, right? RS423 is an unbalanced signal that goes above and below ground and needs a negative voltage supply; RS422 is a differential, balanced signal that stays above ground and needs only the Vdd supply voltage.
I am not understanding the interface of RS422 with the BS2. I admit I have done very little in the serial comm field. I have never tried to communicate between two BS2's before. In the Basic Stamp Reference Manual there is an example of two BS2's communicating using the SEROUT and SERIN commands. Flow control is used to ensure the receiver BS2 is ready to receive data. I think I understand how RS422 works but I don't understand how you do the equivalent of this flow control with the RS422 transceivers. If you could please take a little of your valuable time and show me the physical interface with the LTC490 and some very simple code to make it work on a byte by byte basis I would greatly appreciate it. I have searched the web and these forums and I just haven't found a practiocal application of the RS422 to connect two BS2's. I need to send numeric data back and forth between the submersible and the surface control console. Right now I control the submersible by just varying the resistance to pins on the submerged BS2 and reading the value with RCTime. This is fullproof but is very limiting in what I can do. I want to send control commands down the line and feedback results back up the line.
Thank you,
Richard
Are you sure you even need the flow control? If you do, a couple RS485 transceivers would be more appropriate but slightly more complicated to implement. It might be simpler to come up with a command/response protocol that lacks hardware flow control. If that proves too impractical, I'll come up with a circuit for you.
-Phil
The easiest thing is just to avoid the flow control completely. Make your control console the master and your submersible the slave. During initialization, the master and the slave both set their RS422 outputs to low. Whenever the master has something to send to the slave, it sets its RS422 output to high. The slave may be busy at the time. When the slave is ready, it checks its RS422 input. If that is high, it sets its RS422 output to high, then drops into a SERIN with some kind of timeout, enough time for the master to respond. When the master sees its RS422 input go high, it waits a millisecond or so for the slave to start up its SERIN, then it sends the command and any data with a SEROUT. If they're both done, they both set their outputs to low and everything is ready to go again.
One of the commands might be a "send me a status report". In that case (and in any other case where there's a response to the command), the response is sent back before both units set their outputs to low.
All this needs is an LTC490 at each end. These would be wired like in Figure 5 of the datasheet. The transmit and receive lines at each end would be connected directly to a pair of Stamp pins and the rest is wired as shown. The master's "pseudo-program" might look like:
The slave's "pseudo-program" might look like:
Initialization would do a "LOW Tx" and an "INPUT Rx" on each end.
Post Edited (Mike Green) : 3/25/2008 1:35:31 AM GMT
You have cleared up so much for me in that short paragraph. I know you are tired of hearing this, but you really are a fine gentleman for devoting so much time to helping people on these forums. Parallax has really been a boon for me since retirement. I love to program, but with the PC it was always about games and graphics; nothing I could get interested in. With the microcontroller I can use my love of programming to make real things happen. It is so much more interesting and challenging.
Very respectfully,
Richard
Thanks from me, as well! I had started down the garden path of something a bit more complicated. I'm glad you jumped in!
-Phil
Does this look like I am on the right track?
'Master program outline
MTX PIN 0 'master send
MRX PIN 1 'master receive
'initialize
LOW MTX
LOW MRX
DO
DO
'main routine
UNTIL 'something to send
'send routine
HIGH MTX 'signal slave to receive command
LOOP UNTIL MRX 'wait until slave ready to receive
PAUSE x 'required delay
SEROUT MTX, 16780, [noparse][[/noparse]commandOut] 'send command
'if no response from slave required then
LOW MTX 'tell slave done
'if response from slave required then
PAUSE y 'required delay
SERIN MRX, 16780, [noparse][[/noparse]responseIn]
LOW MTX 'done
LOOP
'note: x and y determined by experimentation
'
'Slave program outline
STX PIN 0 'slave send
SRX PIN 1 'slave receive
'initialize
LOW STX
LOW SRX
DO
LOOP
'do things until master wants
'to send a command
UNTIL SRX
HIGH STX 'tell master ready to receive
PAUSE y 'whatever delay required
SERIN SRX, 16780, [noparse][[/noparse]commandIn]
'lookup required action
SELECT commandIn
CASE ...
CASE ...
.
ENDSELECT
'if no response required then
LOW STX 'done
'go do what command required
'else if response required then
'get response
PAUSE y 'required delay
SEROUT STX, 16780, [noparse][[/noparse]responseOut]
LOW STX 'done
LOOP
'note: x and y determined by experimentation
The only place you need a PAUSE is before the master's SEROUT.
This allows the slave to begin the SERIN statement before the characters start arriving.
The only place you need a LOW MTX is at the end of the whole routine to set up for the next command.
Once the master gets the go ahead from the slave, they don't need to "handshake" back and forth.
Each "knows" what the other expects.
Do I need to place 220 ohm resistors between the BS2 and the Transceiver? How about when I am just tying directly between two BS2's for simple communication, are resistors needed?
Thanks,
Richard
What this does is, protect the I/O pins in the possiblity that you drive one pin high, and one pin low, at the same time. Without some resistance in the line, you get a dead short through the I/O pins, and one or both of the I/O pins will burn out. But WITH the resistance in the line, the current is reduced to the point where it won't destroy the I/O pins.
Now, if you're driving a MAX232 chip, then you won't have "two drivers" on the same line, so you don't need a resistor to limit the current then.
-Phil