November 24, 2024, 03:08:37 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Prop 1 Controller for Dummies

Started by eboomer, September 09, 2008, 10:18:44 AM

Previous topic - Next topic

eboomer

i am just too way of a newbie to even tackle this.  i have read pretty much most of the forums about programming and last night myself and a friend "attempted" to program just a simple event.  we tried to connect the pir to the controller and put the program to prevent false triggering like it said and then have one piston stay open for 10 seconds and in the middle of that have another piston stay open for 5 and close and then the first one would close shortly thereafter.  unfortunately we did not accomplish this.  i tried several programs that i have read but it just would not work.  is there a prop 1 controller for dummies that i can read to get a better grip on this?  or can SOMEONE help out?  any help is definitely appreciated!  thanks in advance

JonnyMac

September 09, 2008, 10:46:54 AM #1 Last Edit: September 09, 2008, 10:49:21 AM by JonnyMac
Not yet.  Writing books, I'm learning the hard way, is not as easy as writing a magazine column like I've been doing for the last nine years (for Nuts & Volts).  That said, on my "To Do" list is a book called, "Prop-1 Programming for Everyone -- From Zero to Hero Without Bending Your Brain or Breaking a Sweat."

Don't fret.  Tell us what you want to do (give us ALL the details) and we'll show you the way.  When you see your program specifications spelled out in Prop-1 code it will start to come together.  And be patient with yourself.  John and I have been programming for nearly 30 years each -- that's a lot of practice that you won't learn overnight, even if you had a "For Dummies" book.  Once you do get going, spend a little time each day just playing and experimenting (I give myself about an hour each morning just to experiment).  Experience is the best teacher and, before you know it, you'll be banging out Prop-1 programs as quickly as we do.

One of the things that is helpful to learn is to breakup your prop events into chunks.  Remember, the Prop-1 does one thing at a time so if you want to co-mingle activities, you may have to use more than one timing command.  For example, lets say that after detection you wanted Valve #1 to come on for 10 seconds, and four seconds into Valve #1 you want Valve #2 to come on for five seconds.  Here's how you have to code this:

' =========================================================================
'
'   File......
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Valve2          = PIN1                  ' use V+ and OUT1
SYMBOL  Valve1          = PIN0                  ' use V+ and OUT0


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

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


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

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000011                              ' make P0-P1 outputs


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  Valve1 = IsOn
  PAUSE 4000

  Valve2 = IsOn
  PAUSE 5000

  Valve2 = IsOff
  PAUSE 1000

  GOTO Reset                                    ' everything off


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


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


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


Okay, a couple things to keep in mind:
-- when you turn an output on or off, it stays that way until you change it
-- PAUSE only creates a delay, it does not affect IO pin states
-- if you add up all the delays after Valve1 comes on, you get 10 seconds (4000 + 5000 + 1000 = 10000 ms, 10 seconds)
-- I use the Reset section to clear everything, so there is no explicit command for turning off Valve #1
Jon McPhalen
EFX-TEK Hollywood Office

eboomer

thank you so much for your help and attention to detail.   i guess too that i will learn by trial and error, hopefully not too many errors!  can't thank you enough and you'll probably be seeing more posts of mine.  keep up the great work!