VMusic2 USB module - anyone used it?

nbw

Senior Member
whoops (previous message)

I've just bought a Vmusic2 USB module... I'm looking for someone who's managed to use it with a PICAXE. The datasheets provided are pretty intensive. Does anyone out there have experience with this little beastie?

thanks for any help :)
 

piclt

Member
Yes. I recently purchased the wee beastie.
See earlier postings titles "Vinculum VDIP1 on PICAXE 18X" 04/05/2007 also earlier posting 25/04/2007 on VMUSIC2 and picaxe 28X1. Works OK playing songs etc. controlled by serial link to picaxe
 

Technical

Technical Support
Staff member
Cut'n'paste from previous topic...

We've had a few requests about sample code for these modules. This code is written for the 28X1 (recommended), but could be modified for other parts:

<code><pre><font size=2 face='Courier'>
; Interfacing a VMUSIC2 module to PICAXE-28X1
; Also shows how to create a log file (this also suits VDRIVE2)

; Hardware Setup

; VMUSIC2 PICAXE-28X1
; 1 Black GND - 0V
; 2 Brown RTS - CTS input4 C4 (not used)
; 3 Red V+ - V+
; 4 Orange RXD - HTXD input6 C6
; 5 Yellow TXD - HRXD input7 C7
; 6 Green CTS - RTS output0 B0 (not essential, can tie to 0V)
; 7
; 8 Blue RI - not connected
; Note RXD on VMUSIC2 connects to TXD on PICAXE etc.


; Tested with a Sandisk 1GB Micro Cruzer with MP3 files called
; &quot;1.mp3&quot;, &quot;2.mp3&quot;,&quot;3.mp3&quot; in the root folder
; Sound was output using normal computer style speakers.

; IMPORTANT NOTE: Upon powerup it can take over a minute for the
; VMUSIC2 to enumerate the 1GB memory stick. During this time it looks
; like nothing at all is happening. This had us confused for many hours,
; thinking that the module was not working!
; After powerup have a cup of coffee and wait for the LED on VMUSIC2
; to go green. The drive LED should also be on - if not try reinserting.

symbol first_byte = b0
symbol point = b1
symbol temp = b2
symbol loopcounter = b3

; set picaxe type
#picaxe 28x1

; set COM port used for download
;#com 4

; open terminal after download
; This is to view the 'sertxd' debugging comments
#terminal 4800

setup:
; setup serial hardware
; at 9600 with background receive
hsersetup b9600_4,%01
low 0 ; ensure CTS is low

init:
; Send Es until the unit responds correctly
sertxd (&quot;&lt;Sent&gt; E&quot;,CR,LF)
hserout 0,(&quot;E&quot;,CR)
gosub get_response
if first_byte &lt;&gt; &quot;E&quot; then init

main:
; check to see if a drive is actually inserted
; response will start D for yes and N for no
sertxd (&quot;&lt;Sent&gt; Check Drive&quot;,CR,LF)
hserout 0,(CR)
gosub get_response
if first_byte &lt;&gt; &quot;D&quot; then main

; play track 1.mp3
; response will start D if ok, C if not
sertxd (&quot;&lt;Sent&gt; Play track 1&quot;,CR,LF)
hserout 0,(&quot;vpf 1.mp3&quot;,CR)
gosub get_response
if first_byte &lt;&gt; &quot;D&quot; then main

;now playing a track
playing:
sertxd (&quot;Playing 10 seconds of track 1&quot;,CR,LF)
pause 10000

sertxd (&quot;...pausing for 5 seconds...&quot;,CR,LF)
sertxd (&quot;&lt;Sent&gt; e&quot;,CR,LF)
hserout 0,(&quot;e&quot;) ; note no CR here
pause 5000

sertxd (&quot;...playing another 10 seconds of track&quot;,CR,LF)
sertxd (&quot;&lt;Sent&gt; CR&quot;,CR,LF)
hserout 0,(CR)
gosub get_response
pause 10000

sertxd (&quot;&lt;Sent&gt; Stopping track&quot;,CR,LF)
hserout 0,(&quot;vst&quot;,CR)
gosub get_response

; create a log file called 'log' (for some reason 'log.txt' didn't work)
sertxd (&quot;&lt;Sent&gt; Open file&quot;,CR,LF)
hserout 0,(&quot;opw log&quot;,CR)
gosub get_response

sertxd (&quot;&lt;Sent&gt; write to file&quot;,CR,LF)
bintoascii loopcounter,b5,b6,b7 ; convert loopcounter byte to 3 ascii digits
; and write 8 bytes loop_xyz
hserout 0,(&quot;wrf &quot;,$00,$00,$00,$08,CR,&quot;loop_&quot;,b5,b6,b7,CR)
gosub get_response

sertxd (&quot;&lt;Sent&gt; Close file&quot;,CR,LF)
hserout 0,(&quot;clf log&quot;,CR)
gosub get_response

inc loopcounter ; increment counter

goto main


; Sub procedure to receive background bytes
get_response:
pause 1000 ; wait a while
sertxd (&quot;&lt;Response&gt; &quot;)

point = 0 ; reset local pointer

get point,first_byte ; Save the first reply byte

do
get point,temp ; get returned byte
sertxd (temp) ; transmit it
inc point ; increment pointer
loop while temp &lt;&gt; CR ; if not CR loop

sertxd (LF) ; Add a LF to the received CR
sertxd (CR,LF) ; Do another blank line

hserptr = 0 ; reset the background receive pointer
return


; Other Useful Commands

; Play all tracks hserout 0,(&quot;w3a&quot;,CR)
; Stop track hserout 0,(&quot;vst&quot;,CR)
; Skip to Next Track hserout 0,(&quot;vsf&quot;,CR)
; Skip to Start of current Track hserout 0,(&quot;vsb&quot;,CR)
; Skip to Previous Track hserout 0,(&quot;vsb&quot;,CR,&quot;vsb&quot;,CR)
; Pause hserout 0,(&quot;e&quot;) ; note no CR here
; Resume (after pause) hserout 0,(CR)
; Set Volume hserout 0,(&quot;vwr&quot;,$0B,vol_right,vol_left,CR)
; where $00 = maximum volume,$FE is the minimum

; Suspend disk hserout 0,(&quot;sud&quot;,CR)
; Wakeup disk hserout 0,(&quot;wkd&quot;,CR)
; Get firmware version hserout 0,(&quot;fwv&quot;,CR)
</font></pre></code>
 

nbw

Senior Member
thanks! I'll give that a go. Thumbs up too for the quick response etc - much appreciated :)
 

adumas

Member
Hi... I'm trying to find anything on vmusic2 with a picaxe18x but the search is always coming up empty...

Has someone posted code for the interface?

I just got the module and am anxious to get it to work...
 

nbw

Senior Member
well,I got my VMUSIC2 module finally! Wired it up. The diagram in SCHip magazine p42 didn't seem to make complete sense. I thought the HTXD at the picaxe end would be sending data TO the VMUSIC2, so it should be on an Out pin rather than an IN. So, I wired it to pin 28 of the 28x1, OUT7. Green and black wires of the VMUSIC are to 0V, blue and brown floating. Yellow isn't being used (not getting anything back from VMUSIC2) so it's floating also.

I used the code below - pretty much the code posted in the mag with 2 exceptions - 1, I've got the hserouts going on pin out7, 2, I've added serouts to an LCD display so I can see what's going on.

Here's my code:

#picaxe 28x1

symbol first_byte = b0
symbol point = b1
symbol temp = b2
symbol loopcounter = b3

setup:
gosub clear_lcd
serout 0,n2400,(254,128)
serout 0,N2400,(&quot;starting init&quot;)
pause 1000

hsersetup b9600_4,%01

init:
hserout 7,(&quot;E&quot;,CR)
gosub get_response
if first_byte &lt;&gt; &quot;E&quot; then init


gosub clear_lcd
serout 0,n2400,(254,128)
serout 0,N2400,(&quot;done&quot;)
pause 1000

gosub clear_lcd
serout 0,n2400,(254,128)
serout 0,N2400,(&quot;starting main&quot;)
pause 1000


main:

hserout 7,(CR)
gosub get_response
if first_byte &lt;&gt; &quot;D&quot; then main


gosub clear_lcd
serout 0,n2400,(254,128)
serout 0,N2400,(&quot;playing!&quot;)
pause 1000
hserout 7,(&quot;vpf 1.mp3&quot;,CR)
pause 20000

hserout 7,(&quot;vst&quot;,CR)
gosub clear_lcd
serout 0,n2400,(254,128)
serout 0,N2400,(&quot;stopped&quot;)
pause 10000
goto main

get_response:
pause 1000
point = 0
get point,first_byte
do
get point, temp
sertxd (temp)
inc point
loop while temp &lt;&gt; CR

hserptr = 0
return


clear_lcd:
serout 0,n2400,(254,1) : pause 30
return ' line up cursor at pos 1, line 1


Basically what happens is the LCD shows 'starting init' and never goes further. I'm using a 128Mb USB drive with a single mp3 on it (called 1.mp3). The light on the USB drive is lit, and the VMUSIC led is green. I have a small pair of phones connected to the vmusic.

Any ideas? Please?!?!

I hope it (VMUSIC) doesn't need flashing - the forum posts I read seem to be complex and not entirely consistent.

thanks in adv for all advice and help.
 

nbw

Senior Member
Well, here's an update. I ignored my gut feeling and wired yellow wire to IN7, and orange to IN6. It worked. DOn't know why! I did change the serout commands for the LCD screen to out7; that worked. Puzzled why the code looks like its sending stuff out through outpin0... but there's nothing connected physically to it!
 

hippy

Technical Support
Staff member
No idea what the Silicon Chip article shows so cannot help you there.

I also do not know what each colour wire is for, but take care not to connect the output from VMUSIC2 directly to a PICAXE output because that could damage one or both. The use of &quot;TX&quot; and &quot;RX&quot; terminology can be confusing at times. Silicon Chip may have got it wrong, perhaps not. It is usually better to ask someone if they know before assuming something which makes for an expensive mistake.

If you haven't connected the transmitted data from the VMUSIC2 to the PICAXE it will hang as soon as it waits for a response from the VMUSIC2, which is what it does in the the &quot;init:&quot; routine. You'll either need to add the receive connection or rewrite the code so it doesn't wait for responses.

Re-flashing the VMUSIC2 isn't too difficult these days. You need to email for the right file, put it on the USB Drive and the re-flash will happen automatically when inserted.

The first thing you need to do is get the VMUSIC2 wired correctly. Download the datasheet, look at the pinout labelling and descriptions, then check your wiring against that.

Edited by - hippy on 14/08/2007 12:33:16
 

nbw

Senior Member
thanks for your notes hippy. I also saw a post you made (somewhere) about how one could say space instead of actually have lots of routines with '01.mp3', '02.mp3' etc, instead with a variable #w0 passed in to the VMUSIC 'play' command. I'll see if I can find that. Altho I'm using a 28x1 and there is a fair bit of space, I feel a bit dirty and cheap if I don't try and write as tight a prog as poss! cheers :)
 
Top