November 22, 2024, 07:06:50 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.


vmusic2 program needed

Started by Vasago, September 14, 2008, 06:25:24 PM

Previous topic - Next topic

Vasago

Hey guys,

I'm pretty deep into building Halloween props at the moment and could use some assistance with my FCG prop. Basically the program needs to do the following:

There should be a background music played by VMUSIC2 unit with a "graveyrd.mp3" this is a very long piece (hence vmusic2 player and not AP8) on and some background lighting (blueish) controlled by RC4 unit. 

When triggered by an PIR sensor, the background music and light will change to a different setting.  The new mp3 file called "Midnight.mp3" will start for a bout 2.5 minutes accompanied by the FCG movement triggered via RC4. 

When music ends the ghost will stop moving at the same time and everything will reset.  The FCG movement and the "Midnight.MP3" cannot be re-triggered for a full 5 minutes after stopping.

Thanks for the help,

Vasago


JonnyMac

"... will change to a different setting" is not something I can program.  If you can be more specific about the RC-4 outputs vis-a-vis the rest of the program I can write something for you that should get you very close if not right on.
Jon McPhalen
EFX-TEK Hollywood Office

Vasago

Thanks for a fast reply Jon.

By "change to a different setting" I mean the RC4 will open a relay to FCG to move at the same time as "MIDNIGHT.MP3" score on vmusic2 mp3 player.  I just want to make sure it will move only for the duration of the score (about 2.5 minutes or so).   Once the score is over, everything gets reset to the background mood setting light (blueish) and  "Graveyrd.mp3" score.

Vasago

Vasago

Oh one more thing,

The background music score "gravyard.mp3" is 15 minutes long and should be looping continuously until PIR is triggered.

Vasago

JonnyMac

September 15, 2008, 08:29:46 AM #4 Last Edit: September 18, 2008, 03:32:15 PM by JonnyMac
Well, you still didn't give me the specifics on the RC-4 (how many relays and when they switch) so this is my best guess.  Note that I've not used the VMUSIC player in repeat mode so you may have to experiment a bit.  I have used the VM_Wait_Prompt routine in other programs indicate the end of an audio file.

[Edit] 18 SEP 2008 - Added VM support code for better performance


' =========================================================================
'
'   File...... Vasago_FC.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... 18 SEP 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Connections:
'
'  * P7 <-- VMUSIC TX
'  * P6 --> VMUSIC RX
'  * P5 --> RC-4
'  * P4 <-- Parallax PIR sensor


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


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

SYMBOL  RX              = 7                     ' SETUP = UP, no ULN
SYMBOL  TX              = 6                     ' SETUP = UP, no ULN
SYMBOL  Sio             = 5                     ' clip ULN
SYMBOL  PIR             = PIN4                  ' active-high input


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

SYMBOL  Baud            = OT2400

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  relays          = B0
SYMBOL   Moodlight      =  BIT0                 ' connect to K1
SYMBOL   FCG            =  BIT1                 ' connect to K2
SYMBOL   K3             =  BIT2
SYMBOL   K4             =  BIT3

SYMBOL  timer           = W5


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

Reset:
  PAUSE 2500                                    ' let VMUSIC power up
  GOSUB VM_Stop                                 ' stop if playing
  GOSUB VM_Wait_Prompt

  relays = %0001                                ' mood light
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "S", relays)

  GOSUB Start_BG_Audio                          ' start background


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

Flying_Crank:
  GOSUB VM_Stop
  GOSUB VM_Wait_Prompt

  SEROUT TX, Baud, ("VPF midnight.mp3", 13)     ' start FC audio
  GOSUB VM_Wait_Start
  Moodlight = IsOff
  FCG = IsOn
  GOSUB Set_RC4
  GOSUB VM_Wait_Prompt                          ' let audio finish
  PAUSE 500
  FCG = IsOff
  Moodlight = IsOn
  GOSUB Set_RC4
  GOSUB Start_BG_Audio                          ' restart background

Pgm_Delay:
  FOR timer = 1 TO 300
    PAUSE 1000                                  ' 300 secs = 5 mins
  NEXT
  GOTO Main


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

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


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

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

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

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

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

Start_BG_Audio:
  SEROUT TX, Baud, ("VRF graveyrd.mp3", 13)     ' repeat file
  RETURN

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

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


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

Vasago

Jon,

I will test this code tonight after work and let you know how it goes.  The number of RC4 outputs are only 2: the mood light (blue) and the FCG.  The black light for FCG will be on the same relay with FCG so there are no other outputs that I can think of needed.

Thanks again,

Vasago

JonnyMac

Some MP3 files are slow to start due to large ID3 headers; I updated the program to deal with that -- the updated sections are red (see above).
Jon McPhalen
EFX-TEK Hollywood Office

dr.frankenscream

Vasago,

I have a very similar set-up to yours (Prop1, RC4 & VMusic2 using PIR for trigger).  Along with the EFX-TEK Support site here, I have found two other websites that were useful for me as a newbie.  They also have some test programs to help learn basic PBasic commands.

www.scary-terry.com (under vMusic2 section)
www.garageofevil.com (under TECH section)

Good luck with your prop.  It sounds cool.

Dr. Frankenscream

Vasago

dr.frankenscream,

Thanks for the words of encouragement.   I think I am running into similar issues as you've had.  The test programs on the sites you've mention work perfectly for me, however making prop work as I want it to (Jon's version) seems a little more challenging.  I need to do a little more experimentation with it, and the time is in short supply.   Were you able to make it work for you?

Vasago

JonnyMac

September 16, 2008, 11:59:17 PM #9 Last Edit: September 17, 2008, 03:27:58 AM by JonnyMac
I don't write "test" code -- well, not for my friends; the countless hours of experiments stay safely in my computer and I deliver to you -- to the best of my ability, anyway -- production quality code.  Why?  You deserve it.  Yeah, there are sometimes easier way to do things but they are usually fraught with problems that one wouldn't consider without a few years under their belt.   I have a few.  And trust me, through every season I get those cries for help, "Well, this code worked for them...."  Be a little careful with "test" code; it's usually designed to show off a feature/function in isolation and will sometimes fail when you attempt to integrate it into a production program.  Not always, of course, but until you have the time to do a lot of experimenting on your own you cannot know.

Keep in mind that some of the things that some of you ask for are actually quite sophisticated.  John and I didn't learn this stuff in a week -- give yourself a little time.  Like us, you can learn it and so long as you want to, we'll be here to help.
Jon McPhalen
EFX-TEK Hollywood Office

Vasago

Jon,

Your point is well taken and highly appreciated.

So back to the business at hand...  I was able to make your program work, but experiencing some problems.

Some of the time program works perfectly and transition from Background lighting routine to Main routine takes place flawlessly.  However, once in a while, when PIR triggered, the RC switches, as it should to trigger FCG, but only stays in that position for a fraction of a second and resets to background lighting and sound again.   

In addition, I've made this change for the program to work.

SYMBOL  RX              = 7                     ' SETUP = UP, no ULN
SYMBOL  TX              = 6                     ' SETUP = UP, no ULN

changed to

SYMBOL  TX              = 7                     ' SETUP = UP, no ULN
SYMBOL  RX              = 6                     ' SETUP = UP, no ULN


Any ideas what can be the problem with PIR triggering Main section but reseting?  The wierd part is that is works 1/2 the time as it should.



Thanks,

Vasago

JonnyMac

It doesn't matter which pin is defined as TX and RX so long as the connections on the other end are correct.  I used definitions from a cable I had that Scary Terry made for me.

I'm wondering if you're having a bit of a power issue.  What is the rating on on the power supply connected to the Prop-1 and the relays that you're using in the RC-4.  What seems to be happening is that the RC-4 is causing more load on the Prop-1 than usual causing it to reset itself.  Maybe what we need to do is switch the background light off and then the FCG on with separate statements.  This is not typical, but it's all I can think of without seeing your actual hardware.
Jon McPhalen
EFX-TEK Hollywood Office

Vasago

Jon,

All products use, including power supply is purchased in the online store of EFX-TEK.  The only other component is vmusic2 mp3 player.

I wanted to attach the pic but it sais file too large.

I will try again from work.


Vasago

Vasago

Lets try the picture reduced in size.


JonnyMac

Well, you reduced the file size, but not the image size.  Please crop the picture so that it's about 800x600 -- that works pretty well as far as size goes.

I have an idea about the problem.  Is the FCG powered from the strip that also powers the Prop-1's transformer?  If yes, the FCG start-up could be creating a noise pulse on the line that is upsetting the Prop-1 from time-to-time.  Try plugging the FCG into a different wall outlet.
Jon McPhalen
EFX-TEK Hollywood Office