programming question for the BS2
firealarmfreak
Posts: 105
Hey I am making a fire alarm panel that pulses alarms. It also has a continuous option. Basicly Its programmed so i can use a button to set it to different signal codes so when I pull it, it either goes on and off or goes continuously.
But for some reason when I use continuous it automatyicy goes to silence. and the silence led is lit like it should be when it goes to silence, but it is not supposed to go to silence unless a button is pressed, but it automaticly goes to silence. I find that if i pulse the alarm led, and dont pulse the alarms, it works for longer before automaticly going to silence, but it still does. Sometimes It even goes to normal and the stamp resets. Is there a reson for this? I already tried puting them in a list instead of using high 8 : high 9, but that didnt help any. Any ideas?
Here is my Alarm routine (the source code for the alarm part)
When I remove the "IF (IN4 = 1) THEN GOTO Silence" and the "IF (IN5 = 1) THEN GOTO Normal", it worked perfectly but obviusly i couldnt turn off the alarm. By the way, all the other codes: March Time, Code 3 and Pulse, all work perfectly, its only continuous that is messed.
AlarmA: 'Continuous
DO
HIGH 8 : HIGH 9 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 225
LOW 0
PAUSE 225
LOOP
AlarmB: 'March Time
'HIGH 8 : HIGH 9 : HIGH 0 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 8 : HIGH 9 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 225 : LOW 8 : LOW 0 : PAUSE 225
LOOP
AlarmC: 'Code 3
'HIGH 8 : HIGH 9 : HIGH 0 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 8 : HIGH 90 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 500 : LOW 8 : LOW 0
PAUSE 500 : HIGH 8 : HIGH 0
PAUSE 500 : LOW 8 : LOW 0
PAUSE 500 : HIGH 8 : HIGH 0
PAUSE 500 : LOW 8 : LOW 0 : PAUSE 1400
LOOP
AlarmD: 'Pulse
'HIGH 0 : HIGH 8 : HIGH 9 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 0 : HIGH 8 : HIGH 9 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 500 : LOW 0 : LOW 8 : LOW 9 : LOW 13 : PAUSE 500
LOOP
Thanks.
Chris.
But for some reason when I use continuous it automatyicy goes to silence. and the silence led is lit like it should be when it goes to silence, but it is not supposed to go to silence unless a button is pressed, but it automaticly goes to silence. I find that if i pulse the alarm led, and dont pulse the alarms, it works for longer before automaticly going to silence, but it still does. Sometimes It even goes to normal and the stamp resets. Is there a reson for this? I already tried puting them in a list instead of using high 8 : high 9, but that didnt help any. Any ideas?
Here is my Alarm routine (the source code for the alarm part)
When I remove the "IF (IN4 = 1) THEN GOTO Silence" and the "IF (IN5 = 1) THEN GOTO Normal", it worked perfectly but obviusly i couldnt turn off the alarm. By the way, all the other codes: March Time, Code 3 and Pulse, all work perfectly, its only continuous that is messed.
AlarmA: 'Continuous
DO
HIGH 8 : HIGH 9 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 225
LOW 0
PAUSE 225
LOOP
AlarmB: 'March Time
'HIGH 8 : HIGH 9 : HIGH 0 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 8 : HIGH 9 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 225 : LOW 8 : LOW 0 : PAUSE 225
LOOP
AlarmC: 'Code 3
'HIGH 8 : HIGH 9 : HIGH 0 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 8 : HIGH 90 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 500 : LOW 8 : LOW 0
PAUSE 500 : HIGH 8 : HIGH 0
PAUSE 500 : LOW 8 : LOW 0
PAUSE 500 : HIGH 8 : HIGH 0
PAUSE 500 : LOW 8 : LOW 0 : PAUSE 1400
LOOP
AlarmD: 'Pulse
'HIGH 0 : HIGH 8 : HIGH 9 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 0 : HIGH 8 : HIGH 9 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 500 : LOW 0 : LOW 8 : LOW 9 : LOW 13 : PAUSE 500
LOOP
Thanks.
Chris.
Comments
Jeff T.
Any other ideas?
Chris.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I will try puting pre alarm in to see if that helps, thanks.
Someone on youtube that also made a panel (i got the idea to make a panel with basic stamp cause of him). He said he had the same issue as me and all he did was erased the continuous one and retyped it in, but that did not work for me. He said its a basic stamp bug. Is that a possibility? that the problem is a bug in the basic stamp?
Chris.
The chance that its a Stamp bug are somewhere between slim and none.
Assuming your pull-downs are there (check with a meter when the button is not pressed), it has to be something thats happening in your program. Also, is the stamp being powered by the same source as the alarm?
Like somewhere pin 4 is getting set high by mistake, for instance.
Post the whole code and the schematic and I bet someone will see it.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
Sorry about some of the messy text Example, the I/O DEFFINTIONS on my code are actually formated like: AlarmLED PIN 1 'Alarm LED on pin 1 (it didn't format correctly after i took it off the basic stamp windows editor). But it is formated correctly on the basic stamp editor.
Any ideas on my problem?
' {$STAMP BS2}
' {$PBASIC 2.5}
'
'
'FIRE-PRO 3002 FIRE ALARM CONTROL PANEL'
'
'
'Most of this code was written by Chris
'All other parts were written by Parallax Inc.
'The idea of using Basic Stamp for a panel was from "NewAgeServer" on youtube
'This is a 2 zone control panel
'It includes supervisory for each zone
'It also includes 4 selectable signal codes: Continuous, March Time, Code 3 and Pulse
'This control panel is incompatible with BS1
'I have only tested this code on BS2
'This code was written using PBASIC 2.5
'
'
I/O DEFINITIONS
'
AlarmLED PIN 0 'Indicates panel is in alarm or WalkTest
Zones1 PIN 2 'Zone 1 Pull Stations
Zones2 PIN 3 'Zone 2 Pull Stations
Btn1 PIN 4 'Silence/StrobeMode, Sig=Cont
Btn2 PIN 5 'Reset, Walk, Sig=March
Btn3 PIN 6 'Walk, Coding, Re-Alarm, Sig=Code3
AudSigs PIN 8 'Audible Signals
Strobes PIN 9 'Strobes (visual-signal)
Btn4 PIN 10 'Test, Sig=Pulse
SilenceLED PIN 11 'Indicates the audibles are silenced
TroubleLED PIN 12 'Indicates the panel is in trouble
Buzzer PIN 13 'Indicates an alarm or trouble condition
LCD PIN 14 'LCD Display
'
VARIABLES
'
signalcode VAR Word 'Indicates which signal code to use
zone1 VAR Word 'Indicates zone 1
zone2 VAR Word 'Indicates zone 2
'
[noparse]/noparse][noparse][[/noparse]PROGRAM CODE BEGINS HERE
'
'--SIGNALCODE DEFINITIONS--'
'signalcode = 1: Continuous
'signalcode = 2: MarchTime
'signalcode = 3: Code 3
'signalcode = 4: Pulse
'signalcode = 5: two-stage
'
'
'--ZONES
'
'Zone 1: Main Floor (lower)
'Zone 2: Upper Floor
'
'
'
[noparse][[/noparse]NORMAL]
Normal:
LOW 8 : LOW 9 : LOW 0 : LOW 1 : LOW 10 : LOW 11 : LOW 12 : LOW 13
PAUSE 300
HIGH 0 : HIGH 1 : HIGH 10 : HIGH 11 : HIGH 12 : HIGH 13
PAUSE 1000
LOW 0 : LOW 1 : LOW 10 : LOW 11 : LOW 12 : LOW 13
signalcode = 2 'Default Signal Code
'
[noparse][[/noparse]BUTTONS]
Begin:
PAUSE 500
HIGH 13 : PAUSE 200 : LOW 13
DO
IF (IN4 = 1) THEN GOTO StrobeTest
IF (IN5 = 1) THEN GOTO WalkMode
IF (IN6 = 1) THEN GOTO SignalCodes
'
[noparse][[/noparse]ZONES]
HIGH 2 'Zone 1
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO AlarmVerify
IF zone1 = 0 THEN GOTO Trouble1
HIGH 3 'Zone 2
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO AlarmVerify
IF zone2 = 0 THEN GOTO Trouble2
IF (IN10 = 0) THEN GOTO AlarmVerify 'Test Button
LOOP
'
[noparse][[/noparse]SIGNAL CODES]
SignalCodes:
HIGH 13 : PAUSE 100 : LOW 13
HIGH 0 : HIGH 11 : HIGH 12
PAUSE 500
DO
IF (IN4 = 1) THEN signalcode = 1 : GOTO AlarmVerify
IF (IN5 = 1) THEN signalcode = 2 : GOTO AlarmVerify
IF (IN6 = 1) THEN signalcode = 3 : GOTO AlarmVerify
IF (IN10 = 0) THEN signalcode = 4 : GOTO AlarmVerify
LOOP
'
[noparse][[/noparse]ALARM]
AlarmVerify:
LOW 0 : LOW 11 : LOW 12
PAUSE 1000
HIGH 2
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO Alarm
HIGH 3
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO Alarm
IF (IN10 = 0) THEN GOTO Alarm
GOTO Begin 'If no zones are in alarm, go back to normal
Alarm:
LOW 11
DO
IF signalcode = 1 THEN GOTO AlarmA
IF signalcode = 2 THEN GOTO AlarmB
IF signalcode = 3 THEN GOTO AlarmC
IF signalcode = 4 THEN GOTO AlarmD
LOOP
AlarmA:
DO
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
HIGH 8
HIGH 9
LOOP
AlarmB: 'March Time
'HIGH 8 : HIGH 9 : HIGH 0 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 8 : HIGH 9 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 225 : LOW 8 : LOW 0 : PAUSE 225
LOOP
AlarmC: 'Code 3
'HIGH 8 : HIGH 9 : HIGH 0 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 8 : HIGH 9 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 500 : LOW 8 : LOW 0
PAUSE 500 : HIGH 8 : HIGH 0
PAUSE 500 : LOW 8 : LOW 0
PAUSE 500 : HIGH 8 : HIGH 0
PAUSE 500 : LOW 8 : LOW 0 : PAUSE 1400
LOOP
AlarmD: 'Pulse
'HIGH 0 : HIGH 8 : HIGH 9 : PAUSE 100 : LOW 8 : LOW 9 : LOW 0 : PAUSE 2500 'Pre Alarm
DO
HIGH 0 : HIGH 8 : HIGH 9 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 500 : LOW 0 : LOW 8 : LOW 9 : LOW 13 : PAUSE 500
LOOP
ReAlarm:
LOW 11
DO
IF (IN4 = 1) THEN GOTO SilenceA
IF (IN5 = 1) THEN GOTO Normal
HIGH 0 : HIGH 8 : HIGH 9
PAUSE 225
LOW 0 : LOW 8
PAUSE 225
LOOP
'
[noparse][[/noparse]SILENCE]
Silence:
LOW 8 : HIGH 11
DO
HIGH 2
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO Zone_1
HIGH 3
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO Zone_2
IF (IN5 = 1) THEN GOTO Normal
IF (IN6 = 1) THEN GOTO ReAlarm
LOOP
Zone_1:
DO
IF (IN5 = 1) THEN GOTO Normal
IF (IN6 = 1) THEN GOTO ReAlarm
HIGH 3 'Zone 1 was activated, Waits to see if zone 2 is activated, if so, goes back to the alarm routine
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO ReAlarm
LOOP
Zone_2:
DO
IF (IN5 = 1) THEN GOTO Normal
IF (IN6 = 1) THEN GOTO ReAlarm
HIGH 2 'Zone 2 was activated, Waits to see if zone 1 is activated, if so, goes back to the alarm routine
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO ReAlarm
LOOP
SilenceA:
LOW 8 : HIGH 0 : HIGH 11
DO
IF (IN5 = 1) THEN GOTO Normal
IF (IN6 = 1) THEN GOTO ReAlarm
LOOP
'
[noparse][[/noparse]WALK TEST]
WalkMode:
HIGH 0
HIGH 13 : PAUSE 100 : LOW 13
PAUSE 500
DO
IF (IN5 = 1) THEN GOTO Normal
HIGH 2 'Zone 1
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO WalkTest1
HIGH 3 'Zone 2
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO WalkTest2
LOOP
WalkTest1: 'Zone 1 Walk Test
DO
LOW 0 : HIGH 8 : HIGH 9 : HIGH 13
PAUSE 225
LOW 8 : LOW 9 : LOW 13
PAUSE 1500
GOTO WalkMode
WalkTest2: 'Zone 2 Walk Test
LOW 0 : HIGH 8 : HIGH 9
PAUSE 225
LOW 8 : LOW 9
PAUSE 225
HIGH 8 : HIGH 9
PAUSE 225
LOW 8 : LOW 9
PAUSE 1500
GOTO WalkMode
LOOP
'
[noparse][[/noparse]STROBE TEST]
StrobeTest:
HIGH 11
HIGH 13 : PAUSE 100 : LOW 13
DO
IF (IN5 = 1) THEN GOTO Normal
HIGH 2
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO StrobeVerify
HIGH 3
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO StrobeVerify
IF (IN10 = 0) THEN GOTO StrobeVerify
LOOP
StrobeVerify:
PAUSE 1000
HIGH 2
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO StrobeOnly
HIGH 3
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO StrobeOnly
IF (IN10 = 0) THEN GOTO StrobeOnly
GOTO StrobeTest 'If no zones are in alarm, go back to normal
StrobeOnly:
HIGH 11
DO
IF (IN5 = 1) THEN GOTO Normal
HIGH 0 : HIGH 9
PAUSE 225
LOW 0
PAUSE 225
LOOP
'
[noparse][[/noparse]TROUBLE]
Trouble1:
DO
HIGH 12 : HIGH 13 : PAUSE 500 : LOW 12 : LOW 13 : PAUSE 500
HIGH 2
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO AlarmVerify
HIGH 3
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO AlarmVerify
IF (IN4 = 1) THEN GOTO TroubleSilence
IF (IN5 = 1) THEN GOTO Normal
LOOP
Trouble2:
DO
HIGH 12 : HIGH 13 : PAUSE 500 : LOW 12 : LOW 13 : PAUSE 500
HIGH 2
RCTIME 2,1, zone1
IF zone1 = 1 THEN GOTO AlarmVerify
HIGH 3
RCTIME 3,1, zone2
IF zone2 = 1 THEN GOTO AlarmVerify
IF (IN4 = 1) THEN GOTO TroubleSilence
IF (IN5 = 1) THEN GOTO Normal
LOOP
TroubleSilence:
DO
HIGH 11
HIGH 12
LOW 13
IF (IN5 = 1) THEN GOTO Normal
LOOP
'
[noparse]/noparse][noparse][[/noparse]PROGRAM CODE ENDS HERE
'
'
Post Edited (firealarmfreak) : 8/27/2008 1:26:24 AM GMT
Post Edit -- http://forums.parallax.com/showthread.php?p=725270
·Some things that cause posts to go unanswered...
·- Posting very large programs into the message rather than attaching. This is not only clutter and difficult to follow, but often the formatting is lost. It is easier for experienced programmers to load attached code in and see what is going on.
It's what the * Attachment Manager * button is there for.
Post Edited (PJ Allen) : 8/27/2008 1:37:52 AM GMT
Chris.
I looked at your attached code thinking I could at least follow what was going on. Unfortunately your code jumps about so much I can’t really follow what is going on. At the beginning you define several pins and their functions but you never use these descriptive labels through the program. Instead you use the pin numbers. While you’re going down through the code, things like HIGH 0 : HIGH 8 : HIGH 9 don’t mean much unless you know what they are connected to. Same with inputs…you use IN4 and IN5. It would be easier to see what is going on by using:
HIGH AlarmLED: HIGH AudSigs : HIGH Strobes
and
IF (Btn1 = 1) THEN GOTO StrobeTest
IF (Btn2 = 1) THEN GOTO WalkMode
IF (Btn3 = 1) THEN GOTO SignalCodes
The section where you have (there are several):
LOW 8 : LOW 9 : LOW 0 : LOW 1 : LOW 10 : LOW 11 : LOW 12 : LOW 13
…could be done with a single command.
You can set the states of several pins using OUTS, or for less pins the appropriate OUTL, OUTH, etc. A quick note is you have PIN 10 defined as a button but you are forcing it LOW above. By doing this when the button is pressed it will cause a short circuit.
It may seem I am being very harsh about your code but please understand that in a situation like this there are so many things that stand out as problems up front that it is hard to see the forest for the trees. In this case you may need to use DEBUG statements to see where the code is going and what is happening…I can’t really follow the flow because the code jumps all over based on so many conditions.
When you use DEBUG try to print the section the code is in as well as the state of any relevant variables or inputs at that point so you can see why the code may be doing this. And definitely check into that button shorting issue. If you group 4 buttons on a nibble within a port it would be easy to read them all using a subroutine or at least one alias.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
"IF (IN4 = 1) THEN GOTO Silence
"IF (IN5 = 1) THEN GOTO Normal
When I removed those, it worked, but i couldnt shut off the alarms..
any ideas?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
When i removed:
IF (IN4 = 1) THEN GOTO Silence,
the system started automaticly resetting.
When I removed:
IF (IN5 = 1) THEN GOTO Normal,
the system started automaticly going to silence (the silence led lit)
When I have them both, its random, sometimes resets automaticly and mostly just goes to silence automaticly.
The key thing is that, i have 4 signal codes, all programmed the same except they pulse the alarm at different rates. The ONLY one not working is continuous, it works perfectlty on the rest.
Any other ideas?
AlarmA: 'Continuous
DO
HIGH 8 : HIGH 9 : HIGH 0 'Normal Alarm
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
PAUSE 225
LOW 0
PAUSE 225
LOOP
In the file you attached it looks like this:
AlarmA:
DO
IF (IN4 = 1) THEN GOTO Silence
IF (IN5 = 1) THEN GOTO Normal
HIGH 8
HIGH 9
LOOP
There are differences and I made initial assumptions based on the snips you first posted and now see they’re incorrect. That was what I meant. I would make all changes and attach new code once you have run the DEBUG routines.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Once you have done this you should post your results. You could put a DEBUG line at various routine entry points and see where the flow of the program is going. At key points, such as where things are not working as they should you can also have it print the values of the affected variables·before, during and after entry into the routine.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Its jumping to silence and sometimes back to the begining.. but if i were to debug it, how would i write the debug code?
P.S. - Suggestions are never pointless.· If we suggest something there is always a point to it, otherwise we're just wasting time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
eg:
Label Name:
DEBUG "Name of Label",CR
if the program is cycling too quickly slow it down a little with a pause after each debug. This will help you close in on the problem
Jeff T.
Chris.