Re: RS-485 Networks

Started by Paul James E. April 26, 2004

Igor,

In a system I designed and built for in house testing where I work, I
had a need to address several slaves. In this case it was 8, but the same
idea can be expanded. What I did here was to reserve 3 pins on each slave
PIC as address pins. In the hardware at each slave socket, I hard wired
these 3 pins in each of the different configurations. All of the slave
boards are identical. So, lets say you pulled the slave out of socket 2
and put it into socket 5. When you repower up the system, the PIC reads
these 3 pins first thing after initialization, and puts the valuse in a
register. Now whenever the USART interrupts with data, the 9th bit is
checked, and if its an address, it compares the transmitted address to
the value in the register. If they match, it knows it's the addressed
unit. If not, it goes back to processing what it was working on before
the interrupt. This has worked well for over a year now. So if you can
spare 5 pins on the PIC, you could implement the same scheme.

Hope this helps you out. Regards,

JIm

> Hello,
>
> Application: There is one master device and many (up to 31) slave
> devices on half-duplex RS-485 network. All of these devices are PIC
> based and USART in asynchronous 9-bit mode is used (9th bit=0 data, 9th
> bit=1 address).
>
> Problem: I'm looking for some protocol that can allow automatic address
> assignment to slave devices after network is powered up. With every
> power-up event, master device doesn't know details about network
> configuration (how many slaves, what type, etc) so I need to check this
> somehow and to assign unique address to each slave. Some kind of
> plug-and-play. I'm going to design both master and slave devices so no
> problem with that.
>
> Example:
> First power up: 4 slave devices.
> Second power up: 7 slave devices.
>
> Rules:
> 1. You can't connect new slave device to network without shutting down
> the network first.
> 2. Master and all of the slave devices will use same communication
> protocol.
>
> What I'm trying to avoid:
> 1. DIP switch (no room for it, slave devices are sealed, etc.)
> 2. Unique ID for each manufactured device (makes manufacturing very
> complicated, etc.)
>
> Any idea? Web site? Document to download? Yahoo group to join? Keyword
> to search for?
>
> Regards,
> Igor >
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~--> Buy Ink Cartridges or Refill Kits for your
> HP, Epson, Canon or Lexmark Printer at MyInks.com. Free s/h on orders
> $50 or more to the US & Canada.
> http://www.c1tracking.com/l.asp?cidU11
> http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/dN_tlB/TM
> ---------------------------------~->
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions Yahoo! Groups Links >
>


Hello,

Application: There is one master device and many (up to 31) slave devices on
half-duplex RS-485 network. All of these devices are PIC based and USART in
asynchronous 9-bit mode is used (9th bit=0 data, 9th bit=1 address).

Problem: I'm looking for some protocol that can allow automatic address
assignment to slave devices after network is powered up. With every power-up
event, master device doesn't know details about network configuration (how
many slaves, what type, etc) so I need to check this somehow and to assign
unique address to each slave. Some kind of plug-and-play. I'm going to
design both master and slave devices so no problem with that.

Example:
First power up: 4 slave devices.
Second power up: 7 slave devices.

Rules:
1. You can't connect new slave device to network without shutting down the
network first.
2. Master and all of the slave devices will use same communication protocol.

What I'm trying to avoid:
1. DIP switch (no room for it, slave devices are sealed, etc.)
2. Unique ID for each manufactured device (makes manufacturing very
complicated, etc.)

Any idea? Web site? Document to download? Yahoo group to join? Keyword to
search for?

Regards,
Igor



Perhaps a solicon id can help you to give each slave an unique id without complex production:
http://www.maxim-ic.com/quick_view2.cfm?qv_pk)03&ln=

Marcel

Igor Janjatovic wrote:
> Hello,
>
> Application: There is one master device and many (up to 31) slave devices on
> half-duplex RS-485 network. All of these devices are PIC based and USART in
> asynchronous 9-bit mode is used (9th bit=0 data, 9th bit=1 address).
>
> Problem: I'm looking for some protocol that can allow automatic address
> assignment to slave devices after network is powered up. With every power-up
> event, master device doesn't know details about network configuration (how
> many slaves, what type, etc) so I need to check this somehow and to assign
> unique address to each slave. Some kind of plug-and-play. I'm going to
> design both master and slave devices so no problem with that.
>
> Example:
> First power up: 4 slave devices.
> Second power up: 7 slave devices.
>
> Rules:
> 1. You can't connect new slave device to network without shutting down the
> network first.
> 2. Master and all of the slave devices will use same communication protocol.
>
> What I'm trying to avoid:
> 1. DIP switch (no room for it, slave devices are sealed, etc.)
> 2. Unique ID for each manufactured device (makes manufacturing very
> complicated, etc.)
>
> Any idea? Web site? Document to download? Yahoo group to join? Keyword to
> search for?
>
> Regards,
> Igor >
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
> Yahoo! Groups Links >




>
>What I'm trying to avoid:
>1. DIP switch (no room for it, slave devices are sealed, etc.)
>2. Unique ID for each manufactured device (makes manufacturing very
>complicated, etc.)

I've done this with PC's before but never microcontrollers. This was on
PC's using TCPIP or RS232 rings.

Basically the server comes up and sends a global "HELLO ALL" packet
which the slaves hear. The slaves accept this packet and a "prepare."
The unidentified slaves then wait "A random amount of time" and send a
three digit random number to the master. Once the data is quiet the
master then sends the three digit sequence in reply tagging on an ID# for
the slave. The slave (single) responds with the same and an OK packet.
If received OK then the slave is told to standby and await data. This
takes it out of the "HELLO ALL" loop.

This sequence runs "for a reasonable time" until you are confident that all
slaves are likely to have been identified.

I've used this to allocate ID's to PC's in a random network when running
applications that require a good amount of redundancy. In my application
slaves pinged the server every few seconds and if my reply was found the
slave then took over the server's job and maintained the network. This also
involved distributing to all slaves the entire server data required for control.
This was burst randomly as bandwidth allowed.

It was a bitch to get right but it was immensely stable and secure from
machine fallouts when started. It also allowed new slaves to arrive at any
time if the "HELLO ALL" was broadcast occasionally.

There's probably better ways to do this, but I didn't have that info 4 years ago! :( Rv!

Sick of Spam? Visit http://keir.net/k9.html



Hello Marcel,

> Perhaps a solicon id can help you to give each slave an unique id without
complex production:
> http://www.maxim-ic.com/quick_view2.cfm?qv_pk)03&ln=
>
> Marcel

One of my first ideas, but... there are few problems with that. Devices are
supposed to be low cost so any additional hardware is not acceptable. That's
why I'm looking for "software" solution. Also, Maxim ID is very
long (64bit or something like that) and it takes too much time to check all
of the possible ID numbers. It's almost impossible to do it within some
reasonable time scale! Or I'm wrong about this?

Regards,
Igor

> Igor Janjatovic wrote:
> > Hello,
> >
> > Application: There is one master device and many (up to 31) slave
devices on
> > half-duplex RS-485 network. All of these devices are PIC based and USART
in
> > asynchronous 9-bit mode is used (9th bit=0 data, 9th bit=1 address).
> >
> > Problem: I'm looking for some protocol that can allow automatic address
> > assignment to slave devices after network is powered up. With every
power-up
> > event, master device doesn't know details about network configuration
(how
> > many slaves, what type, etc) so I need to check this somehow and to
assign
> > unique address to each slave. Some kind of plug-and-play. I'm going to
> > design both master and slave devices so no problem with that.
> >
> > Example:
> > First power up: 4 slave devices.
> > Second power up: 7 slave devices.
> >
> > Rules:
> > 1. You can't connect new slave device to network without shutting down
the
> > network first.
> > 2. Master and all of the slave devices will use same communication
protocol.
> >
> > What I'm trying to avoid:
> > 1. DIP switch (no room for it, slave devices are sealed, etc.)
> > 2. Unique ID for each manufactured device (makes manufacturing very
> > complicated, etc.)
> >
> > Any idea? Web site? Document to download? Yahoo group to join? Keyword
to
> > search for?
> >
> > Regards,
> > Igor




I haven't used them yet, but afaik there are special algorithms available to detect all devices on the
1-wire net. And remember, you only have to do this once on startup. Cost is $0.65 in quantities. Perhaps
the 1-wire net can be usefull to something else in your design.

Igor Janjatovic wrote:
> Hello Marcel,
>
>> Perhaps a solicon id can help you to give each slave an unique id without complex production:
>> http://www.maxim-ic.com/quick_view2.cfm?qv_pk)03&ln=
>>
>> Marcel
>
> One of my first ideas, but... there are few problems with that. Devices are
> supposed to be low cost so any additional hardware is not acceptable. That's
> why I'm looking for "software" solution. Also, Maxim ID is very
> long (64bit or something like that) and it takes too much time to check all
> of the possible ID numbers. It's almost impossible to do it within some
> reasonable time scale! Or I'm wrong about this?
>
> Regards,
> Igor
>
>> Igor Janjatovic wrote:
>>> Hello,
>>>
>>> Application: There is one master device and many (up to 31) slave devices on
>>> half-duplex RS-485 network. All of these devices are PIC based and USART in
>>> asynchronous 9-bit mode is used (9th bit=0 data, 9th bit=1 address).
>>>
>>> Problem: I'm looking for some protocol that can allow automatic address
>>> assignment to slave devices after network is powered up. With every power-up
>>> event, master device doesn't know details about network configuration (how
>>> many slaves, what type, etc) so I need to check this somehow and to assign
>>> unique address to each slave. Some kind of plug-and-play. I'm going to
>>> design both master and slave devices so no problem with that.
>>>
>>> Example:
>>> First power up: 4 slave devices.
>>> Second power up: 7 slave devices.
>>>
>>> Rules:
>>> 1. You can't connect new slave device to network without shutting down the
>>> network first.
>>> 2. Master and all of the slave devices will use same communication protocol.
>>>
>>> What I'm trying to avoid:
>>> 1. DIP switch (no room for it, slave devices are sealed, etc.)
>>> 2. Unique ID for each manufactured device (makes manufacturing very
>>> complicated, etc.)
>>>
>>> Any idea? Web site? Document to download? Yahoo group to join? Keyword to
>>> search for?
>>>
>>> Regards,
>>> Igor >
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
> Yahoo! Groups Links >




Hello Igor,

I'm finishing one project to a PROFIBUSS network that work with 16 slaves in
RS485, One address from PROFIBUSS work with 16 slave in my owner protocol. I
use DIP switch because the slave can be changed by the customer.
I pulled all of slave in a byte rate of the 19200 Hz and read or write data
depends on the kind of the slave, I use one byte to check sum.
It's to works in a industry environment and don't have problem.

Good look in your project.
Gilmar
----- Original Message -----
From: "Igor Janjatovic" <>
To: <>
Sent: Monday, April 26, 2004 12:40 PM
Subject: [piclist] RS-485 Networks > Hello,
>
> Application: There is one master device and many (up to 31) slave devices
on
> half-duplex RS-485 network. All of these devices are PIC based and USART
in
> asynchronous 9-bit mode is used (9th bit=0 data, 9th bit=1 address).
>
> Problem: I'm looking for some protocol that can allow automatic address
> assignment to slave devices after network is powered up. With every
power-up
> event, master device doesn't know details about network configuration (how
> many slaves, what type, etc) so I need to check this somehow and to assign
> unique address to each slave. Some kind of plug-and-play. I'm going to
> design both master and slave devices so no problem with that.
>
> Example:
> First power up: 4 slave devices.
> Second power up: 7 slave devices.
>
> Rules:
> 1. You can't connect new slave device to network without shutting down the
> network first.
> 2. Master and all of the slave devices will use same communication
protocol.
>
> What I'm trying to avoid:
> 1. DIP switch (no room for it, slave devices are sealed, etc.)
> 2. Unique ID for each manufactured device (makes manufacturing very
> complicated, etc.)
>
> Any idea? Web site? Document to download? Yahoo group to join? Keyword to
> search for?
>
> Regards,
> Igor >
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions
> Yahoo! Groups Links >
>




It would take centuries to poll all the addresses in a 64 bit value.  What you do is broadcast (send to all addresses, or unaddressed) a request for devices to identify themselves.  (Or they can simply start the process on power on.)  After which each device waits a random amount of time and then sends its ID.  Then you look for that ID in a table, and if it is found, you know that device already, and if not, then you add it to the table, and send a byte corresponding to that table position (for example 1 to 8 for and 8 device table) and that becomes his address.
 
Not as easy as some methods, but it works.
----- Original Message -----
From: Igor Janjatovic
To: p...@yahoogroups.com
Sent: Monday, April 26, 2004 11:03 AM
Subject: Re: [piclist] RS-485 Networks

Hello Marcel,

> Perhaps a solicon id can help you to give each slave an unique id without
complex production:
> http://www.maxim-ic.com/quick_view2.cfm?qv_pk)03&ln=
>
> Marcel

One of my first ideas, but... there are few problems with that. Devices are
supposed to be low cost so any additional hardware is not acceptable. That's
why I'm looking for "software" solution. Also, Maxim ID is very
long (64bit or something like that) and it takes too much time to check all
of the possible ID numbers. It's almost impossible to do it within some
reasonable time scale! Or I'm wrong about this?

Regards,
Igor

> Igor Janjatovic wrote:
> > Hello,
> >
> > Application: There is one master device and many (up to 31) slave
devices on
> > half-duplex RS-485 network. All of these devices are PIC based and USART
in
> > asynchronous 9-bit mode is used (9th bit=0 data, 9th bit=1 address).
> >
> > Problem: I'm looking for some protocol that can allow automatic address
> > assignment to slave devices after network is powered up. With every
power-up
> > event, master device doesn't know details about network configuration
(how
> > many slaves, what type, etc) so I need to check this somehow and to
assign
> > unique address to each slave. Some kind of plug-and-play. I'm going to
> > design both master and slave devices so no problem with that.
> >
> > Example:
> > First power up: 4 slave devices.
> > Second power up: 7 slave devices.
> >
> > Rules:
> > 1. You can't connect new slave device to network without shutting down
the
> > network first.
> > 2. Master and all of the slave devices will use same communication
protocol.
> >
> > What I'm trying to avoid:
> > 1. DIP switch (no room for it, slave devices are sealed, etc.)
> > 2. Unique ID for each manufactured device (makes manufacturing very
> > complicated, etc.)
> >
> > Any idea? Web site? Document to download? Yahoo group to join? Keyword
to
> > search for?
> >
> > Regards,
> > Igor



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

Message
>   It would take centuries to poll all the addresses in a 64 bit value.  
 
Not with a binary-search type of polling, like what is used by 1-wire devices (and many other busses).
 

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
 

 


Message
Hmm.  That is what I was trying to say - you can't just start at 1 and count to 0xFFFFFFFFFFFFFFFF to poll all the addresses in a 64 bit value.  You have to do something more creative.
----- Original Message -----
From: Wouter van Ooijen
To: p...@yahoogroups.com
Sent: Monday, April 26, 2004 12:46 PM
Subject: RE: [piclist] RS-485 Networks

>   It would take centuries to poll all the addresses in a 64 bit value.  
 
Not with a binary-search type of polling, like what is used by 1-wire devices (and many other busses).
 

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
 

 


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions