View Full Version : Some gereral application concepts needed

T Chap
05-21-2006, 07:47 AM
While waiting on my first chips to get in, I have been digging through looking for ideas on implementing the code needed for my project.

Regarding timing issues, I couldn't find a clear answer on what is the best method to use for timing an input, and if it reaches (in my case) 4 seconds, do X. There was a simple example of RC use but that requires extra parts which are no big deal, but the idea of adding the micro is to lose as many parts as possible avoid part failures. Is there a preferred method to time an input and give an output over RC methods?

Secondly, lets say I have a device that is in 500 hundred hotel rooms, and I want to monitor such things as heat and smoke for example, and have the main system downstairs make decisions should there be heat and smoke: is there a typical method that the stamp can perform to monitor that many outputs at a time and subsequently identify the source?


Mike Green
05-21-2006, 08:10 AM
1) Regarding timing ... it all depends on how accurate you want it. Typically, you have some inputs to check, make a few decisions, then repeat the whole cycle. The cycle time is often 10s to 100s of milliseconds and, on average, is fairly stable. Often, you actually program in a wait because you only have to check things every 100ms or so. The Stamp is pretty good at timing (with PAUSE), but can't do anything else while it's waiting. Figure out your average cycle time and count those up while an input is active. When the count reaches 40 (or whatever) that represents about 4s, then do X. Also set up your counting routine to not count beyond some maximum (so the count doesn't roll over to zero and retrigger later).

2) Heat and smoke are dangerous and liability for system failure may be very high. You are going to need something simple and reliable (and inexpensive). Questions you need to answer first are: a) What kind of signalling is possible? Can you use existing wiring? If so, what? b) For reliability, you need something simple. Burglar alarms use a current loop and interruption signals that something has occurred. It's a pretty reliable method, but you can't easily tell where the problem is. It's also failsafe in that, if the current is interrupted, there's a problem. c) Another way to handle reliability is to have devices that are on a simple network and are actively polled. Although there are all kinds of potential noise problems, you might look into 1-Wire signalling. It's commonly used for thermostats in large office buildings, you can divide up the network into branches with "repeaters" and there are serial devices that do a lot of the protocols already for you.

05-22-2006, 12:47 AM
One nice thing with 1-Wire Thermostats is that they can be set to an 'alarm state' and you can then just do a search for modules with that alarm state set.
(you may need a DS2480b interface chip to do this as I don't think the 1-Wire commands built into the BS2p/pe/px models are capable enough)

Combine this with a sweeping scan of all modules at a regular interval, and you should be all set.
(Just send the serial number of a unit, wait for the response, then do the next one. The limit here is really how many serial numbers you can store in your BS2 model, as each one takes 8Bytes)

Say, check 50 units, check for alarm condition, check another 50 units, check for alarm and so on...

Don't visit my new website...

T Chap
05-22-2006, 03:32 AM
Thats what I was thinking of in a crude way. I have been reading about Polling as well as a concept. The other crazy idea was to create my own internal serial communication method, where the Master sends out a "serial number" to ask for a response, and in the case of i.e. 512 slave units, the Master could send out a unit number with a 24 bit word 0000 0000 0000 0000 0000 0001 to all units on the same wire. All units see the number, but only the unit that has the corresponding serial number responds with a bit on the same or seperate wire that says " i am here, no problem", or yes there is a problem, and this is the problem": then use some word that says fire, smoke, other problem related to the product. The Master then fires an audible and visual alarm to the attendant with the room number, and lists the of problem(s).

Since the Master is constantly polling units, it may be difficult to use the same wire for response, because in the event of a real alram bit/word being sent back, there could be miscommunication unless using some duplex system(AC based sually right?). With two wires, one is always polling, the other is for response and real alarms only. In my reading so far I haven't seen applications for this many 1-wire hook ups, but it may be possible as you say with the right interface on each stamp.

For clarification, I am not in the business of installing fire or smoke alarms, but I am building those features into a product as another layer of redundancy for safety, as my product will certainly be scrutinized for safety issues in a hotel setting. I am clueless on implimenting a 1-wire or similar, although with the right consultant it should come together easily I suppose. I will however build the oem parts myself into the existing system, then probably hire someone to help with the programming to speed it up and experience a quicker curve.

**Side note related to micro use:

Does the program simply loop itself over and over top to bottom unless there is an event to deal with? In other words, if a code at the top of the program has to stop and deal with something (ie button pressed which requires it to stop and count, then act), is the code ay the bottom ignored until the top issue has been dealt with? If so then this affects other buttons pressed right? Just trying to grasp the concept f how it works internally.


Mike Green
05-22-2006, 04:12 AM
On side note: yes. The general flow is:
Is condition X true? If so, go do something
Is condition Y true? If so, go do something else
Go back to beginning to start checking again
Make something work
Go back to beginning to start checking again
Something else:
Make something different work
Go back to beginning to start checking again
You can make this much more complicated, keep the information about what to check and what to do in tables, build in timing stuff (like once something triggers, keep track of how long it's been triggered, and do something if its more than Z minutes), but this is the basic scheme. Understand this and you can move to more sophisticated versions as you get experience.

PJ Allen
05-22-2006, 04:15 AM
You don't have to go and invent your own serial comm standard.ˇ You can make your own sort of token-ring type system easily.ˇ Your Host could SEROUT Remote station Polls andˇyour Remotes would WAIT for their number and talk in turn.ˇ The Host could send out "A000" and WAIT a given time for a response, and move on, "A001", "A002",... "A255", "A256", "A257",... "A511", "A512",...

T Chap
05-22-2006, 03:44 PM
Thanks a lot for the tips. It also seems very easy to add the Pink system and have the whole network on Ethernet for communication.

Regarding programming and embedded parts, if I am using all surface mounts parts, what is the best method for programming (and reprogramming after installing) the stamp? I may be wrong but I assume the eeprom is the only thing that gets programmed by the PC, and if it is surface mounted what methods (headers/connecdtors?) are there to program the surface chip, then update it after it is soldered in the system? If the system is installed, can it be reprogrammed via the internet with Pink?

BTW is there a forum or protocol for hiring help with programming stamps for my project?

Thanks again for the support

Kevin Wood
05-22-2006, 06:42 PM
I think one way you could do something like this is to build it modularly.

So, you might have a dedicated control processor for each floor monitoring the sensors for that floor, and a base processor that monitors the control processors.

For anything dealing with something as critical as fire and smoke, It might not be a bad idea to build redundancy into the system. For instance, you could have 2 control processors per floor, so that if one failed, the second would still be active.

Remote reprogramming in this situation might not be a good idea for safety reasons. If you need to change the program, have a technician swap a circuit board. Or, at a minimum, progam it on-site, so it can be verified, etc.

Parallax has a list of consultants on their website, if you are looking to hire somebody. If that doesn't work out, you can probably post in the Sandbox, or here.

If you are new to Stamps & programming, I suggest downloading the "What's a Microcontroller" manual, and the Basic Stamp Tutorial PowerPoint file. The PowerPoint goes into very good depth on programming concepts. The WaM book is on the WaM kit page, and the BS2 tutorial is on the Educational Downloads page. You can download a PowerPoint viewer from Microsoft.

Also, if you want to get some hands-on with the BS2, check out the Summer Special Kit on the Parallax site. It is the WaM kit with a HomeWork board. It's an excellent bargain.

Lastly, I haven't used this company's products, but might purchase a few for a proof-of-concept, but they manufacture gas sensors, such as CO. It might be useful for your project. Here's the link:

www.figarosensor.com/ (http://www.figarosensor.com/)

PJ Allen
05-22-2006, 08:51 PM
originator99 asked...
BTW is there a forum or protocol for hiring help with programming stamps for my project?

05-22-2006, 11:14 PM
I'm thinking that the building should already have some type of installed central fire system.ˇˇ I was thinking that it might be simpler to have the stamp communicate with this fire system for problems.ˇ I don't work in this area and I'm still new to Stamping myself, but if there's a standard protocol or if you know what system is in use, then you may able to talk to it.ˇ Don't intercept the main communications line, try to tap into an auxillary monitoring output or secondary output (if available).

In creating your own system, youˇspend moreˇfor extra wires and sensors.ˇ Also, central fire systems are UL rated and fire code approved, something you may not be able to obtain for your product.ˇ Since this is a life safety issue, I would tend to leave the fire monitoring to an approved, properly installed system.

ˇTrying to help!