EmbDev.net

Forum: µC & Digital Electronics How to combine I²C/TWI, SPI and UART on one connector?


von Torsten C. (torsten_c84)


Rate this post
useful
not useful
Hello!

I²C (aka SMBus/TWI), SPI and TTL-UART are widely used for robotics and 
model-building (RC Helicopter, Lego, ...)

I want to use the same connector-type for all of these three protocols 
alternatively.

Lego Mindstorms combines SCL/RXD on one pin alternatively, and SDA/TXD 
on the other.

In contrast at the ATtiny1634 SDA, RXD and MOSI are on the same pin.

I want to be compatible as much as possible.

Do you know other examples? Which signals should I combine on the same 
pin?

BTW: I know the electrical issues (OC/pullup/tristate), that's not my 
question.

Torsten

von tellme (Guest)


Rate this post
useful
not useful
Torsten C. wrote:
> I want to use the same connector-type for all of these three protocols
> alternatively.

Torsten C. wrote:
> I want to be compatible as much as possible.

What's your goal / why do you want this? Tell us about your 
use-case(s)..

von peda (Guest)


Rate this post
useful
not useful
Combining different busses into the same wires, has the effect, that 
only one of these can be used on the whole project.

So why different busses at all ???

von peda (Guest)


Rate this post
useful
not useful
I2C on a device, which expect UART cause rubbish.
UART on a device, which expect I2C cause rubbish too.
SPI on a device, ...

It's fundamental, that all devices on the same bus speak the same 
language.

von Torsten C. (torsten_c84)


Rate this post
useful
not useful
tellme wrote:
> why do you want this?

I want to reduce the amount of necessary adapters for my different 
embedded projects. Sensors and actors should be interchangeable.

PS: Please don't think, I want to combinine different busses into the 
same wires.

tellme wrote:
> Tell us about your use-case(s).

The use-case: Different peripherals (sensors, actors, ...) with 
different protocols (USB, TWI, SPI and UART) on the same connector.

It's nearly the same as with Lego NXT and EV3 or with the FSA9280A in 
mobiles.

My problem: There is no standard. I hope, there is a commonly used 
assignment. But up to now I only know 2 examples: ATtiny1634 and Lego 
EV3. And these two examples are exactly vice versa. :-(

I tend to be compatible to Lego EV3 and FSA9280A:

SCL = RXD = USB-DP
SDA = TXD = USB-DM = MOSI

I²C-SCL can be SPI-MISO or SPI-SCLK ?!

: Edited by User
von peda (Guest)


Rate this post
useful
not useful
Torsten C. wrote:
> The use-case: Different peripherals (sensors, actors, ...) with
> different protocols (USB, TWI, SPI and UART) on the same connector.

Then the connector must be wide enough to carry separate pins for each 
bus.

von Torsten C. (torsten_c84)


Rate this post
useful
not useful
peda wrote:
> the connector must be wide enough

You need separate pins for each bus, but not for different protocols on 
different busses.

So, that's not the quetion. I want to use one of those protocols
alternatively with the same pins, as I said. ^^

Do you know Lego EV3 Sensors and mobiles with FSA9280A? They have no 
separate pins.

Do you know other examples with SPI and TWI?

PS: I wrote:
> Different peripherals on the same connector.

Sorry, I meant on different connectors with the same pinout. The 
headline should be:

How to combine I²C/TWI, SPI, UART and USB in one pinout?

: Edited by User
von peda (Guest)


Rate this post
useful
not useful
Torsten C. wrote:
> Do you know Lego EV3 Sensors and mobiles with FSA9280A? They have no
> separate pins.

As I said, then you can only use one bus on a project.

To communicate with I2C slaves you must first disconnect all UART slaves 
and vice versa.

The master (Lego EV3) can change its configuration at run time, but it 
can't be done by a slave. The slave was always only I2C or only UART.

von Torsten C. (torsten_c84)


Rate this post
useful
not useful
peda wrote:
> As I said.

We both said or meant the same. ;-)

One example:

I 've a 8-ch remote switch for 230V mains that understands all mentioned 
protocols. It may be selectable by DIP-SW or auto-detect.

I want to connect it
- to Lego NXT via I²C,
- to Lego EV3 via UART,
- to my fish tank (aquarium controller) via SPI and
- to my PC via USB.

And all that without the need of crossing wires.

Technical this is "no problem". I'm uncertain about the signal-mapping 
(pinout), because it sould be as compatible as possible.

So: Do you know other examples with SPI and TWI?

Perhaps it's typical German: Everything has to be standardized. ;-)

: Edited by User
von braintu (Guest)


Rate this post
useful
not useful
Come on guys, the question is not so hard to understand. The advantage 
he is going to gain is that he can always use the same cables and buy 
connectors in higher volumes.

Alternatively means: either one or the other!!

To answer your question:
I would not take the AVR as a reference. Take any other microcontroller 
and you will see that they combine different pins. - It depends on the 
silicon inside...

I would do it this way:
1       2       3       4
SCLK  MOSI  MISO  SCS  [SPI]
-       TX      RX      -    [UART]
SCL     SDA or  SDA     -    [I2C]
[clock] [out*]   [in*]

*out and in are refering to the controller.

I think it is also very handy to add some power pins to your 'standard', 
e.g. 3V3, 5V, 12V or so.

Best,
braintu

von Patrick C. (pcrom)


Rate this post
useful
not useful
Guck auch mal hier : (sorry, English)
http://www.i2cchip.com/mix_spi_i2c.html

von Torsten C. (torsten_c84)


Attached files:

Rate this post
useful
not useful
@braintu + Patrick: Many thanks + vielen Dank. :-)

braintu wrote:
> I would do it this way:
> 1   2   3   4 …

First, I had the same thought. I meditated long on the connector 
technology. After all, I choose 5-Pin Mini-USB, although SPI with 3 
wires may be a problem.

I choose Mini-USB, because the connectors are very cheap (few cents on 
aliexpress) and receptables are available as SMT and THT.

Or do you think, another connector would be better?

Bidirectional SPI is also possible, if master and slave know, when to 
change the direction.

Attached my proposal "UniversalConnector.png".

Lego-RJ12 is used for Lego mindstorms sensors, EV3 and NXP. I'll build 
some adapter.

● 1,8..5,5V: Power from master to slave
● VDD: CPU-Voltage from slave to master (for level-shifter if necessary)
● Data?: Data-Wire for 1Wire-Slaves: I'm uncertain about the pin

Any comments? Or is it a good idea?

: Edited by User
von Torsten C. (torsten_c84)


Attached files:

Rate this post
useful
not useful
Sorry, I confound the RS-485 pins (A=+ / B=-).
Lego NXT also supports RS 485:
http://ev3-wissen.engeln.info/doku.php?id=pin-belegung_der_nxt_western-stecker_kabel

An alternative with bigger connectors (not for RC Helicopter) is RJ45.

The benefits compared to 5-Pin Mini-USB are:

● There are cheap and ready to use Ethernet patch cables available.
● You have more wires, e.g. for bidirectional SPI
● You can group into "in", "out" and "clock", like braintu ^^

But using these cables means, you have to be aware of the twisted pairs, 
if you assign the signals to the pins.

I found many examples for RS-485 on RJ45, which didn't fit to the 
twisted pairs of Ethernet patch cables.

A good suggestion was on doityourselfchristmas.com, but you could also 
be geared to the standard "POE DC on spares".

For an "universal RJ45 connector", the signals for the other protocols 
have to be assigned. My idea is attached in the picture.

One Problem: I need different adapter for Lego I²C and Lego UART.

: Edited by User
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.