November 23, 2024, 02:18:37 AM

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.


Initial Programming

Started by bgarth, December 29, 2009, 03:20:06 PM

Previous topic - Next topic

JonnyMac

January 07, 2010, 11:58:25 AM #15 Last Edit: January 07, 2010, 12:23:33 PM by JonnyMac
Give this a try -- but... I don't know that this will make a difference.  You see, the ULN2803 can run up to 0.5A (6w at 12v) with just one output and the LEDs don't apply much of a load.  This program demonstrates the use of a mask using OR (|) to turn the bits on, and AND-NOT (&\) to turn the pins off.  This program is actually more verbose than required; the green LED always operates with the valve and could be tied into the mask -- this version lets you do things like flash the LED independent of the valve.

' =========================================================================
'
'   File...... wg_v3.bs1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 07 JAN 2010
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Inputs:
'
'   P7 : Parallax PIR (PIR OUT pin connects to P7.W)
'   P6 : N.O. push-button (momentary contact) between P6.W and P6.R
'   P5 : N.O. push-button (push-on, push-off) between P5.W and P5.R
'   P4 : Reserved for future use
'
' Outputs:
'
'   OUT3 : Red LED beteween V+ and OUT3
'   OUT2 : Green LED between V+ and OUT2
'   OUT1 : ganged to OUT0
'   OUT0 : Valve between V+ and OUT0+OUT1


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


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

SYMBOL  PIR             = PIN7                  ' SETUP = DN
SYMBOL  Manual          = PIN6                  ' SETUP = DN
SYMBOL  Override        = PIN5                  ' ULN is pull-down

SYMBOL  Red             = PIN3                  ' 12v LED to V+/OUT2
SYMBOL  Green           = PIN2                  ' 12v LED to V+/OUT1
SYMBOL  ValveB          = PIN1                  ' ganged to OUT0
SYMBOL  ValveA          = PIN0                  ' Valve to V+/OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  ValveCtrl       = %00000011             ' valve control mask


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

SYMBOL  scan            = B0                    ' for inputs debouncing
SYMBOL   sPIR           =  BIT7
SYMBOL   sManual        =  BIT6
SYMBOL   sOverride      =  BIT5

SYMBOL  idx             = B2

SYMBOL  timer           = W5                    ' output timer


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

Reset:
 PINS = %00000000                              ' clear all
 DIRS = %00001111                              ' define output pins


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

Main:
 scan = %11100000                              ' assume active
 FOR idx = 1 TO 20                             ' debounce; 100ms tick
   scan = PINS & scan                          ' scan the inputs
   PAUSE 5
 NEXT


Check_Override:
 IF sOverride = No THEN Update_Timer           ' skip if override off
   PINS = PINS &/ ValveCtrl                    ' valve off
   Green = IsOff
   Red = IsOn
   timer = 0                                   ' reset timer
   GOTO Main


Update_Timer:
 Red = IsOff                                   ' off if not in override
 IF timer < 100 THEN Check_Manual              ' skip if not running
   timer = timer - 100                         ' update per debounce loop
   IF timer >= 100 THEN Check_Manual           ' skip if still running
     PINS = PINS &/ ValveCtrl                  ' valve off
     Green = IsOff


Check_Manual:
 IF sManual = Yes THEN Activate


Check_PIR:
 IF sPIR = Yes THEN Activate
   GOTO Main                                   ' no inputs, back to Main


Activate:
 timer = 60000                                 ' set timer for 1 minute
 PINS = PINS | ValveCtrl                       ' valve on
 Green = IsOn
 GOTO Main


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


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


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Quote from: JackMan on January 07, 2010, 11:57:33 AM
I have to agree with bigrez here, Kudos to Jon for keeping his cool. Just a friendly tip, wiring diagrams (schematics) are much clearer with straight line connections vs. a plate of spaghetti.  ;)

Both sides have been very cool and communicative -- creative types are often very expressive (that's my excuse!) and it doesn't' always read well in the sterility of typed text.  Barry and I have had several very friendly phone conversations and his product development cycle is moving forward nicely.
Jon McPhalen
EFX-TEK Hollywood Office

bgarth

It almost worked by pairing up on the two outputs to activate the water valve. We need a little more juice to activate it. What can we do here to achieve this?

gadget-evilusions

What are the specs on the valve? I dont understand your "3.2 current amps". I regularly power up to 500ma on one channel, which would be a 6w valve coil at 12vdc. You wouldn't be able to draw that much power however if you have several other outputs on at the same time without the ULN burning out.
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

Barry,

It would be helpful to know the make/model of your valve.

For a lot of current, I use a TIP-120 circuit as shown below -- you can get all the parts at RadioShack.



Here's one I built for a Halloween project:



And connected to the Prop-1; note the white wire goes to the Px.W pin (TTL), the others go to V+ (yellow) and GND (black):



Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Just a note: You don't see the 1N4001 in my board above because I used that board to power a lamp (resistive load); for valves (inductive loads) the diode really should be there.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

Another easy route to achieve this is with a small SPST relay (about $5 at RadioShack) . The relay needs to be the same voltage that you have powering the Prop-1. Connect a separate power supply of appropriate voltage/amperage to your water valve and the normally open contacts of the relay. Power the relay from V+ and OUTx and you're good to go.

JonnyMac

JackMan's suggestion is absolutely valid -- here's how you'd wire it up:



We really need to know the specs on the solenoid.  If it exceeds 1A for more than a few milliseconds (e.g., inrush current) it could cause the Prop-1 brown-out circuit to kick in and reset the controller.  You may need, for your experiments, anyway, to provide a larger capacity power supply for the valve.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

January 09, 2010, 10:26:17 AM #23 Last Edit: January 10, 2010, 12:43:55 PM by JackMan
That's why I suggested a separate power supply just for the water valve. It wouldn't be wired to the Prop-1 at all, just the N.O. contacts of the relay. Positive from the water valve power supply to the valve, negative to one of the N.O. contacts of the relay, the other N.O. contact to the negative side of the water valve. The only current draw from the Prop-1 would be to energize the relay which is very minimal.

bgarth

We are up and running! Special thanks to JonnyMac and EFX-TEK for all the programming and superior technical support. Another thanks to JackMan's SPST relay idea. The main problem we had to overcome here was the water valve  inrush current of 3.2 amps for 72 ms.  By upping the power supply from a 1 amp to a 2 amp, and by adding the SPST relay solved our inrush current problems. Time to move on now to our next prototype that has similarities but yet differences that will be interesting to overcome. Thanks Again!