I2C vs Token Ring
February 18, 2008 07:54AM
As far as I understand, Token Ring topology used now for parts interconnection (maybe I wrong).

Why don't we use more standartized interfaces like I2C for this? It looks easier and wiring should be much simpler...and so on.
Anonymous User
Re: I2C vs Token Ring
February 18, 2008 09:15AM
The current token ring topology makes testing of individual controllers really simple, since less things can go wrong and most people understand rs232 serial lines. Testing i2c connections always requires at least two controllers, since the host computer doesn't speak i2c.

When using more than one controller in this token ring setup however, you get all the problems you can have with one controller multiplied by the number of controllers, since any one of them can really mess up everything. In this case i2c is much better.

So, testing is easier (only need one controller). Actually making a working setup with 4 or 5 controllers is much harder. Not to mention that using the token ring makes round-trips too slow to synchronize the 3 axis, so you need a sync line as well.

What is even simpler than token ring or i2c is using just one controller (Arduino). Or use a USB hub to connect all controllers and broadcast from the host for synchronized operations (not implemented right now).

--Blerik
Re: I2C vs Token Ring
February 18, 2008 09:44AM
If you use a 40 pin controller with an on-board USB circuit like the 18F4550 you have enough pins to control all of the functions. That gets rid of your hub, your Max232 serial comms card and an awful pile of components.
Re: I2C vs Token Ring
February 22, 2008 02:47PM
And the cost?
Re: I2C vs Token Ring
February 22, 2008 03:59PM
"And the cost?"

Trivial. I get rid of the MAX232 board and my 18F4550 costs about $8.50 in one-off lots (half that if you buy 25).

You also have one board instead of 5-6. If you think the cost of the microcontroller is too dear, consider that the 10 foot USB cable cost me $10.50. eye popping smiley
Re: I2C vs Token Ring
February 24, 2008 05:42PM
3 meter USB cable, but why?

To be honest, you can get pretty much all the electronics on the Arduino, thats around 20 GPIO pins. And cost wise I was referencing the first post, I2C is complicated, however RS232 is pretty much standard on almost all uCs and requires the minimal of code.
JBB
Re: I2C vs Token Ring
March 09, 2008 09:30PM
As nophead found out, I2C isn't really suitable for communications between circuit boards because it's a bit sensitive to noise.

There are two reasons for this:

Firstly, it is an open-collector bus which uses pull-up resistors to bring the bus high. This means that the signal can be pulled low by external noise or mucked up by the capacitance of long leads.

Secondly, the interface is a so-called single-ended type - the clock and data signals are transmitted by one wire each and ground. If other equipment is connected to the same ground lead it can interfere with the comms.

Communications protocols such as RS232 get around these issues by using signals which are driven to both rails (i.e. don't rely on pull-up resistors) and by using fairly high voltages (+/-12V in old RS232) for the signals.

If people are interested in bus type communications, RS485 is a good contender - it can operate across several hundred meters of cable (although it gets a bit slow) or up to rather high (tens of megabits) data rates. It uses two wires with differential signalling and ground. It is widely used in industrial systems which is a good sign.

Alternatively, the CAN protocol has some nice features for this kind of project, including automatic priority scheduling and checksum based error protection, but it is a licensed protocol which means that the chips cost a little more. Atmel (AVR) and Microchip (PIC) microcontrollers are available with built in CAN.

Jono
Re: I2C vs Token Ring
March 11, 2008 10:42AM
JBB: do you have any suggestions on an intro to RS485 for beginners?

i think one of the reasons the project doesnt use all the things it should be using is that people arent familiar with the technology. not all of us are professionals (i'm certainly not!), but we do all share a common passion to make this technology succeed, even if we sometimes go down the wrong path =)
JBB
Re: I2C vs Token Ring
March 11, 2008 11:47PM
No worries. I have a little bit of industrial design experience but I'm not an expert.


RS485 COMMUNICATIONS

Shamefully tracked down on Wikipedia, [www.lammertbies.nl] has a bit of an intro.

Basically, a single comms lead would daisy chain each board on the Reprap to the next (the standard does NOT like branches for reasons to do with the high frequency behavior of cables), and all communicating devices would be connected to it in parallel. The RS485 specifies a maximum of 32 devices on the bus, which should be plenty...

On each board, an RS485 converter chip would interface the comms line to the UART of whatever microcontroller was used. There are a huge range of devices available, for example the Analog Devices ADM483. If people need signal isolation, the ADM2485 is perfect for the job.

Unfortunately, there is a catch: because all devices are connected onto the same bus, only one device can 'talk' at a time. The microcontroller software must handle this and drive an enable pin on the converter chip accordingly.

In summary, the advantages of RS485 are:
1) Multidrop communication (many devices on bus).
2) Differential signalling reduces noise sensetivity / allows higher transmission speed.
3) Easy wiring (twisted pair and earth).
4) Easily interfaced to common microcontrollers.

Two major disadvantages in using RS 485 are:
1) The control software has to control who' s talking on the bus (formally called arbitration)
2) You can't just plug it straight into your computer for debugging: an adaptor would be required.

And now, as one or more people interested, some words about CAN.

CAN-BUS COMMUNICATIONS

[www.kvaser.com]

The CAN-Bus was developed for communications inside automobiles. It is also a two wire (plus earth) bus, allowing comms between multiple devices.

The three major features of CAN that I think might interest people are:
1) the hardware automatically does the bus arbitration based on the priority of each message. This makes the coding easier.
2) the hardware automatically uses a CRC-16 to verify each packet. If any data is corrupted, the receivers on the bus automatically request a retransmission. This makes the coding much easier.
3) A wide variety of mircos (PIC, AVR, ARM etc) come with CAN built in - saving circuit board real estate.

And of course, there are some problems:
1) CAN version 1 only allows for 8 bytes of data per transmission. Of course, the command 'move XY stage to (100,200)' should fit in that envelope so it's probably fine...
2) The message transmission mechanism seems to be a little odd.
3) You'll need an adapter to connect it to your computer.

I hope this helps people with their deliberations...

Jono
Re: I2C vs Token Ring
March 27, 2008 04:10PM
JBB wrote:

"Communications protocols such as RS232 get around these issues by using signals which are driven to both rails"

I dont understand this part. Could you elaborate a bit more?
For a simple rs232 communication 3wire required (RX, TX, GND).

Do you mean, that the logical one is -5V and the logical zero is +5V and the 0V is not valid?

---
As I see the rs232 and RS485 are really the same. They are the same serial communication, just the signal levels are different.
(rs232: rx,tx,GND; RS485: rx+,rx-,tx+,tx- (and no GND)

So from the microcontroller point of view they are the same. The pic communicate, and there is an appropriate level converter chip for RS232 (MAX232) and for RS485(MAX485) which convert the 0V,5V signal to rs232(1: -5V,0: +5V) or to rs485(1: -5V,5V 0: 5V,-5V)

The rs485 are widely used, most plc use this type of physical layer, and many other protocol is based on rs485 physical layer (profibus comes to my mind)

The difficulty (as I see) for the microcontroller, that there is only one hardware UART device. So communicating with computer and with other devices requires two rs232 interface, so it would require two uart in the pic. We can workaround by this, there are software rs232 implementation which use interrupts for the timing, but it complicates things a lot.

Oh and there are many rs232-rs485 converters out there, or we can build one (many schematics are available on the net), so monitoring an rs485 line is not really more complicated as monitoring an rs232 line.

An another note. There are the half duplex rs485 too, which use only two cable, and the two devices can not communicate in the same time.
Many source refer for this half duplex communication as rs422.
(although I have buyed a device which said he communicates rs485, and only two wires was required and the communication was half duplex.
So the naming is not straightforward.)

I hope I cleared the things a bit up.

Khiraly
jbb
Re: I2C vs Token Ring
March 29, 2008 03:39AM
Hey there Khiraly.

By 'driven to both rails,' I mean that each output on the chip has two transistors, one to drive the output high and the other to drive it low. This is good because it means that there will be plenty of current available (10 - 100mA typically) to rapidly force the line voltage to change. Remember that the comms cable may have quite a lot of capacitance that needs to be charged / discharged.

In contrast, I2C uses pull up resistors. The lines are pulled low by a transistor in the transmitting device, but when a high level is required the pull up resistors must charge up the cable capacitance all by themselves. In order to get fast response, the resistors must be made small, but this results in excessive current dissipation in the LOW state.

In other words, with a pull up resistor there is a trade off between high speed and low current operation, while a fully driven output you get the best of both worlds.

With the RS-485 vs RS-422 thing, the signal levels are the same but the configuration is different. I'm not sure of the formal definitions, but the most common configuration seems to be half-duplex RS485 which needs two wires plus earth, and can allow for bi-directional comms between up to 32 devices.

If people need more than one UART on a micro, it is possible to switch the outputs of one UART back and forth between two different circuits, or create a software UART (there is absolutely nothing wrong with this approach provided the software is well written) or simply buy a micro with more than one UART on it.

Jono
Re: I2C vs Token Ring
March 30, 2008 06:28AM
"but the most common configuration seems to be half-duplex RS485 which needs two wires plus earth"

I dont think earth is required. If it is half duplex it is only two wires BUS+, BUS-.

I had a device, were the pinouts was:
24V, GND, BUS+, BUS-

But I think the GND is not a requirement for the communication.
Simply it is often the case, that there is a GND line, but it is for power supply, and not because the communication requires it.

Could you check your source please? (i tried to digg a bit more, and I think Im right, but would be nice, if you could confirm it)

ps: thanks for the explication by the way!
Best regards,
Khiraly
VDX
Re: I2C vs Token Ring
March 30, 2008 02:39PM
... i have some RS232-RS485-converters, which drives the RS485-side with only two wires ...

Viktor
Re: I2C vs Token Ring
March 30, 2008 04:06PM
RS485 can cope with about 7v (I think) difference in the ground potential of the transmitter and the receiver. Any voltage less than this limit has no effect on the signal as the receiver works on the difference of its two inputs. This has two major advantages in noisy environments: -

1) If you use a twisted pair to make the connections then any radiated noise induces roughly the same voltage on each line. When the receiver takes the difference this cancels out.

2) Any "ground bounce" which is a change in the local ground voltage due to current flowing in the supply rails, e.g. motor currents, adds a voltage to both lines and again the receiver is unaffected.

There has to be some ground connection between transmitter and receiver but it is usually the 0V power connection or mains earth if going between two systems.

In contrast a with a non differential comms link any noise on the ground or any noise on the signal line add or subtract from the logic level seen at the receiver. RS232 tackles this problem by using large voltage swings. It is generally unwise to transmit 5V TTL levels from one board to another if there are large ground currents or noisy DC motors. 5V CMOS signals are not quite so bad because it has higher noise margins in the logic levels.


[www.hydraraptor.blogspot.com]
Re: I2C vs Token Ring
April 24, 2008 11:05AM
In terms of purely signaling (The physical Layer in networking terms) the currently emerging standard is LVDS (Low Voltage Differential Signaling) and is built in as common to some of the leading programmable Logic Silicon (Xilinx Spartan3e).

aka47


Necessity hopefully becomes the absentee parent of successfully invented children.
JBB
Re: I2C vs Token Ring
April 27, 2008 10:54PM
LVDS is turning up in a few places, and it is of course possible to get CMOS / LVDS converter chips, but they are more specialised than RS485 chips and we don't need the stupendous data rates (100 Mbit/sec and up).

Programmable logic chips (CPLD / FPGA etc.) do have some advantages (for example, customised I/O units for steppers etc and the opportunity to use multiple embedded microcontrollers), but they are pretty tough to get started with, particularly if one isn't great shakes with electronics.
Re: I2C vs Token Ring
December 06, 2009 02:53AM
khiraly Wrote:
-------------------------------------------------------
> JBB wrote:
>
> "Communications protocols such as RS232 get around
> these issues by using signals which are driven to
> both rails"
>
> I dont understand this part. Could you elaborate a
> bit more?
> For a simple rs232 communication 3wire required
> (RX, TX, GND).
>
> Do you mean, that the logical one is -5V and the
> logical zero is +5V and the 0V is not valid?
>
> ---
> As I see the rs232 and RS485 are really the same.
> They are the same serial communication, just the
> signal levels are different.
> (rs232: rx,tx,GND; RS485: rx+,rx-,tx+,tx- (and no
> GND)
>
> So from the microcontroller point of view they are
> the same. The pic communicate, and there is an
> appropriate level converter chip for RS232
> (MAX232) and for RS485(MAX485) which convert the
> 0V,5V signal to rs232(1: -5V,0: +5V) or to
> rs485(1: -5V,5V 0: 5V,-5V)
>
> The rs485 are widely used, most plc use this type
> of physical layer, and many other protocol is
> based on rs485 physical layer (profibus comes to
> my mind)
>
> The difficulty (as I see) for the microcontroller,
> that there is only one hardware UART device. So
> communicating with computer and with other devices
> requires two rs232 interface, so it would require
> two uart in the pic. We can workaround by this,
> there are software rs232 implementation which use
> interrupts for the timing, but it complicates
> things a lot.
>
> Oh and there are many rs232-rs485 converters out
> there, or we can build one (many schematics are
> available on the net), so monitoring an rs485 line
> is not really more complicated as monitoring an
> rs232 line.
>
> An another note. There are the half duplex rs485
> too, which use only two cable, and the two devices
> can not communicate in the same time.
> Many source refer for this half duplex
> communication as rs422.
> (although I have buyed a device which said he
> communicates rs485, and only two wires was
> required and the communication was half duplex.
> So the naming is not straightforward.)
>
> I hope I cleared the things a bit up.
>
> Khiraly


RS422 is full-duplex communication.For RS485,it can work for only connect 2 wires,but I suggest you to connect 3 wires,it will be better.

---------------------------------------------------------------------------
pc adapter: www.shopsintech.com
Re: I2C vs Token Ring
December 17, 2009 06:48PM
I am struggling with the idea of 485 being 3 wires.

As it is a form of differential (multi-drop resistor terminated bus) signaling (best down a twisted pair) I am not sure where your third wire comes from unless you are referring to screened cabling and connectors. In which case only one end of the screen is connected to ground so as to avoid hum loops.

?????????


Necessity hopefully becomes the absentee parent of successfully invented children.
jbb
Re: I2C vs Token Ring
December 17, 2009 09:47PM
Hi aka47

I can see the confusion about the 3rd wire, and I agree that screened cables should be treated with care lest one get the dreaded hum. A 2 wire connection would probably work OK, but will not be as reliable as the 3 wire connection...

RS485 measures the voltage difference between two wires, A and B[/Ai]. In an ideal world, all a receiver cares about is the differential voltage (A-B), and so a 2 wire connection would be OK.

In the real world, the signals A and B have to go through electronics, and will be handled as (A-G), (B-G) for a little while before being fed into the innards of a comparator circuit (where G is the receiver ground). If the ground of the receiver suddenly jumps way up above the ground of the transmitter because of ElectroStatic Discharge (ESD), we might see (A-G) = 1001 V and (B-G) = 999 V. On paper, (A-B) = 2V and everything's OK, but in the real world the poor little chip isn't going to like this much, and the internal ESD diodes will try to protect it, but the signal will be corrupted and over many such cycles the chip will be mechanically damaged. By using a third conductor, the difference between the receiver ground G and the transmitter ground 0 is controlled and we get a more reliable link.

In the case of RepRap, we will be reticulating DC power around the place anyway, so an earth connection will already be available.

I hope that this make sense to you

jbb
Re: I2C vs Token Ring
December 17, 2009 10:35PM
still have to deal with motor noise turning up on ground leads, which it invariably will. a separate signal ground would be best, but tends to be tricky to implement effectively in terms of getting information from signal-grounded to power-grounded electronics without dumping half the motor noise down the signal ground.

differential signalling already helps massively with this, so may be a complete non-issue in this situation.
Re: I2C vs Token Ring
December 18, 2009 06:24PM
Sorry to disappoint (And experience installing and using 485 in adverse conditions supports this) 485 is a two wire differentially signaled medium. Just about always carried out using a twisted pair. A screened twisted pair cable may be used but the screening is never connected at both ends and therefore takes no part in the signaling. Ergo two cables.

Over the short haul that we are talking about (ie RepRap) environmental electrostatic issues are not an issue. Twisted pair and differential signaling is more than adequate to resist common mode interference. Not withstanding this some may prefer to use screening in addition to protect against interference (Belt and braces)

If we were talking about longer distance data comms electrostatics become a serious issue and need serious consideration. And I think I would be partially agreeing with you.

The only perfect medium for long distance comms (from an interference and electrostatics perspective) is at the moment optical ie fibre.

As it is then, an unshielded twisted pair is more than adequate for the task in hand.


Necessity hopefully becomes the absentee parent of successfully invented children.
Re: I2C vs Token Ring
December 19, 2009 02:36PM
CAN is differential in the same way, the hardware support for CAN is vastly superior to RS485 from the perspective of software. Making the implementation much simpler.

The issue with comparison to RS485 is packet size (still 8 bytes in CAN 2.0cool smiley

And bus speed is limited to 1Mbit, where as a well setup RS485 can handle 12Mbit.
Re: I2C vs Token Ring
December 19, 2009 06:32PM
I guess the line termination (a resistor across A and B at both ends of the bus) in 485 helps to keep the A to B differential within a sensible range.


Necessity hopefully becomes the absentee parent of successfully invented children.
Re: I2C vs Token Ring
December 19, 2009 11:35PM
AK47 is bang on with his comments we do not have the kind of enviroment or distance to warant anything other that a two wire solution.

Now if we were talking about cables above 1Km situated in a car factory or power station where there is sparking igniters or factory spot welding, Arc welding, or with heavy duty motors, we would start to become concerend about signal to noise levels.

Rs422 spec 1.2 Km the speed of signals start to be affected..and must be reduced.


Bodge It [reprap.org]
=======================================

BIQ Sanguinololu SD LCD board BIQ Stepcon BIQ Opto Endstop
BIQ Heater Block PCB BIQ Extruder Peek clamp replacement BIQ Huxley Seedling
BIQ Sanguinololu mounting BIQ standalone Sanguinololu or Ramps mounting Print It Stick It Cut it


My rep strap: [repstrapbertha.blogspot.com]

Buy the bits from B&Q pipestrap [diyrepstrap.blogspot.com]
How to Build a Darwin without any Rep Rap Parts [repstrapdarwin.blogspot.com]
Web Site [www.takeaway3dtech.com]
Re: I2C vs Token Ring
December 21, 2009 04:11PM
Interestingly enough (although not entirely related) FPGA's that have LVDS (Low Voltage Differential Signaling) built in are becoming common.

I think they should support quite high data rates over a short haul.


Necessity hopefully becomes the absentee parent of successfully invented children.
Re: I2C vs Token Ring
January 18, 2010 11:59AM
Hello,

I designed a small CNC machine based on Arduino and I2C controlled drivers. I2C works well as long as the drivers are shielded against EMF and the wires for the bus are kept as short as possible.

The Arduino runs a modified version of the RepRap G-Code interpreter, where I replaced the stepper control functions with my own sending I2C commands instead.

For more info, details, PCBs, source code please see my post here (sorry for the messy very long post smiling smiley ): [letsmakerobots.com]
Sorry, only registered users may post in this forum.

Click here to login