Re: Interfacing again

Richard Urwin <[email protected]> Wed, 29 Oct 2003 23:13:40 +0000
Newsgroups gmane.comp.hardware.avr.general
Message-ID <[email protected]>
On Wednesday 29 Oct 2003 10:14 pm, Jesse Hammons wrote:
> I was just about to ask about interfacing when I saw the question
> posted rescently in the archives.  However I still have the following
> questions:
>
> * What kind of datarate and cable length can I expect to get from SPI?
> (Or how do I calculate it)
>
> * Can I use a USB cable for SPI or UART?  I know it is non-standard,
> but they are good, plentiful, pre-made cables that are known to handle
> hi-speed.  I would like to get 100-400kbps.
>
> * I2c does my datarate *but* I would like to use the hardware UART on
> my avr chips if possible.  Only the large mega chips seem to have i2c
> in hardware.
>
> * Do I need to use interface chips to go distances of 5-6 feet?
> Assuming I only have my own devices on the bus, the logic level doesn't
> matter on the line as long as both avr chips interpret 1 as 1 and 0 as
> 0.  Would like to minimize serial glue components.
>
> People mentioned using port pins for chip select, but I can't run those
> extra lines.  I am hoping that the four wires on the USB cable will be
> enough for power, ground, clock, and serial data to connect my whole
> system (strange, I know, but it's kind of a ropelight thing with
> intelligent lights...)
>
> So basically my question is has anyone abused RS-232 in this way?
> Which is to say running at 100kbps or more, using the hardware UART,
> and going over a shielded cable.  If so how long were your cables?
>
> What about interfacing with a PC?  I assume for that I would need an
> RS-232 line driver to make sure the levels were correct.

It's not advisable to run RS232 or logic levels over twisted pair cables. You 
will get cross-talk between the wires in each pair. Twisted pair is designed 
for differential signals. Each pair should contain a single signal. Similarly 
putting the power next to the signals inside the same screen will reduce the 
signal to noise ratio. It's OK if the power is only to the line drivers, but 
not for the microcontroller's power, which will have large spikes and clock 
noise.

The rates and distances you want are not that demanding, so you should get 
away with it.

You probably need line drivers of some sort on the AVRs. PC printer ports use 
TTL buffers and unshielded ribbon cable with alternate cores as a "screening" 
ground, and are spec.ed to 5 feet (IIRC). They work at about the rate you're 
interested in. Open collector buffers are used by CANbus upto tens of feet at 
Mbps rates in very noisy environments, and should be fairly cheap. The specs 
are available on the net.

Remember: only connect screens at one end and use a seperate, low resistance 
path to ground for them.

HTH,

-- 
Richard Urwin