November 21, 2024, 11:23:25 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Air blast tanks not working.

Started by michilson, September 29, 2014, 12:31:29 PM

Previous topic - Next topic

michilson

Hey guys below is the code for some air blast tanks.

They are not triggering the program. I have a blinking status light but that's it.

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


' -----[ Program Description ]---------------------------------------------
'
' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, etc.)
'            -- clip pin 1 of ULN2803 or replace with ULN2003
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  StatLed         = PIN5                  ' V+/OUT5
SYMBOL  HoldLed         = PIN4                  ' V+/OUT5
SYMBOL  Valveled        = PIN3                  ' V+/OUT5
SYMBOL  Valve           = PIN1                  ' V+/OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  idx             = B2
SYMBOL  timer           = B3

SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' preset IOs
  DIRS = %00111111                              ' define output pins (1s)


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  FOR idx = 1 TO 20
    PAUSE 5
    timer = timer + 5 * PIR                     ' update activity timer
    RANDOM lottery                              ' stir random #
  NEXT
  StatLed = IsOn - StatLed                      ' toggle LED state
  IF timer < 500 THEN Check_Trigger             ' valid signal?

  StatLed = IsOn                                ' prop active

  delay = lottery // 4001 + 1000                ' delay 1 to 5 seconds
  PAUSE delay

  Valve = IsOn
  Valveled = IsOn
  PAUSE 2000
  Valve = IsOff
  ValveLed = IsOff
  StatLed = IsOff
  Holdled = IsOn

  PAUSE 5000
  Holdled = IsOff
  GOTO Main


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


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


' -----[ User Data ]-------------------------------------------------------


Is there something wrong with the code that the PIR isnt being triggered or is it a wire issue?

thanks guys! I seem to have 5V on both the Red and Black and Red and White, While the Black and White have 0V with no movement and around 3v with movement.

Thanks guys. (Thinking its a program issue)

JonnyMac

The problem is you're looking for a 500ms input from the PIR when the trigger value can only go to 255 (because it's a byte). Change the PIR threshold value to 100 and it will be fine. 500ms is a really long time -- 100ms is perfectly valid for a PIR. Even if the PIR comes on half way through a 100ms debounce cycle, it will get detected at the end of the next.

Hint: Change your Font Face to Courier to make inline listings easier to read. Blue color (as you did) helps, too.

Jon McPhalen
EFX-TEK Hollywood Office

michilson

Im changing where it is Red correct?

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


' -----[ Program Description ]---------------------------------------------
'
' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, etc.)
'            -- clip pin 1 of ULN2803 or replace with ULN2003
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  StatLed         = PIN5                  ' V+/OUT5
SYMBOL  HoldLed         = PIN4                  ' V+/OUT5
SYMBOL  Valveled        = PIN3                  ' V+/OUT5
SYMBOL  Valve           = PIN1                  ' V+/OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  idx             = B2
SYMBOL  timer           = B3

SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' preset IOs
  DIRS = %00111111                              ' define output pins (1s)


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  FOR idx = 1 TO 20
    PAUSE 5
    timer = timer + 5 * PIR                     ' update activity timer
    RANDOM lottery                              ' stir random #
  NEXT
  StatLed = IsOn - StatLed                      ' toggle LED state
  IF timer < 100 THEN Check_Trigger             ' valid signal?

  StatLed = IsOn                                ' prop active

  delay = lottery // 4001 + 1000                ' delay 1 to 5 seconds
  PAUSE delay

  Valve = IsOn
  Valveled = IsOn
  PAUSE 2000
  Valve = IsOff
  ValveLed = IsOff
  StatLed = IsOff
  Holdled = IsOn

  PAUSE 5000
  Holdled = IsOff
  GOTO Main


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


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


' -----[ User Data ]-------------------------------------------------------


michilson

Sorry I though I had made that all blue. Anyways I changed the 500 to 100 and that seems to have fixed the Trigger however when I read the voltage on Pin1 and 12V+ I dont see it go to 12V and the Status and Hold LEDs dont come on either. The switch is in position 2 as well. Any Ideas?

JackMan

Not sure why you are checking voltage at PIN1. In your program, the 2 LED's you are referring to are on OUT4 and OUT5.

JonnyMac

Quotewhen I read the voltage on Pin1 and 12V+ I dont see it go to 12V

Connect the red lead of your meter to V+ and the black lead to the OUTx (not PINx) terminal you want to monitor. When the output is on, you should see your V+ voltage.
Jon McPhalen
EFX-TEK Hollywood Office

michilson

I was doing that. I had changed the code making sure it wasn't a output issue. on 12V and GND i see 12V, However on Out1 I was only seeing like 3 volts. I brought the controller back home from the haunt with me to do more debug. I'll try changing the chip and see if that fixes the issue.

JonnyMac

You may want a load on the output before measuring. Some meters don't work well without a proper load.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

Quote from: michilson on September 30, 2014, 03:55:27 PM
I was doing that. I had changed the code making sure it wasn't a output issue. on 12V and GND i see 12V, However on Out1 I was only seeing like 3 volts. I brought the controller back home from the haunt with me to do more debug. I'll try changing the chip and see if that fixes the issue.

So you are saying that when OUT1 is LOW, the voltage is zero, when OUT1 is HIGH, the voltage is 3? Are you checking by placing the probes on the terminal block screws? If the screw isn't all the way in tight, you won't get a proper reading. When any of the OUTx terminals are LOW, you should get a reading of around 0.03v, when they are HIGH, you should get V+ voltage.