Shop OBEX P1 Docs P2 Docs Learn Events
basic stamp programing question — Parallax Forums

basic stamp programing question

firealarmfreakfirealarmfreak Posts: 105
edited 2008-07-04 22:10 in BASIC Stamp
Hey I have a VERY weird problem lol.

Ok i am making a fire alarm control panel using basic stamp 2. For some reason when I activate the alarm, the system resets automaticly and then goes normal, then activates nromally. It does not always do this. Im not sure why it is doing this, but its annoyig and making it not work right. Any help would be greatly apreciated. Thanks. Chris.

Heres my code:

' {$STAMP BS2}
' {$PBASIC 2.5}

'Chris's Homemade 2 Zone Fire Alarm Control Panel

'Panel Features:

'2 Zones
'Power On Delay
'Codes: March Time




'PIN List:
'P0: Alarm Led for Zone 1
'P1: Alarm Led for Zone 2
'P2: Zone 1 Pulls
'P3: Zone 2 Pulls
'P4: Reset Switch
'P5: Silence Switch
'P7: Bell
'P8: Strobes
'P9: Silence Led
'P10: Walk Test Switch
'P12: Walk Test Led
'P13: Piezo (Panels Sounder)



'Code begins below:




'----System Normal----'
Normal:
HIGH 0
HIGH 1
HIGH 9
HIGH 12
HIGH 13
PAUSE 3000
LOW 0
LOW 1
LOW 7
LOW 8
LOW 9
LOW 12
LOW 13

'----Zone 1----'
Zones:
DO
LOW 12
IF (IN2 = 1) THEN
PAUSE 3000
HIGH 0
HIGH 13
GOTO Alarm
ENDIF

'----Zone 2----'
IF (IN3 = 1) THEN
PAUSE 3000
HIGH 1
HIGH 13
GOTO Alarm
ENDIF
loop



'----Alarm----'
Alarm:
DO
HIGH 7
HIGH 8
IF (IN5 = 1) THEN GOTO Silence
PAUSE 250
LOW 7
PAUSE 250
LOOP

'----Audible Silence----'
Silence:
DO
HIGH 9
LOW 7



'----System Reset----'
Reset:
IF (IN4 = 1) THEN GOTO Normal

LOOP
«1

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-24 15:02
    I wonder with all the inputs if perhaps you have something floating...Do you have a connection diagram or schematic?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-06-24 20:58
    Wjat do you mean by floating?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-24 21:04
    Picture this…You have a switch connected…one end to the BASIC Stamp I/O pin and the other to VDD (5V). When you push the button the I/O pin goes HIGH as intended. When the button is open though the I/O pin is left floating, which means it is in no determinate state. It could float high or low causing erratic readings. In fact it is possible for the line to even oscillate. A pull-up or pull-down resistor is required on an input that is open in one state. You did not post the schematic or wiring diagram so I am still assuming this is a possibility.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • kenwtnkenwtn Posts: 250
    edited 2008-06-24 21:10
    A schematic is worth a 1000 words. At least that is what I have heard.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-24 23:09
    The other thing that commonly happens is that a program is triggered, activates something, and the extra current drain is too much for the power source and the voltage on the Stamp drops to where it resets and the program starts over from the beginning (and turns off whatever was activated).
  • agfaagfa Posts: 295
    edited 2008-06-25 01:49
    If the problem that Mike Green described is occurring, a short routine that·exicutes only once at the beginning of the program, such as an unique alarm sound or·flashing some LEDs in a unique sequence would·help·you
    determine if that problem was occurring.

    agfa
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-25 16:20
    You could simply put a DEBUG statement at the beginning which says:

    DEBUG "PROGRAM RUNNING...", CR

    If you see that message more than once on your DEBUG screen the program is starting over.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-06-25 18:57
    I do have a resister connectd so its not floating, i think its the bell relay shorting cuz my relay system sucks currenly. I need to get a better system. Could a shorting out relay do this?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-25 19:10
    "Could a shorting out relay do this?"

    Yes, for sure

    Again, a schematic would help in giving you advice.
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-06-25 19:29
    Please understand that if this thread continues without a wiring diagram or schematic there will be nothing more we can do to help you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-03 18:25
    Hey Heres a schematic hopefully its good enough. I recenly found out that if i keep the bell disconnected and only the 2 strobes conencted, its fine (the relay clicks on and off properly and it does not reset) but when the bell is connected, the system resets afetr it rings 2-3 times. I still cant figure this ut. I did narrow it down. Its not shorting relays cuz it works without the bell.

    Any help greatly appreciated.

    http://image69.webshots.com/169/4/80/3/2377480030102854175vnWjdk_fs.jpg
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 18:35
    Where does the bell get its power? If it gets its power from the Stamp's regulator, then you're probably overloading the regulator or the unregulated power source
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-03 18:41
    The bell is powered by an external 18 volt dc power supply. the strobes are also powered by the 18 volt dc and the strobes work fine, its the bell that causes the problem. Any other ideas?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 18:55
    You have several problems with the relay circuitry:
    1) The polarity of the whole thing is backwards. Please refer to the Industrial Control tutorial (www.parallax.com/Portals/0/Downloads/docs/books/edu/ic.pdf) on page 86 for a schematic.
    2) Notice in one schematic that there's a diode connected across the relay. You need this. A 1N4001 rectifier diode from RadioShack will work fine.
    3) As shown in the schematics, with a junction transistor like the 2N3904, you need a base resistor (1K will work as shown).

    Any of the above could account for your problems.
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-03 19:24
    would you be able to explain why the relay swictehs on and off fine and does not reset the system but when the bell is connected to the relay it starts resetting the system? The strobes work fine even when they are connected. Only the bell. It dosnt make sence that the bell would cause the thing to reset.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-07-03 19:37
    I would recommend correcting the issues (even if they seem to be working) before addressing other issues. You never know if the original issues are the cause. Sometimes fixing the obvious issues fixes the other issues.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 19:42
    It's hard to say. You didn't show the bell or the sirens anywhere on your schematic. Perhaps they're connected wrong. Perhaps there's noise that somehow gets coupled into the logic circuitry. The things I mentioned all can result in intermittent operation or potential damage to the Stamp even if the bell is never connected. The protective diode across the relay coil can be left out and the device appears to work fine, then the Stamp fails or the switching transistor fails after 100 relay closures. Similarly, with the missing base resistor. The system seems to work until maybe the 135th time the relay closes and the temperature of the Stamp was a little higher than before and the relay had to stay closed a few seconds longer and "poof" part of the I/O pin circuitry in the Stamp melts.
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-03 19:46
    could puting a protective diode in there fix my restarting problem?
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-03 19:57
    i just tried and the diode made no difference. could it be a faulty transister?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 20:18
    Adding a diode was only one of the things I mentioned. All three items are problems. The fact that the circuit you drew is something called an "emitter follower" may have saved the transistor from too much base current, but the relay may not be switching reliably in this circuit. It might "click", but not stay on.
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-03 21:59
    Ok, well i tried a small buzzer on the relay and strobes and everything worked fine, didnt reset. It only does it with the bell. But when i programmed the bell to ring continuously instead of on and off, it worked fine. (the buzzer worked even when programed to go on and off). Could it be caused bymy power suply for the bell and strobes not having eniough amps to switch on and off, but just enough to switch on once? my power supply is 1 amp 18 volt dc, my bell uses 0.085 amps to run. Im not sure how to converter 0.085 into amps but mabe u know how?

    Chris.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 22:20
    0.085 Amps is a lot less than 1.000 Amps. On the other hand, I don't know the peak current although that's not a high suspicion here.
    I don't know how you have the bell connected and I don't know how you have the 18V bell supply connected. Both pieces of information are important. It's a good sign that you can make the buzzer work in place of the bell, but it tells me very little about why the bell doesn't work.

    I can't stress strongly enough that you need to learn about basic electronics including basic formulas like Ohm's Law and the Power formula. You need to learn about series and parallel circuits and a little about how resistors, capacitors, diodes, and transistors work. Here's one quick introduction: (www.seattlerobotics.org/guide/electronics.html). There are many available on the web.
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-03 22:37
    Here is a wiring diagram on how my bell and strobes are connected to the relays:

    http://image50.webshots.com/650/7/38/1/2589738010102854175doNfcH_fs.jpg
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-03 22:39
    By the way, the blocks with the dots are terminal strips
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-03 23:02
    Thanks for the diagram. The important point is that there really is complete isolation between the 18V circuit and the Stamp.
    I still can't tell what's going on from the information you've given although we've eliminated a number of possibilities.
    How are you powering the Stamp? Since this works with a buzzer, it doesn't sound like it involves the Stamp or relays.
    There could still be noise coupled into the Stamp wiring if the bell wiring runs for some distance with some sort of Stamp
    related wiring.
  • jmalaysiajmalaysia Posts: 97
    edited 2008-07-03 23:33
    How far away is the bell from the stamp? If it's a firebell then it has a solenoid in it that switches every time the bell sounds, which generates a tremendous amount of electrical noise. Since you are using active high inputs for the alarm triggers then external noise can cause false triggers. It doesn't take a lot of external noise to cause a false high on a pulldown circuit. First, move the bell a good distance from the stamp to see if that helps. If not, put a non-reactive load in place of the bell, like a lamp or something. If either of those solve the problem then I would suggest you redesign your circuit to use active low inputs, which don't have the same problems from external noise.
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-04 02:04
    hey my friend told me my bell was reseting my system because i was under pwoering it. The bell is 20-24 VDC and im powering it with 18 VDC, and he said that underpowering it will cause the relays to have to work harder therefore they are not switching the bell on and off reliably. He said the reason continuous worked is because it only had top switch on once, not over and over. He also said my small buzzer is only around 15 mA so thats why it was able to be used with a small power supply.

    Does this sound accuate and mabe if i get a 24 volt DC power supply it may fix my problem?

    Chris.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-04 02:11
    This is not accurate at all. The bell may sound louder at 24V, but using an 18V power supply would not explain what's happening and it will not cause the relays to work harder. Do you understand how relays work? You might read some articles in the Wikipedia on relays to find out (do a web search for "wiki relay"). You'll see why this explanation doesn't make sense.
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-04 02:26
    then why the heck does the bell not work? cuz the small buzzer works on the same relay the bell doesnt work on. could my bells motor be dying?

    Chris.
  • firealarmfreakfirealarmfreak Posts: 105
    edited 2008-07-04 02:38
    Sorry i phrased it bad.

    Its not causing the relays to work harder but under powering could be causing the bell to have to put out more power to work, so thats why its not switching. Is this correct?
Sign In or Register to comment.