November 22, 2024, 12:52:06 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Trouble shooting code: Unable to turn outputs off

Started by Jadams, February 05, 2012, 11:19:20 AM

Previous topic - Next topic

Jadams

This program has been running perfectly for the past year.  There are 3 parts to this program, the part in question is when the relay on P6 is active, P6 goes high and turns on P1 and P4 (Show_Y).  All of a sudden P1 stays on even when the relay is not active.  P4 does not come on.  I have tried disconnecting the input on PIN6 but P1 is still on.  I replaced the ULN with a new one, no change.  None of the other parts of the program operate.  My next step is to change out the PROP 1.  Since the unit is difficult to get to, thought I would check to see if anyone could spot something obvious.  Any ideas?

Thanks



' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' P6 : Connect NC contacts between P6.W and P6.B; when relay is active and
'      contacts open, P6 goes high.
'
' P5 : Configure photoresistor circuit so that input goes high when dark
'
'      +5 ---[fixed]--- P5.W ---[photoresistor]--- P5.B
'
' Remove ULN2803 pins 1, 2, and 3.


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  PIR             = PIN7                  ' SETUP = UP; no ULN

SYMBOL  LightBeam       = PIN6                  ' SETUP = UP; no ULN
SYMBOL  Darkness        = PIN5                  ' no ULN
SYMBOL  Sounder         = PIN4                  ' piezo transducer
                                                '                       wire color
SYMBOL  Green           = PIN3                  ' green led             green
SYMBOL  Red             = PIN2                  ' red led               orange
SYMBOL  Yellow          = PIN1                  ' yellow led            orange/white
SYMBOL  Lights          = PIN0                  ' relay for 120v lights blue/white


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1                     ' for active-high in/out
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400


' -----[ Variables ]-------------------------------------------------------

SYMBOL  triggers        = B0
SYMBOL   trPIR          =  BIT7
SYMBOL   trBeam         =  BIT6                 ' debounced trigger bits
SYMBOL   trDark         =  BIT5


SYMBOL  status          = B1
SYMBOL   playing        =  BIT15

SYMBOL  idx             = B2


' -----[ Initialization ]--------------------------------------------------

Power_Up:
  PINS = %00000000                              ' clear all
  DIRS = %00011111                              ' make P0-P3 outputs

  PAUSE 100000                                  ' PIR warm-up

Reset:
  PAUSE 5000                                   ' re-trigger delay


' -----[ Program Code ]----------------------------------------------------

Main:
  triggers = %11100000                          ' arm triggers
  FOR idx = 1 TO 20                             ' debounce, 100ms
    PAUSE 5
    triggers = triggers & PINS                  ' re-scan inputs
  NEXT

  Red = trDark                                  ' if dark, Red is on

  IF trBeam = Yes THEN Show_Y                   ' beam broken?
  IF trPIR = Yes THEN Show_G                    ' PIR detect?
  GOTO Main


Show_Y:

    FOR idx = 1 TO 5                             ' flash
    Sounder = Ison
    Yellow = IsOn
    PAUSE 250
    Sounder = Isoff
    Yellow = IsOff
    PAUSE 250
  NEXT



  IF Darkness = No THEN Main
  Lights = IsOn                                 ' 120v lights on
  PAUSE 20000
  Lights = IsOff

  GOTO Main


Show_G:

   FOR idx = 1 TO 10                             ' flash
    Sounder = Ison
    Green = IsOn
    PAUSE 150
    Sounder = Isoff
    Green = IsOff
    PAUSE 150
  NEXT
    PAUSE 250



  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------



' -------------------------------------------------------------------------



' -----[ User Data ]-------------------------------------------------------
Jim Adams

JackMan

 You can't use a value for the BS1 greater than 65535, in your Power_Up section there is a Pause value of 100000 so the BS1 is ignoring that line. This would cause an immediate trigger from the PIR when the code hits Main. A 60 second pause is plenty for PIR warm up (60000).  Not sure about the P6 problem, if this code was working before there has to be a hardware problem somewhere.

Jadams

Thanks for that.  That explains why every time I would power it up, the buzzer would sound.  I may just go ahead and switch out the Prop 1 and eliminate that possibility.
Jim Adams

JackMan

You may want to double check with Jon first on the wiring of your relay to P6 to make sure this isn't causing any problems.

JonnyMac

It is possible that P6 is damaged -- doesn't happen often but it can happen.  A quick test would be to download a little program that just shows the state of P6.  Since you're using it as an active-low input, set the P6 jumper to UP and connect a normally open button between P6.W and P6.B.  When you run this little program it should print "1" when the button is open, "0" when it is pressed.

'   {$STAMP BS1}
'   {$PBASIC 1.0}

Main:
  DEBUG PIN6
  PAUSE 25
  GOTO Main


Jon McPhalen
EFX-TEK Hollywood Office

Jadams

I have a pretty embarrassing senior moment to confess guys.  I did the test that Jon suggested and P6 is working fine.  I reloaded the program, with the correction in the PIR warm up time, and everything was back to normal.  My lessons learned here is, reload the program first, then begin the troubleshooting process.

Thanks for your help.
Jim Adams

livinlowe

Quote from: Jadams on February 07, 2012, 06:29:59 AM
I have a pretty embarrassing senior moment to confess guys.  I did the test that Jon suggested and P6 is working fine.  I reloaded the program, with the correction in the PIR warm up time, and everything was back to normal.  My lessons learned here is, reload the program first, then begin the troubleshooting process.

Thanks for your help.
Hey, no worries! It's how we learn. Glad your back up and running!
Shawn
Scaring someone with a prop you built -- priceless!