May 20, 2024, 12:22:40 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.


Initial Programming

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

Previous topic - Next topic

bgarth

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".

JonnyMac

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.
Jon McPhalen
EFX-TEK Hollywood Office

bgarth

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.

gadget-evilusions

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?
Brian
Evilusions LLC
www.evilusions.com for all your pneumatic components

JonnyMac

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 ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

bgarth

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.
 

JonnyMac

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.

Jon McPhalen
EFX-TEK Hollywood Office

bgarth

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!

bgarth

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.

JonnyMac

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....
Jon McPhalen
EFX-TEK Hollywood Office

bgarth

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.
 

BigRez

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.)

JonnyMac

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 ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

bgarth

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!

JackMan

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.  ;)