November 23, 2024, 07:33:12 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


help please with code on man eating plant!

Started by brads, October 08, 2010, 01:14:55 PM

Previous topic - Next topic

brads

October 08, 2010, 01:14:55 PM Last Edit: October 08, 2010, 01:55:26 PM by brads
Hey Jon,

I may need a little help on this.

I want to run a man eating plants air cylinder mouth open and closed every second for 30 seconds,
while at the same time running a second cylinder open and closed for 30 seconds at a DIFFERENT open close interval
at the same time running a 3rd cylinder for 30 seconds at yet again a separate open close interval.

Is this possible?

I have a man eating plant (two plastic wheel barrows) opening and closing it's mouth with two banks of 10 each tiny air actuated singing plants on each side and i'm trying to sync them to a Ump3 soundtrack


I think the last time I saw you was in all electronics late last year!

bsnut

I don't see a problem with this at all. I will try to write a program for you tonight.

You spelled his name wrong, it is spelled like this "Jon".
William Stefan
The Basic Stamp Nut

brads

October 08, 2010, 01:55:04 PM #2 Last Edit: October 08, 2010, 02:00:29 PM by brads
Thanks a real much!
I forgot to mention I would like to set delays on the 2nd and 3rd cylinders separately so they don't start until a certain amount of seconds after cylinder 1 starts.
Also want to activate this with a PIR.

Sorry bout the misspell

Quote from: bsnut on October 08, 2010, 01:41:07 PM
I don't see a problem with this at all. I will try to write a program for you tonight.

You spelled his name wrong, it is spelled like this "Jon".

JackMan

You need to post more info. When you say "open and close every second" does that mean open for 1 second and closed for 1 second or 1 open/close cycle per second? How long is the delay from #1 start to #2 & #3 start? Do you want 2 & 3 to start together or do you need a delay between 2 & 3? How long of a delay? How long do you want 2 & 3 to be active after the 30 seconds has elapsed for #1? Just a note, if you're trying to sync the movements to audio it's very difficult to do this way.
Post as many details as possible on exactly what you want to do.

JonnyMac

1) Please don't call our anyone specifically for help -- this may be seen as dis-inviting other really qualified folks to assist and it's a violation of the forum guidelines you apparently forgot to read!  ;D

2) As the very qualified JackMan points out, there's not enough information to write your program.  One needs to know the common denominator when it comes to timing because a state machine will be required for this kind of prop.  That is to say that it can be done, but this program might have been better suited for an EZ-8.
Jon McPhalen
EFX-TEK Hollywood Office

brads

sorry guys,
lemme get some timing on it manually tonight and figure out what works best manually before I respond

Quote from: JackMan on October 08, 2010, 02:53:39 PM
You need to post more info. When you say "open and close every second" does that mean open for 1 second and closed for 1 second or 1 open/close cycle per second? How long is the delay from #1 start to #2 & #3 start? Do you want 2 & 3 to start together or do you need a delay between 2 & 3? How long of a delay? How long do you want 2 & 3 to be active after the 30 seconds has elapsed for #1? Just a note, if you're trying to sync the movements to audio it's very difficult to do this way.
Post as many details as possible on exactly what you want to do.

JackMan

Well, without having specific timing to go by, here's something for ya to try. It gives you a 60 second warm up/post delay on the PIR so it can't be re-triggered for 1 minute after the sequence ends (changeable value in RESET). The interval timing is 1/4 second between valves 1, 2, & 3 with each one switching on/off every second (1/2 second on, 1/2 second off) for a total of 30 seconds. Valve 1 completes 2 cycles (2 seconds) before valve 2 & 3 start. Valves 2 & 3 will continue for 2 cycles (2 seconds) after valve 1 stops. This timing is easily changed by the last number in the three lines  "FOR counter = 1 TO x"



' {$STAMP BS1}
' {$PBASIC 1.0}

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

SYMBOL PIR    = PIN6                       'PIR on PIN6  setup jumper DN
SYMBOL Valve1 = 0                          'Valve 1 on OUT0
SYMBOL Valve2 = 1                          'Valve 2 on OUT1
SYMBOL Valve3 = 2                          'Valve 3 on OUT2

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

SYMBOL timer     = B2
SYMBOL counter = B3

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

Reset:
  PINS = %00000000                            ' clear all outputs
  DIRS = %00111111                            ' make P0-P5 outputs

    PAUSE 60000                               '1 minute pause for PIR warm up

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

Main:
    timer = 0                                                ' reset timer

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

    FOR counter = 1 TO 2
     HIGH Valve1
     PAUSE 500
     LOW Valve1
     PAUSE 500
    NEXT

    FOR counter = 1 TO 28
     HIGH Valve1
     PAUSE 250
     HIGH Valve2
     PAUSE 250
     LOW Valve1
     HIGH Valve3
     PAUSE 250
     LOW Valve2
     PAUSE 250
     LOW Valve3
    NEXT

    FOR counter = 1 TO 2
     PAUSE 250
     HIGH Valve2
     PAUSE 250
     HIGH Valve3
     PAUSE 250
     LOW Valve2
     PAUSE 250
     LOW Valve3
    NEXT

    GOTO Reset

JonnyMac

Synchronization is out of the question without using show-control software like Vixen (you could use it to create a Prop-1 program).

Here's another approach.  After triggering it will run the "show" for ~30 seconds.  Each "mouth" has a hold-off timer so that you can control when it starts after the trigger is detected.  To make the mouth movements somewhat interesting, the open-close period is randomized each time through (from 100 to 250ms). 

This program is tricky to follow and should not be modified by beginners.  Sometimes -- as my friends in the DPRG say -- "It's harder than it looks."

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Mouth3          = PIN2
SYMBOL  Mouth2          = PIN1
SYMBOL  Mouth1          = PIN0


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

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

SYMBOL  Baud            = OT2400


' timing expressed in units set at Loop_Pad (25ms)

SYMBOL  M1Delay         = 0                     ' start immediately
SYMBOL  M2Delay         = 50                    ' start 1.25s later
SYMBOL  M3Delay         = 120                   ' start 3.00s later

SYMBOL  ShowLength      = 1200                  ' 30 seconds


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

SYMBOL  m1HoTimer       = B2                    ' hold-off timers
SYMBOL  m2HoTimer       = B3
SYMBOL  m3HoTimer       = B4

SYMBOL  m1MouthTimer    = B5                    ' mouth speed timers
SYMBOL  m2MouthTimer    = B6
SYMBOL  m3MouthTimer    = B7

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

  m1HoTimer = 0                                 ' reset all timers
  m2HoTimer = 0
  m3HoTimer = 0
  m1MouthTimer = 0
  m2MouthTimer = 0
  m3MouthTimer = 0


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

Main:
  timer = 0                                     ' reset timer

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


New_Show:
  timer = 0                                     ' reset show run timer


Check_1:
  IF m1HoTimer >= M1Delay THEN Update_1         ' reached delay time?
    m1HoTimer = m1HoTimer + 1                   ' no, inc timer
    GOTO Check_2                                ' check next

Update_1:
  IF m1MouthTimer = 0 THEN Move_1               ' time to move mouth?
    m1MouthTimer = m1MouthTimer - 1             ' no, update timer
    GOTO Check_2

Move_1:
  PINS = PINS ^ %00000001                       ' toggle Mouth1
  RANDOM lottery                                ' create new move time
  m1MouthTimer = lottery // 7 + 4               ' 4 to 10 = 100ms to 250ms


Check_2:
  IF m2HoTimer >= M2Delay THEN Update_2
    m2HoTimer = m2HoTimer + 1
    GOTO Check_3

Update_2:
  IF m2MouthTimer = 0 THEN Move_2
    m2MouthTimer = m2MouthTimer - 1
    GOTO Check_3

Move_2:
  PINS = PINS ^ %00000010
  RANDOM lottery
  m2MouthTimer = lottery // 7 + 4


Check_3:
  IF m3HoTimer >= M3Delay THEN Update_3
    m3HoTimer = m3HoTimer + 1
    GOTO Loop_Pad

Update_3:
  IF m3MouthTimer = 0 THEN Move_3
    m3MouthTimer = m3MouthTimer - 1
    GOTO Loop_Pad

Move_3:
  PINS = PINS ^ %00000100
  RANDOM lottery
  m3MouthTimer = lottery // 7 + 4


Loop_Pad:
  PAUSE 25                                     ' set loop timing
  timer = timer + 1
  IF timer >= ShowLength THEN Reset

  GOTO Check_1


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


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


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