View Full Version : Multiple Nodes on RS485 Network

03-07-2005, 07:07 AM
Please bear with me as I have no previous experience in the world of Stamps or 485 networking. I am working on designing and building a network to serve as an emergency alarm/alert system.·The system needs to be efficient and low cost since the project budget is·~$400.·Since the system will 5 nodes we are considering using 5·BS2 OEM kits to save money.

There will be nodes in 4 rooms and the main base station will be located in the nurse's station. Each node should have the option of two types of alarm and a·system reset as local inputs. The local outputs will be three LEDs.·The first signifies alert 1 was sent, second LED signifies that second alarm type is sent, and the third LED signifies that the·Alarm was acknowledged in the base station. A fourth output·that is being considered is a relay to drive a 120AC light bulb circuit. The·fourth output is·but a minor concern at this point.·The inputs will be push button switches·which are connected to input pins of the stamp. I have seen·the wiring diagrams for the switches and understand·how they should be connected.

The·base station should have an acknowledge button as its only local input. The output of the base station will be a panel with multiple·LEDs indicating from which room the signal was received, and which type of alarm it is.···Each alarm output can be coded with a label indicating which room with two LEDs indicating the alarm type. Also considered for this base node is a relay circuit to power a light bulb which is connected in the hallway as a secondary indicator.

Right now we are considering the TI SN75176A transceiver chip to send a signal over the network. The distance from one end of the system to the other is approximately 250'.

The signals which need to be sent over the network bus need to be coded to describe which room the signal comes from, which station is intended to listen to it, what type of data (alarm 1, alarm 2, acknowledge, reset). Our power source has not yet been determined but a 9V wall wart has been considered.

I am currently trying to read through the BASIC Stamp Syntax and Reference Manual and get a feel for the Stamp programming process. From my understanding the best way to run the system would be·a Master/Slave type set-up, but it seems to me like each node needs to be ready to send and receive a signal at any time.

I am trying to make sure that the BS2 is capable of running this type of system before ordering all the parts. If it is capable then a few pointers to lead me in the right direction as to where and/or how to start programming would be greatly appriciated. Sorry about the length, and thanks in advance for any consideration which is given in assisting me towards designing a working system.

03-07-2005, 07:39 AM
you got a nice little job on your hands. fun. you'll definately need the 232->485 chip.
and you'll wanna go with the master/slave config
the way you would do it would be to poll the slaves every so often, maybe once a second or every few seconds.

its definately do able

this way you just need to have the slaves ready to send there status data when the master polls the for the info

all of the rest switches/light ect is pretty much cake very simple to hook up and should be fairly simple to code.

you made just need to do some debugging on the timing between the master and slaves.
it will take some work and research to get the system up and running.

if you run into any particular trouble post the situation.

I'm sure there are others on the forum who may have experience with making a system such as this.

I think Jon Williams made a security system that a company uses to this day.?


Jon Williams
03-07-2005, 09:01 PM
Get a copy of Jan Axelson's book "Serial Port Complete" -- it covers RS-485 networking and includes lots of BASIC Stamp material.

Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA

03-07-2005, 09:14 PM
Yes, a master-slave protocol makes the most sense. With only a few stations, the polling sequence need not take much time.

You do need to take into account that the BS2 is a single tasking device. What this means is each slave should spend most of it's time 'listening' on the 485 bus for its address, ready to send data back to the 'master' (the base station). Every so often the slave will need to read its buttons, so it can't be listening at that time. This means it might miss a message every so often. The 'Master' should be aware of this, and re-try its 'poll' message.

A typical protocol is:

Master: 'Poll' unit 1
Unit 1: Send 'No Data Acknowledge' -- meaning I hear you, but I have no data for you.
Master: 'Poll' unit 2

Master: 'Poll' unit 1
Unit 1: Send 'I have data Acknowledge' -- meaning I hear you, AND I have data for you.
Master: Send 'get data' to Unit 1
Unit 1: Send data back to 'master'.

Each message should probably have a 'start of message' character, a Unit Number, a command byte, and an 'end of message' character. This way each slave can determine if it has recieved a good message. If a slave recieves a 'bad' message (ie it wasn't listening at the right time) it should throw away whatever it recieved and prepare to get the NEXT message sent. The 'start of message' character and 'end of message' character should be different, so the slave can determine it has missed something.

RS485 needs this 'master-slave' protocol, because you are using the same pair of wires for both outbound (master to slave) and inbound (slave to master) communications. There needs to be some 'handshake' via the poll-response cycle which insures that two slaves don't try to talk at the same time.

This is the same reason you don't want slaves asking for re-transmission of garbled messages.

Oh, and if this REALLY is an Emergency system, reliability and provability are going to be extremely important.· If somebody dies because this home-brew system you put together failed, or even worked badly, the implications in terms of insurance and legal are enormous.· This may not apply to your situation, but you should be aware it exists.

The solution to this is lots of testing.· Develop some scenarios, hook the units together, and try them out.· Scenarios like -- all 4 units push-buttons activated at the same time.· One unit's push button held down.· One unit's wall-wart falls out of the wall -- is this detected?· And how long does it take to detect it?

Post Edited (allanlane5) : 3/7/2005 2:18:35 PM GMT