November 21, 2024, 03:33:19 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.


Door Controller Program Modification help

Started by pbronson, June 28, 2015, 09:55:16 AM

Previous topic - Next topic

pbronson

I am looking for a little help with the following modification to a program the was written originally by Jon Williams. I have decided to add a shut off solenoid to the system to alleviate pressure loss when the system is dormant. I added the address to pin three as Solenoid = IsOn and IsOff and it passes the syntax test but doesn't complete the ground on output 3 on the Prop1 Controller.  I am very new at this and would appreciate any help. I am currently testing using LEDs on a breadboard before hooking it up to the system.

Program follows:

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


' -----[ Program Description ]---------------------------------------------


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


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

SYMBOL  Delay           = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  PIR             = PIN5

SYMBOL  Retract         = PIN4                  ' separated for thermal
SYMBOL  Solenoid        = PIN3                  ' activate gas solenoid
SYMBOL  Extend          = PIN2                  '  management
SYMBOL  Door            = PIN0


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

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


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

SYMBOL  timer           = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00010101                              ' set outputs

  timer = 0                                     ' reset timer


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

Main:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 200 THEN Main                      ' wait for 0.2 sec input

Read_Delay:
' POT Delay, 103, timer                         ' read pot, 5..255
'
  timer = timer / 5 + 9 * 1000                  ' scale to 10000 to 60000

Open_Sesame:
  Solenoid = IsOn
  Door = IsOn                                   ' activate actuator
  PAUSE 1000
  Door = IsOff

  Extend = IsOn
  Retract = IsOff
  PAUSE timer

Check_PIR:
' timer = PIR * 2000
' PAUSE timer
' IF PIR = IsOn THEN Check_PIR

Close_Door:
  Extend = IsOff
  Retract = IsOn
  PAUSE 5000
  Solenoid = IsOff
  GOTO Reset                                    ' reset everything

JonnyMac

For future reference, it's always best to explain what you want in total. Who's to say that someone else wouldn't write a better program for you?

Right off, it looks like you've added a solenoid to PIN3/OUT3 but you're not setting that pin to output mode with the DIRS register. To make it an output, change the DIRS configuration line to:

DIRS = %00011101                              ' set outputs    

Note that BIT3 (4th from right) is now "1" (output) where in your program it's a "0" (input).
Jon McPhalen
EFX-TEK Hollywood Office

pbronson

June 28, 2015, 12:25:44 PM #2 Last Edit: June 28, 2015, 12:40:01 PM by pbronson
Thanks Jon,
That fixed it and the program works great now. I know that I am pushing the capabilities of the controller as far a current and was wondering if anyone has any suggestions on a relay board to control the solenoid.

Pete

JonnyMac

Jon McPhalen
EFX-TEK Hollywood Office

pbronson

Thanks, just placed an order.

Thanks again for the help.

Pete