May 11, 2024, 11:09:41 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


updated coded and getting missing label

Started by reddragon, April 10, 2009, 04:42:20 AM

Previous topic - Next topic

reddragon

April 10, 2009, 04:42:20 AM Last Edit: April 10, 2009, 08:04:59 AM by JonnyMac
This is the updated code when i added the low input part of the code.

' =========================================================================
'
'   File...... VMusic.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 23 MAY 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Demo for VMUSIC2 player; based on work by "Scary" Terry Simmons
' -- P7 and P6 SETUP jumpers need to be in the UP position
' -- clip pins 1 and 2 from ULN2803, or pin 1 from the ULN2003
' -- trigger on P5 must be active-high; ULN acts as pull-down


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


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

SYMBOL  RX              = 7
SYMBOL  tx              = 6                     ' SETUP = UP, no ULN
SYMBOL  Trigger         = 5                      'SETUP = UP, no ULN

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

SYMBOL  Baud            = OT2400

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  theMP3          = B2                    ' MP3 file pointer
SYMBOL  char            = B3                    ' character value
SYMBOL  eePntr          = B4                    ' EEPROM memory pointer
SYMBOL  volume          = B5


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

Reset:
  PAUSE 2250                                    ' let VMUSIC power up
  GOSUB VM_Stop                                 ' stop if playing
  GOSUB VM_Wait_Prompt                          ' set P6 as input'jump in the DN
  DIRS %00100000                                ' set p5 as input

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

Main:
  timer = 0                                     ' reset timer

  Check_Trigger:
  PAUSE 5
  timer = timer + 5 * Trigger
  IF timer < 100 THEN Check_trigger
  INPUT
  DEBUG CLS, "death.MP3", CR
  theMP3 = 0
  GOSUB VM_Play
  GOSUB VM_Wait_Start
  DEBUG "-- file started", CR

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

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

  volume = 0
  GOSUB VM_Volume
  GOSUB VM_Wait_Prompt
  DEBUG "-- volume reset to max", CR, CR

  DEBUG "Playing getout.MP3", CR
  theMP3 = 1
  GOSUB VM_Play
  GOSUB VM_Wait_Start
  DEBUG "-- file started", CR, CR

  GOSUB VM_Wait_Prompt
  DEBUG "VMUSIC demo done", CR, CR

  PAUSE 5000
  GOTO Main


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

' Pass file # (index in EEPROM table) to play in "theMP3"
' -- add EEPROM address entries to LOOKUP as required
' -- if "theMP3" exceeds LOOKUP table first song in list will be played

VM_Play:
  eePntr = 0
  LOOKUP theMP3, ($00, $08, $11), eePntr
  SEROUT TX, Baud, ("VPF ")

Send_Name:                                      ' send file title
  READ eePntr, char
  IF char = 0 THEN Finish_Cmd
  SEROUT TX, Baud, (char)
  eePntr = eePntr + 1
  GOTO Send_Name

Finish_Cmd:
  SEROUT TX, Baud, (".mp3", 13)                 ' send extention + CR
  RETURN

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

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

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

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

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

VM_Pause:
  SEROUT TX, Baud, ("VP", 13)
  RETURN

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

VM_Resume:
  GOTO VM_Pause

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

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

VM_Volume:
  volume = volume MAX $FE                       ' limit per spec
  SEROUT TX, Baud, ("VSV ", #volume, 13)
  RETURN

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

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

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


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


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

' Use the Memory Map function from the editor (view in ASCII mode) to
' determine the starting addresses of each string.

Song_List:
  EEPROM ("death", 0)                         ' addr = $00
  EEPROM ("child", 0)                        ' addr = $08
  EEPROM ("getout", 0)                        ' addr = $11

BigRez

Syntax checking only, I found the following:

  • You don't have timer declared as a variable.  Add it into the variabled section such as   symbol timer = b6.
  • You need an equals sign on the DIRS %00100000 so it becomes DIRS = %00100000
  • The INPUT line needs to have a pin number after it.
Once you correct those, you may still have issues - I didnt look to see what it was doing.

JonnyMac

April 10, 2009, 08:11:56 AM #2 Last Edit: April 11, 2009, 09:21:58 AM by JonnyMac
I fixed your listing
  -- timer added
  -- removed DIRS instruction because it was no needed
  -- removed stray INPUT line (bogus command)
  -- corrected address array for your names

The last part is the trickiest.  You have to manually count the characters in the EEPROM table to determine the address of the first character of the string.

' =========================================================================
'
'   File...... VMusic.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK (www.efx-tek.com)
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 23 MAY 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Demo for VMUSIC2 player; based on work by "Scary" Terry Simmons
' -- P7 and P6 SETUP jumpers need to be in the UP position
' -- clip pins 1 and 2 from ULN2803, or pin 1 from the ULN2003
' -- trigger on P5 must be active-high; ULN acts as pull-down


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


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

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

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

SYMBOL  Baud            = OT2400

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  theMP3          = B2                    ' MP3 file pointer
SYMBOL  char            = B3                    ' character value
SYMBOL  eePntr          = B4                    ' EEPROM memory pointer
SYMBOL  volume          = B5
SYMBOL  timer           = B6


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

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


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5
  timer = timer + 5 * Trigger
  IF timer < 100 THEN Check_Trigger

  DEBUG CLS, "death.MP3", CR
  theMP3 = 0
  GOSUB VM_Play
  GOSUB VM_Wait_Start
  DEBUG "-- file started", CR

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

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

  volume = 0
  GOSUB VM_Volume
  GOSUB VM_Wait_Prompt
  DEBUG "-- volume reset to max", CR, CR

  DEBUG "Playing getout.MP3", CR
  theMP3 = 1
  GOSUB VM_Play
  GOSUB VM_Wait_Start
  DEBUG "-- file started", CR, CR

  GOSUB VM_Wait_Prompt
  DEBUG "VMUSIC demo done", CR, CR

  PAUSE 5000
  GOTO Main


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

' Pass file # (index in EEPROM table) to play in "theMP3"
' -- add EEPROM address entries to LOOKUP as required
' -- if "theMP3" exceeds LOOKUP table first song in list will be played

VM_Play:
  eePntr = 0
  LOOKUP theMP3, (0, 6, 12), eePntr
  SEROUT TX, Baud, ("VPF ")

Send_Name:                                      ' send file title
  READ eePntr, char
  IF char = 0 THEN Finish_Cmd
  SEROUT TX, Baud, (char)
  eePntr = eePntr + 1
  GOTO Send_Name

Finish_Cmd:
  SEROUT TX, Baud, (".mp3", 13)                 ' send extention + CR
  RETURN

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

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

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

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

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

VM_Pause:
  SEROUT TX, Baud, ("VP", 13)
  RETURN

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

VM_Resume:
  GOTO VM_Pause

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

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

VM_Volume:
  volume = volume MAX $FE                       ' limit per spec
  SEROUT TX, Baud, ("VSV ", #volume, 13)
  RETURN

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

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

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


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


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

' Use the Memory Map function from the editor (view in ASCII mode) to
' determine the starting addresses of each string.

Song_List:
  EEPROM ("death", 0)                           ' addr = 0
  EEPROM ("child", 0)                           ' addr = 6
  EEPROM ("getout", 0)                          ' addr = 12
Jon McPhalen
EFX-TEK Hollywood Office

reddragon

ok the program is on the prop one and I have the mat switch hooked to P5. w and P5. r nothing happenes after i step on the mat? Did I miss something. I have my vmusic2 on P7 and the TX yellow cable form the vmusic2 on P6. W

JonnyMac

1. Check your VMUSIC connections very carefully -- it requires a specific setup
2. Make sure that you've removed the ULN influence for P7 and P6 (cut the pins off the ULN)
3. Make sure the P7 and P6 SETUP jumpers are in the UP position
4. Make sure you've got the 2400 baud firmware installed in the VMUSIC player

The VMUSIC is tricky and gives everyone fits.



Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

I found a couple subtle "gotchas" with the code, too -- grab the updated version above.
Jon McPhalen
EFX-TEK Hollywood Office

reddragon

OK i have ran the code to the pop one and here is what happens when i hit the trigger the vmusic2 will once and the the thumb dive flashes like it received the command but after it flashes it stops and there is no sound or it don't flash showing that its about to play the files. steps taken: 1 checked my hook up to the one posted. 2 checked file names put on the file names i labeled them death , child and getout.3 double checked wires. it worked when i used scary Terry's prop 1 test file put it only played one file? I'm using you code that you wrote for me. I'm lost and i will probably be getting your sound chip when it is done that way i will know it will work with no problem scine your the maker of it.

JonnyMac

Maybe you don't have the 2400 baud firmware installed in the VMUSIC.  The program I posted works with the cable assembly above -- I've used this many times with success.
Jon McPhalen
EFX-TEK Hollywood Office

reddragon

Jon i ran the demo code from sarry terrys web sight to see if it might of been the vmusic player, but it works when i use that code with p0 and p1. I cant understand why that code works and the one you wrote dont??? I am still looking at the two codes and you wrote them bouth im confused? Is there a way to use that code and modify it with a trigger,and also i was thinking that if i used the p7 for the trigger and p6 as the trigger would that work i would like to end up using the prop1 to control the vmusic player only.

JonnyMac

Let's be clear; my code works just fine -- why you can't make it work when I do every time I connect it is the mystery....  ;D

If you have working code, go with it; there are conditions that Terry's code has problems with but you probably won't encounter them.  So, if you have the audio player working, use the P6 trigger code loop I put into every program to start it.  You are really making this much harder than it is.  Trust me, this stuff is easy and you can do it.
Jon McPhalen
EFX-TEK Hollywood Office