May 03, 2024, 11:36:27 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.


SX & Vmusic

Started by Digital Steve, January 07, 2009, 12:50:37 PM

Previous topic - Next topic

Digital Steve

Hello Jon, I am trying out the vmusic2 player and I am trying to intergrate it into a parking meter to let the customer know what they have purchased. I have tried the code you have posted but have a run into a few problems, as I am new to the sx but I have done some pic programming, I have downloaded your Vmusic2_38k4_asc.sxb file. I have flashed the vmusic2 with 3,65 rom.  IS this correct so far. I need to add in 3 message buttons to play different messages. I can talk to the vmusic2 via hyper terminal. But the music doesnot play via the sx, is there a start to play button? I have read the sleepnotizer article in N&V and saw the start button in that code. Tried that code and things got worser.......Where should I start to look? Thanks for any help ..



Getting crossed eye in code
Steve

JonnyMac

Steve,

It might be easier for you to send me your files (audio) and describe who you want it all to work -- I'll whip up a demo that you can build on.  Coaching via forums will get tedious for both of us unless we're working on the same set of code.
Jon McPhalen
EFX-TEK Hollywood Office

Digital Steve

Hello Jon,
I am using the the following code,VMUSIC2_38K4_ASC.SXB from this forum.
FTRFB_9600.FTB and renamed and reflashed the Vmusic2 chip, this went ok as I can play mp3 files from hyper terminal.
What I want to do is play 4 messages from 4 I/P's . I have rename the mp3's to MESS1, MESS2, AND SO ON. I am using regular mp3 music files for a test. I don't think they will fit here so I can email them to you if you need them.


Thanks for your help :

steveh@digital-electricinc.com

JonnyMac

That's enough information for me to go on; things are a bit busy so give me a day or so to get a demo working for you.

Jon
Jon McPhalen
EFX-TEK Hollywood Office

Digital Steve

Thanks a Million, I am working thru your labs in the Pratical SXB guide.

Thanks again
Steve

JonnyMac

January 08, 2009, 01:52:13 PM #5 Last Edit: January 08, 2009, 04:55:20 PM by JonnyMac
For reasons that are confounding me at the moment, I can't get my own program to work either!  Actually, I did find one type but for reasons I've yet to discover the version that uses "background" serial is not behaving as it should.  So... I punted back to non-background serial and this works fine.  Note that my VMUSIC is set to 38.4K baud so you may need to change the Baud constant to "OT9600" for your module.

This is just a framework -- that works (I've run it) -- and should let you put your logic into it.  If you have more troubles post your version and I'll assist.  Right now I want to see why the other program isn't working and get it fixed.

' =========================================================================
'
'   File...... EZ_VMUSIC.SXB
'   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... 08 JAN 2009
'
' =========================================================================


' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------


' -------------------------------------------------------------------------
' Conditional Compilation Symbols
' -------------------------------------------------------------------------


' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------

ID              "VMUSIC"

DEVICE          SX28, OSCXT2, TURBO, STACKX, OPTIONX, BOR42
FREQ            50_000_000


' -------------------------------------------------------------------------
' I/O Pins
' -------------------------------------------------------------------------

RX              PIN     RC.7 INPUT              ' pull-up
TX              PIN     RC.6 INPUT              ' pull-up


' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------

Baud            CON     "OT38400"

CR              CON     13

Yes             CON     1
No              CON     0


' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------

flags           VAR     Byte
isPaused       VAR     flags.0


tmpB1           VAR     Byte                    ' work vars
tmpB2           VAR     Byte
tmpB3           VAR     Byte
tmpB4           VAR     Byte
tmpW1           VAR     Word
tmpW2           VAR     Word


' =========================================================================
' Subroutine / Function Declarations
' =========================================================================

DELAY_MS        SUB     1, 2

RX_BYTE         FUNC    1, 0
TX_BYTE         SUB     1
TX_STR          SUB     2
TX_HEX2         SUB     1                       ' transmit in HEX2 format

VM_PLAY         SUB     2                       ' play MP3 file
VM_REPEAT       SUB     2                       ' repeat MP3 file
VM_STOP         SUB     0
VM_PAUSE        SUB     0
VM_RESUME       SUB     0
VM_VOLUME       SUB     1                       ' overall volume
VM_PAN          SUB     2                       ' set left and right levels
VM_WAIT_PROMPT  SUB     0                       ' waits for ">" prompt
VM_WAIT_START   SUB     0                       ' wait for song start


' =========================================================================
  PROGRAM Start
' =========================================================================

Start:
  PLP_A = %0000                                 ' pull-up unused pins
  PLP_C = %1100_0000

  TX = 1                                        ' set to idle
  DELAY_MS 3_500                                ' let VMUSIC power up
  TX_BYTE CR                                    ' ping VMUSIC
  VM_WAIT_PROMPT
  VM_STOP                                       ' stop if playing
  VM_WAIT_PROMPT
  VM_VOLUME $00                                 ' reset to MAX
  VM_WAIT_PROMPT

  HIGH RB.0


Main:
  VM_PLAY "serenity"
  VM_WAIT_START
  HIGH RB.1

  VM_WAIT_PROMPT
  DO
    TOGGLE RB.1
    DELAY_MS 100
  LOOP
 


  END



' -------------------------------------------------------------------------
' Subroutine / Function Code
' -------------------------------------------------------------------------

' Use: DELAY_MS duration
' -- shell for PAUSE

SUB DELAY_MS
  mSecs         VAR     __WPARAM12

  \ SB  __PARAMCNT.1
  \ CLR mSecs_MSB
  PAUSE mSecs
  ENDSUB

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

' Use: aByte = RX_BYTE
' -- shell for SERIN

FUNC RX_BYTE
  SERIN RX, Baud, __PARAM1
  ENDFUNC

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

' Use: TX_BYTE aByte
' -- shell for SEROUT

SUB TX_BYTE
  SEROUT TX, Baud, __PARAM1
  ENDSUB

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

' Use: TX_STR [String | Label]
' -- pass embedded string or DATA label

SUB TX_STR
  tmpW1 = __WPARAM12

  DO
    READINC tmpW1, __PARAM1
    IF __PARAM1 = 0 THEN EXIT
    TX_BYTE __PARAM1
  LOOP
  ENDSUB

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

' Use: TX_HEX2 byteVal
' -- transmit byte in HEX2 format

SUB TX_HEX2
  tmpB1 = __PARAM1
 
  tmpB2 = tmpB1 & $F0                           ' isolate high nib
  SWAP tmpB2                                    ' move for READ
  READ Hex_Digits + tmpB2, tmpB2                ' convert to ASCII
  TX_BYTE tmpB2
  tmpB1 = tmpB1 & $0F                           ' isolate high nib
  READ Hex_Digits + tmpB1, tmpB1
  TX_BYTE tmpB1
  ENDSUB

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

' Use: VM_PLAY [String | Label]
' -- issues single play command to VMUSIC player
' -- name should be less than eight characters -- assumes MP3 extension

SUB VM_PLAY
  tmpW2 = __WPARAM12

  TX_STR  "VPF "
  TX_STR  tmpW2
  TX_STR  ".MP3"
  TX_BYTE CR
  isPaused = No                                 ' clear paused flag
  ENDSUB

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

' Use: VM_REPEAT [String | Label]
' -- issues repeat play command to VMUSIC player
' -- name should be less than eight characters -- assumes MP3 extension

SUB VM_REPEAT
  tmpW2 = __WPARAM12

  TX_STR  "VRF "
  TX_STR  tmpW2
  TX_STR  ".MP3"
  TX_BYTE CR
  isPaused = No                                 ' clear paused flag
  ENDSUB

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

' Use: VST
' -- stops playback of VMUSIC player

SUB VM_STOP
  TX_STR  "VST"
  TX_BYTE CR
  isPaused = No                                 ' clear paused flag
  ENDSUB

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

' Use: VM_PAUSE
' -- pauses VMUSIC player
' -- using VP allows paused file to be overridden

SUB VM_PAUSE
  IF isPaused = No THEN
    TX_STR  "VP"
    TX_BYTE CR
    isPaused = Yes                              ' toggle paused bit
  ENDIF
  ENDSUB

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

' Use: VM_RESUME
' -- resumes VMUSIC player

SUB VM_RESUME
  IF isPaused = Yes THEN
    TX_STR  "VP"
    TX_BYTE CR
    isPaused = No
  ENDIF
  ENDSUB

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

' Use: VM_VOLUME level
' -- sets overall volume of VMUSIC player

SUB VM_VOLUME
  tmpB3 = __PARAM1                              ' capture volume

  tmpB3 = tmpB3 MAX $FE
 
  TX_STR "VSV $"
  TX_HEX2 tmpB3
  TX_BYTE CR
  ENDSUB

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

' Use: VM_PAN left, right
' -- sets left and right channels independently

SUB VM_PAN
  tmpB3 = __PARAM1                              ' capture levels
  tmpB4 = __PARAM2

  tmpB3 = tmpB3 MAX $FE
  tmpB4 = tmpB4 MAX $FE

  TX_STR "VWR $0B"                              ' write to VS1003
  TX_HEX2 tmpB4                                 ' assuming little endian
  TX_HEX2 tmpB3
  TX_BYTE CR
  ENDSUB

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

' Use: VM_WAIT_PROMPT
' -- waits for caret character at end of command prompt

SUB VM_WAIT_PROMPT
  DO
    tmpB1 = RX_BYTE
  LOOP UNTIL tmpB1 = ">"
  ENDSUB

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

' Use: VM_WAIT_START
' -- waits for start of MP3 position data: "T $"

SUB VM_WAIT_START
  tmpB1 = RX_BYTE
  IF tmpB1 <> "T" THEN VM_WAIT_START
  tmpB1 = RX_BYTE
  IF tmpB1 <> " " THEN VM_WAIT_START
  tmpB1 = RX_BYTE
  IF tmpB1 <> "$" THEN VM_WAIT_START
  ENDSUB 


' =========================================================================
' User Data
' =========================================================================

Hex_Digits:
  DATA  "0123456789ABCDEF"
Jon McPhalen
EFX-TEK Hollywood Office

Digital Steve

Thanks Jon,
I will be playing later tonite. Weather should be crapy on Friday so I will have a snow day. Thanks agaain.....

Steve

JonnyMac

Sometimes it's the simple things that kick our butts.  I spent a lot of time trying to find that the problem in the original program yesterday (which wasn't easy as I'm feeling a bit under the weather) -- today, I found it: a silly typo.

The original program is working and re-posted in this thread: http://www.efx-tek.com/php/smf/index.php?topic=934.0
Jon McPhalen
EFX-TEK Hollywood Office

Digital Steve

Hello Jon,

Just testing, but want to check wiring of Vmusic2 module
Pin 1 & 6 to Grd
Pin 3 to +5
Pin 4 RXD to TX RC6
Pin 5 TXD to RX RC7

I am using SX Tech test board, do I need to plug in 50 MHz oscillator

Vmusic2 Baud parameters
38400 baud
8 Data Bits
1 Stop Bit
No Parity
Flow Control None



JonnyMac

We can't afford to do general SX support here (Parallax has a forum for that) -- if you're not running this program on a Prop-SX I'm going to lock the thread.

These are my connections for the Prop-SX:


Jon McPhalen
EFX-TEK Hollywood Office

Digital Steve

Hello Jon, Been OR for the last week(out of range), yes i am using your Prop-SX controller, quite a robust board. Getting into the program tonite. Will update you later.

thanks
Steve

JonnyMac

Okay -- the 4.7K pull-ups on my diagram above are the SETUP resistors on the Prop-SX pins 15 (RC.7) and 14 (RC.6) -- move these to the UP position and make sure that you have the ULN influence removed from these pins (clip ULN2803 pins 1 and 2).
Jon McPhalen
EFX-TEK Hollywood Office

Digital Steve

Jon, had the program talking back and forth last and this morning, then later today I was getting ready to add some input triggers and for some reason the vmusic2 module is not making it to to RB.0 High step, I get to TX _Byte CR line but it won't go pass this line. Nothing has changed in the code, it was working this morning, I left it powered up and went for lunch upon my return it was in limbo. I have another Vmusic2 unit tried it same thing??? it is flashed with firm wear 3.63. any ideas, I have ordered another vmusic2 module and hope to get on Weds...............

JonnyMac

Ghosts?...  I don't mean to be cheezy, but something changed.  As always, double-check you connections and make sure that a bug didn't sneak into your code.
Jon McPhalen
EFX-TEK Hollywood Office

Digital Steve

See posting---Vmusic2 player SX code, posted by robomaster-1 for more help.

Thanks for all your help.