November 23, 2024, 08:12:42 AM

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.


program help! I'm stumped!

Started by insanehobbies, April 26, 2009, 10:58:02 AM

Previous topic - Next topic

insanehobbies

So I'm learning a few things. I know I must be missing some thing. I started with this program that Jon wrote and tried to modify it for what I'm trying to do. Lid1 comes on but doesn't turn off after the 3 seconds (it stays on) and Lid2 doesn't come on at all. But the random works fine. Can some one help me out with this?

Thanks Keith

EricTheMannn

Post the code and explain exactly what you want it to do, this way we all can help you out :)

-Eric

WooHoo

insanehobbies

April 26, 2009, 12:34:32 PM #2 Last Edit: April 26, 2009, 01:26:21 PM by insanehobbies
OOPS!! Sorry! Here it is. Also I want to add that the lids are opened with 12v solenoide's (one for each lid).

  ' =========================================================================
'
'   File...... Barrel_Lids.BS1
'   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... 15 OCT 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Lid3            = PIN2
SYMBOL  Lid2            = PIN1
SYMBOL  Lid1            = PIN0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  idx             = B2

SYMBOL  timer           = W3
SYMBOL  delay           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000111                              ' set outputs


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

Main:
  timer = 0                                     ' reset timer

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

  PAUSE 5000                                    ' 5 second delay
  timer = 0                                     ' reset timer

  HIGH Lid1                                     ' lift Lid1 left side
  PAUSE 3000                                    ' hold for 3 seconds
  LOW Lid1                                      ' retract Lid1 left side

  PAUSE 2000                                    ' 2 second delay

  HIGH Lid2                                     ' lift Lid2 right side
  PAUSE 3000                                    ' hold for 3 seconds
  LOW Lid2                                      ' retract Lid2 right side

  PAUSE 2000                                    ' 2 second delay

Shake_Em:
  FOR idx = 1 TO 3
    RANDOM lottery                              ' big stir
  NEXT
  PINS = lottery                                ' randomize lids
  delay = lottery // 100 + 500                  ' 0.25 to 0.50 seconds
  PAUSE delay
  timer = timer + delay
  IF timer < 20000 THEN Shake_Em                ' run for 20 seconds
    GOTO Reset


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


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


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

JonnyMac

It's easier to help when you explain what you do want versus what you don't want.  If you tell me how you'd like the program to behave I will make it happen.
Jon McPhalen
EFX-TEK Hollywood Office

insanehobbies

 ??? OK! I'm going to mimic the Krazy Kristin prop. Mine is Jack. Jack will be flat on his back in a straight jacket. I will have a pir, I want there to be a 5 second start delay. There will be three pneumatic cylinders one a each shoulder blade and on behind the neck. The head should pop first for @ 3 seconds (I will work on sound later) then down. then right shoulder shoulder up for @ 2 seconds then down, the left same. then again a little faster maybe @ 1sec. Then head up for 3 seconds then down, then right shoulder and left shoulder thrashing up and down for about 5 seconds then a little faster for 5 seconds, then head up for 3 seconds then down. then a 10 second delay before next start.

Thanks Keith  :D

EricTheMannn

April 26, 2009, 10:56:54 PM #5 Last Edit: April 28, 2009, 09:50:37 PM by EricTheMannn
I'm under the assumption that this is her, http://www.youtube.com/watch?v=tNsLTJt_KUM. Great choice of prop by the way, one of the thing's i would change is the placement of one of the cylinders for your "Jack Prop". the one behind the head, if you look closely the head is swinging freely. It may be a lot simpler and realistic this way. Only two cylinders for each shoulder and you should get the same rapid movement.  To make the head go forward you could allow both cylinders to activate quickly (in the video there is about 3 sec pause b4 she lunges forward, & about a 9 sec pause before the struggle routine, Then about 15 sec after that she lunges forward again etc...) [Edit] (If you're using 110v solenoids)The prop-1 & RC-4 With two Crydom SSR relays will work fantastic for this, a lot of control and quick activation. I did something similar last year,  I modified it a bit so you can play with it till its just right. This code is Only intended for use with a RC-4 connected to the prop-1 I highly recommend it.



' =========================================================================
'
'   File......  JackProp.bs1
'   Purpose...
'   Author.... Eric garthwait
'   E-mail.... ericthemannn@live.com
'   Started... 4/26/2009
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
' INTENDED TO USE WITH a prop-1 controller & rc-4 Board Test.


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


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

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


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  relays           = B0
SYMBOL   Left_Shoulder   = BIT0   'K1 On RC-4
SYMBOL   Right_Shoulder  = BIT1   'K2 On RC-4


SYMBOL  timer           = B2
SYMBOL  idx             = B3


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

Reset:
  PINS = %00000000                             ' clear all outputs
  DIRS = %00000000                             ' no direct outputs (yet)

  relays = IsOff
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")     ' clear RC-4 outputs

  PAUSE 30000                                  ' let PIR warm-up/delay


' -----[ 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


  PAUSE 3000                                   ' Halt for 6 seconds



  GOSUB Struggle_Routine                       ' Struggle Routine
  PAUSE 2000

  GOTO Reset                                   ' End of program, reset wait 30 seconds till next show

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

Update_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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

Struggle_Routine:
    FOR idx = 1 TO 3        'Amount of time's you want the cylinder to pop up and down
    Left_Shoulder = IsOn
    GOSUB Update_RC4
    PAUSE 500               'Amount of time you want the cylinder activated.
    Left_Shoulder = IsOff
    GOSUB Update_RC4
    PAUSE 500               'Amount of time you want the cylinder De-Activated

    FOR idx = 1 TO 3
    Right_Shoulder = IsOn
    GOSUB Update_RC4
    PAUSE 500
    Right_Shoulder = IsOff
    GOSUB Update_RC4
    PAUSE 500


  NEXT
  RETURN

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


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


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


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


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


I Hope this all Helps,

-Eric
WooHoo

insanehobbies

I just purchased the prop-1 less than a week ago. Although I'm a quick learner I've been reading so much I think I've confused myself. Anyway I started building props about two years ago and now I'm hooked. This particular prop is my challenge if I can understand this one and get through it I'll be rollin. I know I have a lot to learn but you have to start somewhere.
I like your idea with the two cylinders, but I think I'll experiment with the three. I really appreciate your help on this, and I'll take all the ideas I can get. Check out my first props if you get a chance. I'm planning on putting more detail into these this year. http://www.youtube.com/watch?v=KzeMA6--lB8 Can't wait to try the program out.

Thanks Again
Keith

JonnyMac

I think you're going to find two cylinders will create fewer mechanic problems -- but hey, an electronics engineer and and could be wrong.  Before you run a real program, make sure you can activate any combination of cylinders (you have eight combination with three cylinders) to check for mechanical interference or stresses.

And get to know the RANDOM instruction as it really brings props to life when used correctly.
Jon McPhalen
EFX-TEK Hollywood Office

insanehobbies

April 27, 2009, 02:35:44 PM #8 Last Edit: April 27, 2009, 04:56:46 PM by insanehobbies
Thanks Jon! I know I have a lot to learn. I'm sure you will here for me frequently. Jon if you have an opportunity could you write a program designed with two cylinders and the random so I can soak in some more info. A couple of questions #1 Will I be able to run it with the trainer? #2 why would I need the rc-4 if I use 12v solenoids?
Thanks Keith

JonnyMac

Give this a try -- it's very simple and will probably be very effective.  For 12v solenoids you don't need an RC-4 (I never suggested that you did).

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


' -----[ Program Description ]---------------------------------------------
'
' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, etc.)
'            -- clip pin 1 of ULN2803 or replace with ULN2003
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

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

SYMBOL  Valve2          = PIN1                  ' use V+/OUT1
SYMBOL  Valve1          = PIN0                  ' use V+/OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  idx             = B2

SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000011                              ' set output pins


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

Main:
  timer = 0                                     ' reset timer

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

  PAUSE 5000                                    ' 5-second delay
  timer = 0                                     ' reset the timer

Thrash:
  FOR idx = 1 TO 3
    RANDOM lottery                              ' big stir
  NEXT
  PINS = lottery & %11                          ' update outputs
  PAUSE 100                                     ' let valves move
  timer = timer + 100                           ' update timer
  IF timer < 10000 THEN Thrash                  ' run for 10 secs?
    PINS = %00000000                            ' yes, clear outputs

  PAUSE 10000                                   ' re-trigger delay
  GOTO Main


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


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


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

insanehobbies

May 04, 2009, 09:04:10 PM #10 Last Edit: May 04, 2009, 09:37:31 PM by insanehobbies
Thanks Eric and Jon for your help! Things are going good.
Thanks Keith

EricTheMannn

Anytime insanehobbies!

i cant wait to see the prop when its finished.

-Eric
WooHoo