The flow chart attached shows my complete function needs. With the Prop-1 Controller, how much can we do here?
Need a run program and connection points for the different components.
I downloaded Parallax Basic Stamp Editor and entered the run program from your product sheet (document version 2.3)...
' {STAMP BS1}
' {$PBASIC 1.0}
It came back with download complete at the bottom left, but it did not respond with "Hello, World".
I'm pretty good at programming but don't understand what you're trying to do with your flow chart. Please do me a favor: consider me stupid and spell it out in text as well. I should be able to link your text description and the chart to get a program working for you.
I attached a revised flow chart drawing and a flow chart functions page.
I also deleted the bypass switch and moisture sensor due to that those functions are not necessary at this time.
What are the specifics on the pir sensor your using? Is it the parrallax one?
What voltage and wattage is your solenoid valve?
What voltage and wattage is your relay?
What is "timer"? Is it another device or prop controller?
What voltage are your green and red leds?
Here you go -- give this a try. The push-on, push-off override button takes a bit of programming trickery, but if you study the code carefully it should all make sense.
' =========================================================================
'
' File...... wg.bs1
' Purpose...
' Author.... Jon Williams, EFX-TEK
' E-mail.... jwilliams@efx-tek.com
' Started...
' Updated... 30 DEC 2009
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
'
' Inputs:
'
' P7 : Parallax PIR
' P6 : N.O. push-button (momentary contact) between P6.W and P6.R
' P5 : N.O. push-button (momentary contact) between P5.W and P5.R
' P4 : N.O. toggle switch between P4.W and P4.R
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL PIR = PIN7 ' SETUP = DN
SYMBOL Manual = PIN6 ' SETUP = DN
SYMBOL Override = PIN5 ' ULN is pull-down
SYMBOL Enable = PIN4 ' ULN is pull-down
SYMBOL Red = PIN2
SYMBOL Green = PIN1
SYMBOL Valve = PIN0
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1 ' for active-high in/out
SYMBOL IsOff = 0
SYMBOL Yes = 1
SYMBOL No = 0
' -----[ Variables ]-------------------------------------------------------
SYMBOL scan = B0
SYMBOL sPIR = BIT7
SYMBOL sManual = BIT6
SYMBOL sOverride = BIT5
SYMBOL sEnable = BIT4
SYMBOL flags = B1
SYMBOL fOverride = BIT8
SYMBOL idx = B2
SYMBOL timer = W5 ' output timer
' -----[ Initialization ]--------------------------------------------------
Reset:
PINS = %00000000 ' clear all
DIRS = %00000111 ' define output pins
' -----[ Program Code ]----------------------------------------------------
Main:
GOSUB Scan_Inputs
Check_Enable:
IF sEnable = Yes THEN Check_Override_Button ' skip if enabled
timer = 0 ' clear everythinga
PINS = %00000000
flags = %00000000
GOTO Main
Check_Override_Button:
IF sOverride = No THEN Check_Override_Status
flags = flags ^ %00000001 ' toggle override bit
Force_Override_Release:
GOSUB Scan_Inputs
IF sOverride = Yes THEN Force_Override_Release
Check_Override_Status:
Red = fOverride ' clear red when off
IF fOverride = No THEN Update_Timer
timer = 0
Valve = IsOff
Green = IsOff
Red = IsOn
GOTO Main
Update_Timer:
IF timer = 0 THEN Check_Manual ' skip if not running
timer = timer - 100 ' update per debounce loop
IF timer > 100 THEN Check_Manual ' skip if still running
Green = IsOff ' clear outputs
Valve = IsOff
Check_Manual:
IF sManual = No THEN Check_PIR ' abort if not active
GOTO Activate
Check_PIR:
IF sPIR = No THEN Main ' abort if not active
GOTO Activate
Activate:
IF timer > 100 THEN Main ' abort if still running
timer = 60000 ' set for one minute
Green = IsOn ' acvtivate
Valve = IsOn
GOTO Main
' -----[ Subroutines ]-----------------------------------------------------
Scan_Inputs:
scan = %11110000 ' assume active
FOR idx = 1 TO 20 ' debounce; 100ms tick
scan = PINS & scan ' scan the inputs
PAUSE 5
NEXT
RETURN
' -------------------------------------------------------------------------
' -----[ User Data ]-------------------------------------------------------
I need further direction on component hookup. Would you be able to provide a simple wiring/hookup diagram?
I'm sure that would probably handle all my hookup questions listed below.
1. What output do I hookup the Solenoid valve? The valve is a 12v, 2w valve which is within the specs of the prop-1 controller as you recommended.
2. Where and how do I connect the trainer board?
3. Where and how do I connect the pir motion?
4. Where to connect the momentary switch?
5. What voltage LED's should be used and where to connect them.
We have diagrams in our documentation -- have you download that material and looked at it?
1. Please see the Prop-1 docs: http://www.efx-tek.com/downloads/prop-1_docs.pdf
-- you will use V+ and OUT0 for this program
2. This program is not compatible with the trainer; you have four inputs, the trainer only supports one
3. Again, we have docs for this: http://www.efx-tek.com/downloads/pir_docs.pdf
-- We usually use P6, your program is using P7 (follow the notes in the code)
4. The code listing spells this out -- see the notes at the top
5. That's up to you; what changes is the current limiter. If you use V+/OUTx connection then you'll need at least a 1K current limiter (for a typical LED); if you ue Px.W/Px.B then 470 will be fine.
I downloaded your program and it came back with download successful at the lower left part of the screen.
I still lack a few parts and won't be able to test it until after I can round them up and get everything hooked up.
Hopefully I can test it over the weekend or early part of next week. I'll let you know what happens. Thanks!
Cheers!
Your program downloaded successfully and I have everything hooked up, but have no response except the 2 LED's stay illuminated.
Created a wiring diagram attached for you to verify correct hookup.
Your program specifies a toggle switch on P4 that I don't think we need, and it calls for a momentary contact on P5 that is actually a push-on, push-off switch that I assume would work like a toggle switch.
You may have damaged something. As I told you on the phone and in our docs, the terminal block outputs are for 12 volts -- if I understand your diagram (which is very confusing to me) then you have one side of the LED connected to 12 volts and the other side connected to the Px.W terminals.
This is bad, bad, bad....
The other side of the LED, just as our docs show, should have been connected to the OUTx terminal block.
Man, I hope you didn't break something....
You need to be more specific and tell me what it is that is so confusing about my wiring diagram that I have provided to you. I previously have asked you for a simple wiring diagram before I started hooking things up, but you wouldn't supply me with one. A wiring diagram would only ensure that things will not get damaged. You are not fully communicating with me, and please be more specific and more detailed on where to hook things up. You told me in the past to give you as much information as possible, and I am trying to do just that, but you also in return need to provide as much information as possible and more than you think needed so it will ensure the overall success of our mission here. In addition, I am not the only one hooking this up, my father
(an electrical engineer) and I are both working together on this. Both of us are having a difficult time understanding your controller board and documentation (which is also very confusing) that you provided. How about you just take my wiring diagram and sketch in on how you think it should be and send it back with the needed programming changes. Our success here could only benefit us both. Once I get a successful working prototype together then it could lead to many more of these needed.
If there is some test-meter testing to be done to ensure that the board is not damaged then just let us know.
I think that's a bit harsh. ???
How could anyone provide you with a wiring diagram when you didn't provide answers to the specifications for the devices you're using?
What's confusing about your wiring diagram? Get rid of the start box and arrows; save those for a program logic flow. Remove the numbers in the right corner of each box UNLESS they refer to a specific port (p0, p1, etc) on the controller. Label each box with both its function and device type. For example, I assume the momentary start switch is a "Manual Trigger". The PIR is your "Event Trigger". Is the push on/off a "Safety On/Off" swtich?
Jon specifically stated above that the valve is connected to V+ and OUT1. And for the LEDs, he said to use EITHER V+ and OUTx, OR the Px.w and Px.b.
Jon has provided quite a bit of info and pointed you to several docs that contain everything you should need. I think you'll find he goes above and beyond to provide support, but we can't expect him to create our projects for us.
BTW... your project is looking very similar to one I created last summer to keep the cats out of my garden. Basically, I had two PIRs at each end of the garden and when they sensed movement, they sprayed the water for about 10 seconds. I didn't have a safety on/off switch but did have a manual trigger. (I will integrate it into the new watering system this spring.)
Okay, after a phone call to clear up confusion, the program actually gets simpler:
' =========================================================================
'
' File...... wg_v2.bs1
' Purpose...
' Author.... Jon Williams, EFX-TEK
' E-mail.... jwilliams@efx-tek.com
' Started...
' Updated... 04 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
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL PIR = PIN7 ' SETUP = DN
SYMBOL Manual = PIN6 ' SETUP = DN
SYMBOL Override = PIN5 ' ULN is pull-down
SYMBOL Red = PIN2 ' 12v LED to V+/OUT2
SYMBOL Green = PIN1 ' 12v LED to V+/OUT1
SYMBOL Valve = PIN0 ' Valve to V+/OUT0
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1 ' for active-high in/out
SYMBOL IsOff = 0
SYMBOL Yes = 1
SYMBOL No = 0
' -----[ 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 = %00000111 ' 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
Valve = IsOff
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
Valve = IsOff
Green = IsOff ' clear outputs
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
Valve = IsOn ' acvtivate
Green = IsOn
GOTO Main
' -----[ Subroutines ]-----------------------------------------------------
' -------------------------------------------------------------------------
' -----[ User Data ]-------------------------------------------------------
Excellent job on the programming Jon, but I have one small problem with the valve not able to latch on. Right now the solenoid makes a click and a hum, but the valve doesn't open. After digging further into the specifications for the valve, I discovered that it requires 3.2 current amps to latch the valve open. So it does look like we will need to pair it up on two outputs afterall in order to get up enough current to latch the valve open. Otherwise everything works great. Thanks for all your support!
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. ;)
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 ]-------------------------------------------------------
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.
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?
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.
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.
(http://www.efx-tek.com/files/tip120_control.png)
Here's one I built for a Halloween project:
(http://www.efx-tek.com/files/hc_board.jpg)
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):
(http://www.efx-tek.com/files/hc_connection.jpg)
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.
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.
JackMan's suggestion is absolutely valid -- here's how you'd wire it up:
(http://www.efx-tek.com/files/relay_valve.png)
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.
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.
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!