November 23, 2024, 04:19:03 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.


Zombie Thrasher help

Started by jrhogan, September 17, 2010, 10:57:32 AM

Previous topic - Next topic

jrhogan

http://www.efx-tek.com/php/smf/index.php?topic=1103.0

im trying to make this program work sans VM2 player and am so far very unsuccessfull, I was hoping someone could help me edit the program code to work without the player.

Thanks for your time!

here is the code as found in the above thread


' =========================================================================
'
'   File...... Casa_Fear_Zombie.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...
'   Modified.. 17 JUN 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P5.W and P5.R
'
'
' After downloading this program you should cycle power on the Prop-1 to
' allow synchronization with the VMUSIC player.


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


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

SYMBOL  RX              = 7                     ' SETUP = UP; no ULN pin
SYMBOL  TX              = 6                     ' SETUP = UP; no ULN pin
SYMBOL  Trigger         = PIN5                  ' ULN is pull-down
SYMBOL  Shoulder2       = PIN1                  ' use V+/OUT1 terminals
SYMBOL  Shoulder1       = PIN0                  ' use V+/OUT0 terminals


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0                     ' put back to low/off

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' baud for VMusic


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

SYMBOL  idx             = B2
SYMBOL  valves          = B3
SYMBOL  last            = B4

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


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

Power_Up:
  PAUSE 2250                                    ' let VMUSIC power up

Reset:
  PINS = %00000000                              ' preset IO pins
  DIRS = %00000011                              ' define IO pins

  GOSUB VM_Stop                                 ' stop if playing
  GOSUB VM_Wait_Prompt

  PAUSE 10000                                   ' 10s inter-show delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' randomize lottery value
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' inc or clear timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Jump:
  PINS = %00000011                              ' both shoulders on
  PAUSE 1000                                    ' adjust for audio

Audio_Activate:
  SEROUT TX, Baud, ("VPF zombie.mp3", 13)
  GOSUB VM_Wait_Start
  PAUSE 100                                     ' adjust for audio

  timer = 0                                     ' reset timer

Thrasher:
  FOR idx = 1 TO 3                              ' big stir
    RANDOM lottery
  NEXT
  valves = lottery & %00000011

  IF valves = last THEN Thrasher                ' no repeats
    last = valves                               ' save for next cycle

  PINS = valves                                 ' update should outputs
  RANDOM lottery                                ' restir
  delay = lottery // 251 + 100                  ' delay 100 to 350 ms
  PAUSE delay
  timer = timer + delay                         ' update timer
  IF timer < 10000 THEN Thrasher                ' thrash for 10 seconds
    GOTO Reset


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

VM_Stop:
  SEROUT TX, Baud, ("VST", 13)
  RETURN

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

VM_Wait_Prompt:
  SERIN RX, Baud, (">")
  RETURN

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

VM_Wait_Start :
  SERIN RX, Baud, ("T $")
  RETURN


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

JonnyMac

Here you go:

' =========================================================================
'
'   File......
'   Purpose...
'   E-mail....
'   Started...
'   Modified.. 17 SEP 2010
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P5.W and P5.R


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


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

SYMBOL  Trigger         = PIN5                  ' ULN is pull-down
SYMBOL  Shoulder2       = PIN1                  ' use V+/OUT1 terminals
SYMBOL  Shoulder1       = PIN0                  ' use V+/OUT0 terminals


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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0                     ' put back to low/off

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  idx             = B2
SYMBOL  valves          = B3
SYMBOL  last            = B4

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


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

Reset:
  PINS = %00000000                              ' preset IO pins
  DIRS = %00000011                              ' define IO pins

  PAUSE 10000                                   ' 10s inter-show delay


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' randomize lottery value
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' inc or clear timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Jump:
  PINS = %00000011                              ' both shoulders on
  PAUSE 1000                                    ' adjust as desired

  timer = 0                                     ' reset timer

Thrasher:
  FOR idx = 1 TO 3                              ' big stir
    RANDOM lottery
  NEXT
  valves = lottery & %00000011

  IF valves = last THEN Thrasher                ' no repeats
    last = valves                               ' save for next cycle

  PINS = valves                                 ' update should outputs
  RANDOM lottery                                ' restir
  delay = lottery // 251 + 100                  ' delay 100 to 350 ms
  PAUSE delay
  timer = timer + delay                         ' update timer
  IF timer < 10000 THEN Thrasher                ' thrash for 10 seconds
    GOTO Reset


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


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


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


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

jrhogan

Thanks Jon, you guys are the best.

jrhogan

Jon,

if I want to leave the trainer attached, is there anything bad about changing the trigger from Pin5 to Pin6?

Ive made that slight change and it seems to be working, but want to make sure.


JonnyMac

You can change the trigger input from P5 to P6 -- I didn't as to minimize the changes in the code.  Make sure the P6 SETUP jumper is in the DN position.
Jon McPhalen
EFX-TEK Hollywood Office

jrhogan

Okay, one last question I promise  ::)

assmuming a servo could handle the abuse a prop like this could put out (if they last in RC cars, it should be no problem, right?) im thinking about over doing it again and installing a servo into a lightweight skull to control the mouth only and using it as the head on this prop.. what I would like to do is while in the props "rest" state (or off) id like to have an audio track going with some voice tracks (chatting, groaning, "brains", you get the idea) I could even run it as an angry greeter I suppose) and I want to sync the audio with the servo to give the prop alittle more life, and then when triggered have it go into its thrashing program like everyone else has done..

is this possible with a single prop-1 controller and vmusic2? (I know you hate the vmusic, but the price is right atm) Id love to just go with the AP16 but its just out of my budget for this year.

you told me about a new servo programmer thing a ma bob at the RMG gathering in june, should I save myself the headache and wait until its available or try and do it manually?

thanks again!

what do you think?

JonnyMac

September 17, 2010, 08:38:20 PM #6 Last Edit: September 17, 2010, 08:41:13 PM by JonnyMac
I think it would be somewhat less that fruitful to attempt.  First, the loads imposed on the prop by the thrashing around of the cylinders would probably break the servo.  Second, you're not going code synchronized servo motion with audio using a Prop-1 -- there's not enough memory and neither one of use has the patience, anyway.

Simple idea: put the jaw on a bit of a spring and just let it do what it does based on the motion; you can start the audio.  Will it be in sync?  No.  Will anyone care?  Not likely.

If you do need sync then you should control the servo through a "servo audio" board; we don't make one, but our friend, Carl Cowley, does.

Since you changed the direction of this thread I'm locking it.  If you want to use the original program (with VMUSIC) and add extras, please start another thread and give it an appropriate subject line.  Thanks.  
Jon McPhalen
EFX-TEK Hollywood Office