November 22, 2024, 01:01:38 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


VMusic 2 and a Prop2 Trainer

Started by time2dive, March 12, 2009, 03:38:37 AM

Previous topic - Next topic

time2dive

I recently got a Prop2  and the trainer that goes with it.  I am trying to make it work with a VMusic2 module.  I removed the uln2803a and put in the uln2003a when I installed the trainer.   The trainer and the uln2003a are in the upper section.  Do I need to clip the pins on the uln2803a on the lower section to make the VMusic2 module work.  Instead of clipping pins can I install a uln203a in the lower section. 
I am still new at the Prop2 and have not programmed in basic for 15 years.  It should come back to me.  I am sure I will have other questions later about how to control solenoids for my pneumatics.

Bill P

Here is a link to the documention for the trainer.

http://www.efx-tek.com/downloads/prop-1_trainer_docs.pdf

Hope this helps.

Bill

JonnyMac

You could use the Prop-1 Trainer on the P0-P7 group which would allow you to free-up pins on the P8-P15 group for VMUSIC.  Do you have a specific application or is this just an experiment?
Jon McPhalen
EFX-TEK Hollywood Office

time2dive

It is both an experiment and I am learning as I go to upgrade a project from last year.  I plan on starting the soundtrack, then using pneumatics opening and closing some doors, then flashing some LEDs on and off a few times as well as a few bursts from a fog machine.  It is a bit elaborate for my first project, but I figure that I will learn a lot from it.   I have already written the code for the doors, it works using the trainer.  I ran into problems with the VM2.  The instructions that I had never mentioned cutting the pins in the IC.  I could not get any audio out of the VM2 so I may have wrongly assumed that I had a bad module and sent it back for replacement,  Do I need to cut the pins on the IC on the lower half if I have a uln2003a in the upper half, or can I replace the uln28903a with a uln2003a in the lower half.  I hate cutting things if I don't have to, it tend to be permanent.
I figure that I will need to get the relay module to power the control for the fog machine.  That comes later.  I want to get each part of the project working before I add the next step.

Tim

JonnyMac

The Prop-1 Trainer instructions do say that you need to swap the ULN2803 for a ULN2003 if you want to use the POT circuit --if not, you can use use the button and LEDs without changing the ULN.

I always use TX and RX with the VMUSIC so I can know it's status at any time -- this takes two pins and as with other True-mode serial devices the ULN load must be removed from those pins.
Jon McPhalen
EFX-TEK Hollywood Office

time2dive

I am still having problems getting my VMusic2 module to work.  I got a new VM2 so I pretty sure that it is not the VM2.
I have it wired up (as near as I can figure out) according to Scarey Terry's page and the Garage of Evil's page.  I have removed the two pins on the upper IC, I did upload ftrfb.ftd



I am using the following program to try and make things work...


' =========================================================================
'
'   File....... vm2_bs2_demo.bs2
'   Purpose.... Demonstrate VMusic2 driven by a BASIC Stamp 2 or Prop-2
'   Author..... Scary Terry
'   E-mail..... terry@scary-terry.com
'   Started.... 4/16/2008
'   Updated....
'
'   {$STAMP BS2}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
' Sends serial commands to the VMusic2 via the RXD input.  The following are the individual commands:
' VPF file CR   Plays single file where "file" is MP3 name, MAXIMUM 8 CHARACTERS PLUS EXTENSION (8.3)
' VST CR        Stops play
' V3A CR        Plays all MP3 files
' VRA CR        Repeatedly plays all MP3 files
' VRR CR        Repeatedly plays random MP3 files
' VSF CR        Skip forward one track
' VSB CR        Skip back one track
' VP CR         Pause
' VSV byte CR   Sets playback volume, "byte" ranges from 0 loud to 256 off

'Also receives serial data from VMusic2 via the TXD output.  I've found about the only useful thing it
'sends is ">" followed by the word "Stopped" at the end of a playback file.

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

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

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

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

' -----[ EEPROM Data ]-----------------------------------------------------

' -----[ Initialization ]--------------------------------------------------
PAUSE 5000                                'allow VMusic2 to initialize
SEROUT 0,84, ["VST",CR]                   'stop anything that's playing
' -----[ Program Code ]----------------------------------------------------

Main:

SEROUT 0,84,["VPF test.mp3",CR]           'Play a file named "test.mp3"
PAUSE 5000
SEROUT 0,84,["VP",CR]                     'Pause playback of "test.mp3"
PAUSE 3000
SEROUT 0,84,["VP",CR]                     'Resume playback of "test.mp3"
PAUSE 5000
SEROUT 0,84, ["VSV 30",CR]                'Reduce playback volume
PAUSE 5000
SEROUT 0,84, ["VSV 0",CR]                 'Return playback volume to full
PAUSE 5000
SEROUT 0,84, ["VST",CR]                   'Stop playback of "test.mp3"

SEROUT 0,84, ["V3A",CR]                   'Command to play all mp3 files.  It will play whatever file it first finds
PAUSE 5000
SEROUT 0,84, ["VSF",CR]                   'Skip forward one track.  It will play the next file
PAUSE 5000
SEROUT 0,84, ["VSB",CR]                   'Backs up to the start of this track.
PAUSE 5000
SEROUT 0,84, ["VST",CR]                   'Stop playback

SEROUT 0,84,["VPF test2.mp3",CR]          'Play a file named "test2.mp3"
PAUSE 2000
SERIN 1,84, [WAIT (">")]                  'Waits for "test2.mp3" to stop playing
PAUSE 2000

GOTO Main

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

The VM2 does not do a damn thing...
So what if anything did I do wrong and how does P8 and P9 know to be serial inputs and outputs.  I see no where in the code that tells the Prop2 that a certain pin is a serial output rather than turning on an LED..... am I missing something or still too new at this?

a Frustrated and Confused...
Timothy Ewing

JonnyMac

March 17, 2009, 03:30:36 PM #6 Last Edit: March 17, 2009, 03:41:13 PM by JonnyMac
QuoteI see no where in the code that tells the Prop2 that a certain pin is a serial output rather than turning on an LED..... am I missing something or still too new at this?

You're missing something.  Your code says SEROUT 0 which means it's sending commands on P0 and yet you have it connected to P8 (maybe P9) -- that's the big problem.  Also, the ULN will be a problem in some cases so it's best to get it out of the way.  Trust me, please, I've been doing this stuff a very long time.

In my opinion you should use P12 and P13 with the ULN pins removed and the SETUP jumpers moved to the UP position.  I've done this, it works.

Here's a re-post of my [working] code:

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


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


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


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

Sio             PIN     15                      ' no ULN / SETUP = UP
Trigger         PIN     14                      ' no ULN / SETUP = DN
TX              PIN     13                      ' no ULN / SETUP = UP
RX              PIN     12                      ' no ULN / SETUP = UP


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

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

Yes             CON     1
No              CON     0

VolMax          CON     $00
VolMin          CON     $FE


T2400           CON     396
T9600           CON     84
T19K2           CON     32
T38K4           CON     6

SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000
Baud            CON     Open + T9600


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

flags           VAR     Byte
rptMode        VAR     flags.BIT0
isPaused       VAR     flags.BIT1

theMP3          VAR     Byte                    ' MP3 file pointer
char            VAR     Byte                    ' character value
eePntr          VAR     Word                    ' EEPROM memory pointer

volume          VAR     Byte

panCtrl         VAR     Word
lvlLeft        VAR     panCtrl.BYTE0
lvlRight       VAR     panCtrl.BYTE1


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

Reset:
  PAUSE 2250                                    ' let VMUSIC power up

  SEROUT TX, Baud, [CR]                         ' ping (if no power-up)
  GOSUB VM_Wait_Prompt

  GOSUB VM_Stop                                 ' stop if playing
  GOSUB VM_Wait_Prompt

  volume = VolMax                               ' reset volume level
  GOSUB VM_Volume

  flags = %00000000                             ' clear flags


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

Main:
  DEBUG CLS, "Playing: Firefly theme.", CR
  theMP3 = 0
  GOSUB VM_Play
  GOSUB VM_Wait_Start
  DEBUG "-- file started", CR

  PAUSE 5000
  volume = 40
  GOSUB VM_Volume
  GOSUB VM_Wait_Prompt
  DEBUG "-- volume reduced", CR

  GOSUB VM_Wait_Prompt
  DEBUG "-- ready for new song", CR, CR


Pan_Test:
  DEBUG "Playing: Spalding.", CR
  theMP3 = 4
  GOSUB VM_Play
  GOSUB VM_Wait_Start

  lvlLeft = VolMax                              ' pan to left
  lvlRight = VolMin
  GOSUB VM_Pan
  DEBUG "-- pan left", CR

  PAUSE 3500                                    ' wait for dead spot

  lvlLeft = VolMin                              ' pan to right
  lvlRight = VolMax
  GOSUB VM_Pan
  DEBUG "-- pan right", CR, CR

  DEBUG "Good-bye"
  END


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

' Pass file # (index in DATA table) to play in "theMP3"

VM_Play:
  rptMode = No
  GOTO Play_MP3

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

' Pass file # (index in DATA table) to play in "theMP3"

VM_Repeat:
  rptMode = Yes
  GOTO Play_MP3

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

' Pass file # (index in DATA table) to play in "theMP3"
' -- add DATA label entries to LOOKUP as required

Play_MP3:
  LOOKUP theMP3, [SFX0, SFX1, SFX2,
                  SFX3, SFX4, SFX5], eePntr     ' get base address

Send_Play_Cmd:
  IF (rptMode = No) THEN
    SEROUT TX, Baud, ["VPF "]                   ' start play command
  ELSE
    SEROUT TX, Baud, ["VRF "]                   ' start repeat command
  ENDIF

Send_Name:                                      ' send file title
  DO
    READ eePntr, char
    eePntr = eePntr + 1
    IF (char = 0) THEN EXIT
    SEROUT TX, Baud, [char]
  LOOP

Finish_Cmd:
  SEROUT TX, Baud, [".MP3", CR]                 ' send extention + CR
  RETURN

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

VM_Stop:
  SEROUT TX, Baud, ["VST", CR]
  RETURN

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

VM_Pause:
  IF (isPaused = No) THEN
    SEROUT TX, Baud, ["VP", CR]
    isPaused = Yes
  ENDIF
  RETURN

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

VM_Resume:
  IF (isPaused = Yes) THEN
    SEROUT TX, Baud, ["VP", CR]
    isPaused = No
  ENDIF
  RETURN

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

' Pass volume (0 = loudest, 254 = muted) in "volume"

VM_Volume:
  volume = volume MAX $FE                       ' limit per spec

  ' copy to pan register for future use

  lvlLeft = volume
  lvlRight = volume

  SEROUT TX, Baud, ["VSV ", IHEX2 volume, CR]
  RETURN

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

' Pass levels (0 = loudest, 254 = muted) in "lvlLeft" and "lvlRight"
'
' NOTE: The VPF command seems to reset volume levels so you must use a
'       pan command while the file is playing for it to work.

VM_Pan:
  lvlLeft = lvlLeft MAX $FE                     ' limit per spec
  lvlRight = lvlRight MAX $FE

  SEROUT TX, Baud, ["VWR $0B", HEX4 panCtrl, CR]
  RETURN

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

VM_Wait_Prompt:
  SERIN RX, Baud, [WAIT(">")]
  RETURN

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

VM_Wait_Start:
  SERIN RX, Baud, [WAIT("T $0")]
  RETURN


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

' MP3 files are stored in root of USB memory stick
' Table below needs only name, followed by a zero
' Keep names short to conserve EE space

SFX0            DATA    "Firefly", 0
SFX1            DATA    "Serenity", 0
SFX2            DATA    "Fruity", 0
SFX3            DATA    "Angel", 0
SFX4            DATA    "Spalding", 0
SFX5            DATA    "Thunder", 0


Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Something to remember: the TX pin of the VMUSIC needs to connect to your RX pin (the one that uses SERIN) on the Prop-2; the RX pin on the VMUSIC needs to connect to your TX pin (the one that uses SEROUT).
Jon McPhalen
EFX-TEK Hollywood Office

time2dive

I am more than glad to listen to people that know more than I do....which is many people.

As near as I can figure out I now have TXD going to P13 and RXD going to P12.  Should all of the SETUP jumpers be moved to the up position or just the first one.  To keep things as simple as possible (using your code) I should rename my mp3 files to Firefly and Serenity correct?  The ULN with the pins removed coresponds with P8-P15

time2dive

What if anything should I be seeing on the "Debug Terminal"?

Tim

JonnyMac

March 17, 2009, 05:15:21 PM #10 Last Edit: March 17, 2009, 06:45:32 PM by JonnyMac
It's all in spelled out in the program -- I think your frustration is causing you to skip over some things.

1) The position of the SETUP jumpers is spelled out in the PIN declarations section

2) TxD on the VMUSIC needs to connect to RX (P12) on the Prop-2; and vice versa
    -- you connect the "mouth" (TX) of one to the "ear" (RX) of the other

3) You don't have to rename your MP3s; easier to put the name of your MP3s in the listing -- without the .MP3 extension.  All of this is in the DATA section at the end of the listing

4) The Debug window tell you what's playing and when -- shows you that the Prop-2 is in control.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

I whipped up this graphic to help clarify the connections I use:

Jon McPhalen
EFX-TEK Hollywood Office

time2dive

The continuing saga of me and VM2....After doing everything that JonnyMac said to do with no luck what soever I gave up temporarily and ordered a new VM2 from a different company as well as an interface cable to hook up the VM2 directly to my computer.  After a few trials and tribulations making hyper terminal talk to the VM2 I finally got the new module to work....now to try the old module, it was dead and it was the replacement for the very first VM2 that I got.  I followed Scarey Terry's instructions how to reflash the player and the old module started working with hyper terminal.  Now for the big test would they work with the Prop2.... Success both VM2 work with the Prop2 using both JonnyMac's program as well as the Garage of Evil's program.  It was the VM2 module all along or the idiot that upgraded the ftrfb...no, it had to be a bad VM2
Now I can learn more how to make it do what I want it to and interface it with my "Doors from Hell" routine
Thanks for all of the help.

Tim