A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
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?cid=5511 > 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=2903&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=2903&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=2903&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.
|
|
|
|
> 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 |
|
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.
|
|
If using the 1-wire silicon-id, there are coding examples on the 1-wire site to
explore all devices on the 1-wire net pretty fast.
|
|
There's lots of replies to this already, which I haven't yet read, but: It seems to me a kind of 'collision detect' algorithm, with variable fallback, can be used. You'll want to put the chip's address in EEPROM, so once assigned it won't have to be re-assigned every time. So: the 'master' sends out a query <STX><1><Talk><ETX> If there IS a <1> node, it should talk within 1 mSec. If there ISN'T a <1> node, then one of the unassigned nodes can try to talk after 1 mSec. If more than one node tries to talk after 1 mSec, they should detect that they have collided. They should then both wait 'a random amount of time', and try to talk again. One should get through. <STX><0><ACK><1><ETX> Now, the master knows he has the attention of only one 'slave', so he can send <STX><0><NewAddr><1><ETX> This tells the one who just responded to set his address to '1', and save it to EEPROM. 'master' now sends out '2', etc.. On power up, master queries 32 times to get the current set of addresses on its bus, and set any un-assigned addresses. If all have already been assigned, a 10 mSec timeout on responses will let the whole cycle finish in 300 mSec for 30 nodes. --- In , "Igor Janjatovic" <kodrat@p...> 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 |
|
On Mon, 26 Apr 2004 17:40:40 +0200, you 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 Igor, Check out IEEE 1451 smart sensor standard. It does everything you have described. Dave Duley |
|
On Mon, 26 Apr 2004, 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. I don't think you can allocate a slave address in this way. Take a look for example how it works the 1 wire unique code identification. You need to connect just one device, till that device will have its own address. Is not such a big deal, there are only 32 (theoreticaly !!!) devices on your bus so you need just 6 bits for the address. Set the master to allocate or realocate the ID in the slave's eeprom memory only when there is just one slave on the bus. Add the second slave. Remove the first. Allocate the address for the second slave. And so on. Then connect all slaves on the bus. BTW, you don't need 9 bit USART mode even this looks an elegant way. And remember, you need to know which slave have which address on 1Km line ! best regards, Vasile http://surducan,netfirms.com > > 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 |