Comms protocol?

Go To Last Post
32 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will be making a single master - multi slave network.

Initially I am thinking of using I2C and just use a bus extender IC.
But is there perhaps a better way?

The setup is like this:
MASTER >> slaveA >> slaveB >> slaveC ... >> slaveX

But the slaves could be re-ordered in such a way as:
MASTER >> slaveC >> slaveX >> slaveA ... >> slaveB

And I would still have to know their order e.g. slaveX is to the right of slaveC and to the left of slaveA.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It would help to know how long your wires will be, but I think most people would favour RS485 or similar for such a network.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry. forgot to say that the wires will be (typically) 3-5 ft. that was why I was looking at I2C bus extenders (i think I2C cannot tolerate more than a few cm?)
And speed need not be fast at all. 1kbps is already very fast.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Personally, I would avoid I2C. It is designed mainly for communication between ICs on the same PCB. When it works, it's great, when you get problems it's messy(in my opinion).

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

midea31 wrote:

Initially I am thinking of using I2C and just use a bus extender IC.
...
And I would still have to know their order e.g. slaveX is to the right of slaveC and to the left of slaveA.

Without doing something clever you'll not do that easily with I2C.

To clarify... the 3-5ft figure; is that the total bus length or the distance between slaves?

Also, how much electrical interference from outside sources is likely to occur?

And, are the master and slaves all fed from the same power source?

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go with RS485. Much simpler to implement and you can go up to 4000 feet

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I agree. RS485 is the appropriate comms topography/hardware. I would also suggest that you consider the SNAP comms protocol ( www.hth.com/snap ).

Cheers,

Ross

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

485 is *probably* the best/easiest but the requirement to know the order the slaves are connected in is going to make the hardware a bit trickier. It's likely to need a doubling up of transceivers with the comms passing through each slave MPU. Which introduces the risk of downstream slaves losing comms when just one fails.

A relay, fed from some kind of watchdog, will add in fail-safe operation.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely having an identity marked externally on each module and to which it responds should solve that. The master could do a roll call to determine "who" is connected periodically. I don't see the need for any comms pass through, but maybe I have missed something.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A CAN bus might be a solution as well.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
To clarify... the 3-5ft figure; is that the total bus length or the distance between slaves?

3-5 ft distance per slave
Quote:
Also, how much electrical interference from outside sources is likely to occur?

hmm...I don't know, but there will be motors and such nearby the units.
Quote:
And, are the master and slaves all fed from the same power source?

Yes. Master has the power and feeds the slaves.
Quote:
Surely having an identity marked externally on each module and to which it responds should solve that.

The slave units cannot have a fixed identity since they could be re-ordered and shuffled.
E.g.
MASTER--slaveA--slaveB--slaveC
It is necessary for me to know their order. slaveA is the first, slaveB is second and slaveC is third.
But the customer could might as well connect the units as:
MASTER--slaveB--slaveC--slaveA
And I still would have to know that B is first, C is second and A is third.

I was thinking along these lines.
Power bus is controllable. Master is ready to give power to the slave that connects to it. Once that slave (say, slaveA) is already initialized, I will give it a unique address (say, 0x7F). Once it has an address, it can switch on or give power to the slave connected to it (say, slaveB). And then slaveB initializes and given a unique address (0x7E).
This would go on until all slaves are ready and initialized.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Consider something like this.

In addition to an RS485 single-master/multi-slave connection, have one enable output from the master and one from each slave, and an enable input to each slave. The wiring is such that the master enable goes to the "first" slave, and its enable goes to the "second" slave, on down the line.

When slaves boot up, their enable outputs are off (thus shutting down all slaves downstream), and when they see their enable input go active (initially this will be the first slave, driven by the master enable), they request an address. The master gives out addresses in order, let's say starting with 1. After the first slave gets its 1 address, sets its enable and the 2nd slave then requests an address (it would get 2) and so on down the line.

As long as an unpowered slave cannot appear to have its enable active, and as long as a slave continues to request an address until it receives one, I think this would be pretty bulletproof.

Last Edited: Wed. May 8, 2013 - 02:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is in reply to midea31...

Yes, you could do that, but... as Brian has said above, you are then exposed to the major fault scenario whereby the first or second or any nearby slave has a fault and fails to allow either messages to be passed down the line, or in failing causes the power to be disconnected down the line. RS485 hardware is meant to operate like a telephone party line; all slaves are in parallel for listening, but only one should "talk" at a time. If a slave goes faulty and you unplug it , all the downstream slaves then lose power.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kk6gm wrote:
Consider something like this.
How does it operate when a faulty slave is removed from an operating system? Clearly the enable lines must not be continually active, otherwise the units downstream would be instantly disabled when the slave is removed. So during powerup, a momentary enable signal is propagated downstream after each address assignment.

Let's say slave 7 is removed. The master polls 1...6 and receives its data, then tries 7, times out and continues down the line until the end of its initial address range. When does it "find" the replacement for 7 which has not yet been assigned an address or sent an enable pulse? How will unit 6 know to send an enable signal for under your proposal it is 6 that must send it?

Cheers,

Ross

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:
kk6gm wrote:
Consider something like this.
How does it operate when a faulty slave is removed from an operating system? Clearly the enable lines must not be continually active, otherwise the units downstream would be instantly disabled when the slave is removed. So during powerup, a momentary enable signal is propagated downstream after each address assignment.

Let's say slave 7 is removed. The master polls 1...6 and receives its data, then tries 7, times out and continues down the line until the end of its initial address range. When does it "find" the replacement for 7 which has not yet been assigned an address or sent an enable pulse? How will unit 6 know to send an enable signal for under your proposal it is 6 that must send it?

Cheers,

Ross


I would be surprised if this is a requirement. The 3rd slave suddenly needs to become the 2nd slave while the system is running, etc, etc?

But if this is a requirement, then I guess as soon as a NAK is detected from any slave, the master will initiate a re-address sequence. As soon as the master drops its enable, all the slaves would become disabled and would start the sequence.

EDIT: OK, I missed the big part, which is that a dead slave can't pass along the daisy-chained enable.

The only solution I can see at that point is to use dipswitches to ID each slave, and address them in the sequence their dipswitches call for. Assuming, I repeat, that the system can even function with a dead slave.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

CAN is a good way to go. Lots of microprocessors have built-in CAN bus controllers. CAN doesn't require a node to regenerate a signal, so it's passive. And passive if dead.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

oops ... for kk6gm

Let me illustrate why that won't work either.

Imagine that the OP's system is a fancy car wash with a barrier, car transport, water jets, brushes, air dryer and finally a sign telling the driver to drive off the mechanism. Each step is sequential and controlled by its own slave device.

In the unfaulty (sic) mode, the master accepts the coins and then commands the nearest slave (1) to do its thing, ie lift the barrier after which it indicates finished to the master.. The next nearest (2) starts the car transport mechanism thereby pulling the car under the water jets. 2 then says finished to the master and the master tells 3 to start spraying water. You get the idea.

In a fault situation that you have suggested if 1 fails, the old 2 becomes 1 and pulls the car through the unopened barrier. If the water jets (3) fails and the brushes (4) are reassigned 3, the car is brushed without any water.

No I don't think that works either. All control systems must be able to handle fault situations in a logical, safe way. Reassignment of ids in my example fail to achieve that.

Cheers,

Ross

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

stevech wrote:
CAN is a good way to go. Lots of microprocessors have built-in CAN bus controllers. CAN doesn't require a node to regenerate a signal, so it's passive. And passive if dead.
Can the "master" determine which CAN device is physically closest to the master without a pre-existing sequential identity as per the OP's requirement?

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The possibility here is for the master to have multiple RS485 transceivers - one per slave. The master can manipulate the enables on the rs485 tranceivers to talk to a specific slave.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:
oops ... for kk6gm

Let me illustrate why that won't work either.

Imagine that the OP's system is a fancy car wash with a barrier, car transport, water jets, brushes, air dryer and finally a sign telling the driver to drive off the mechanism. Each step is sequential and controlled by its own slave device.

In the unfaulty (sic) mode, the master accepts the coins and then commands the nearest slave (1) to do its thing, ie lift the barrier after which it indicates finished to the master.. The next nearest (2) starts the car transport mechanism thereby pulling the car under the water jets. 2 then says finished to the master and the master tells 3 to start spraying water. You get the idea.

In a fault situation that you have suggested if 1 fails, the old 2 becomes 1 and pulls the car through the unopened barrier. If the water jets (3) fails and the brushes (4) are reassigned 3, the car is brushed without any water.

No I don't think that works either. All control systems must be able to handle fault situations in a logical, safe way. Reassignment of ids in my example fail to achieve that.

Cheers,

Ross


I agree that reassigning IDs is an unlikely requirement and I made a point of saying that, but I thought that's what you were asking about, so I offered a potential solution.

Note that, as in most systems, a failed slave in your car wash shuts down the entire system in any case, so how the addressing works with a failed slave is not an issue.

The solution I would use to address slaves independently of other slaves is to have a location-specific ID communicated to the slave. This could either be dipswitches on the slave, or jumpers in the wiring harness that the slave reads to know its location in the chain.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
The possibility here is for the master to have multiple RS485 transceivers - one per slave. The master can manipulate the enables on the rs485 tranceivers to talk to a specific slave.
thats not how rs485 works
The slaves sit listening for a frame of data with their address in it. When they see their address they in turn respond by asserting their comms enable to the transceiver chip bringing it active on the bus and the slave then transmits back to the master. Once done the slave de-asserts the enable and goes back to listening for its address. This is the simplest form of re485 communications

This takes place in every slave on the bus. Very simple and very effective.

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim,

Russell is suggesting that having multiple RS485 lines would be the way to 1)know which slave is physically nearest to the master and 2) overcome the failure of the whole system if one slave goes down (assuming that the whole system is not my car wash example and dependent upon the earlier slave operating correctly)

I don't see why it wouldn't work. At the very worst, your local cable salesman would sell more cable. But of course your master would have to have enough pins to drive multiple RS485 lines.

And, I am certain that Russell knows about how RS485 works :lol:

Cheers,

Ross

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hmmm...
it would seem I haven't put enough thought into this.
thanks all.

I have already ordered the I2C bus extender and awaiting them for testing.
I have also put an order on RS485 transceivers.
I hope to get to testing this weekend.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Ross for the kind words.
Jim -rs485 just specifies the hardware layer. As to how you manage addressing, that is up to the user. A recent project of mine used TDMA over RS485. The slaves do not listen for an address - they just know their timeslot. The master outputs a frame sync packet at regular intervals and the slaves derive their timing from that.

Nowhere is it said you can't use a star network and enforce addressing based on the segment. Ethernet switches do a similar thing but much smarter.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, now I know who 'Russell' is.

Russell/Ross, I am well aware of what RS485 is and how the actual data on it is the responsibility of the programmer. My posts were derived from the 'traditional' mindset of simply hang up to 32 transceivers on a 4000 foot run of twisted pair. Software does the rest. I also admit I have only skimmed this thread after my initial post as my thought was that this was to be a simple communications setup not CAN/self healing etc so my bad for not reading every detail as it seems that this project is far from simple then. :(

Quote:
A recent project of mine used TDMA over RS485. The slaves do not listen for an address - they just know their timeslot. The master outputs a frame sync packet at regular intervals and the slaves derive their timing from that.
It's eerie you mention this as I am trying to add a feature to a product I designed that works on a Solartron Orbit RS-485 network. They have a measurement mode called 'Dynamic' which does exactly what you just described. Depending on the number of readings/second dictates on how many sync pulses are output between frames.

Well, since Ross and Russell have given me a good thrashing for not reading all the posts I shall be quiet now....;)

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
Well, since Ross and Russell have given me a good thrashing ...
You're welcome. :lol: Always happy to help a friend.

Cheers,

Ross
ps Defn: Happy marriage: When a sadist marries a masochist.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Russell aka Karl Artman. Us Aussies are like brothers - we'll fight each other but given a common enemy, we'll fight them together!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not to turn this thread into something else. But I don't see myself as an enemy nor am I looking for a fight. I stand by my posts and two others posted about it otherwise. If this makes me an enemy then so be it

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No Jim, you are OK... for a Yank :lol: :lol: (ducking for the incoming heat-seeking missiles)

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
The slave units cannot have a fixed identity since they could be re-ordered and shuffled.
E.g.
MASTER--slaveA--slaveB--slaveC
It is necessary for me to know their order. slaveA is the first, slaveB is second and slaveC is third.
But the customer could might as well connect the units as:
MASTER--slaveB--slaveC--slaveA
And I still would have to know that B is first, C is second and A is third.

So isn't that a fixed identity?

If you have two UARTs per node you can use a redundant ring topology, that gives you an easy way to detect the location of each node and also give a high level of robustness.

_____
Rob

Scattered showers my arse -- Noah, 2348BC.
Rob Gray, old fart, nature photographer, embedded hardware/software designer, and serial motorhome builder, www.robgray.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jim, . I apologise if i've offended you. The intention was purely lighthearted.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ross/Russ,
No offense taken.

Cheers

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user