Vinculum VDIP1 on PICAXE 18X

Technical

Technical Support
Staff member
Here is some untested code based upon our work with vdrive2

<code><pre><font size=2 face='Courier'>

; Hardware Setup

; VDIP PICAXE-18X
; GND - 0V
; RTS - CTS input4 (not used)
; V+ - V+
; RXD - TXD output7
; TXD - RXD input6
; CTS - RTS output0 (not essential, can tie to 0V)
; Note RXD on VMUSIC2 connects to TXD on PICAXE etc.

; Tested with a Sandisk 1GB Micro Cruzer
; IMPORTANT NOTE: Upon powerup it can take over a minute for the
; VDIP 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
; to go green. The drive LED should also be on - if not try reinserting.

symbol point = b0
'b1 reserved
symbol temp = b2
symbol loopcounter = b3

; set picaxe type
#picaxe 18x

; set COM port used for download
;#com 4

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


setup:
setfreq m8
'NB double speed, so t4800 is actually t9600

low 0 ; ensure CTS is low

init:
; Send Echos until the unit responds correctly
sertxd (&quot;&lt;Sent&gt; E&quot;,CR,LF)
serout 7,t4800,(&quot;E&quot;,CR)
serin 6,T4800,b1
pause 100
if b1 &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)
serout 7,t4800,(CR)
serin 6,T4800,b1
pause 100
if b1 &lt;&gt; &quot;D&quot; then main


logging:
; create a log file called 'log' (for some reason 'log.txt' didn't work)
sertxd (&quot;&lt;Sent&gt; Open file&quot;,CR,LF)
serout 7,t4800,(&quot;opw log&quot;,CR)
serin 6,T4800,b1
pause 100

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
serout 7,t4800,(&quot;wrf &quot;,$00,$00,$00,$08,CR,&quot;loop_&quot;,b5,b6,b7,CR)
serin 6,T4800,b1
pause 100

sertxd (&quot;&lt;Sent&gt; Close file&quot;,CR,LF)
serout 7,t4800,(&quot;clf log&quot;,CR)
serin 6,T4800,b1
pause 100

inc loopcounter ; increment counter

goto main
</font></pre></code>

Edited by - Technical on 26/04/2007 22:49:25
 

piclt

Member
I have got a VMUSIC2 and connected it up as you say but I am unable to talk to it.
When I switch on power I generally dont get any USB light. If I plug in a memory stick the light on the stick flashes a few seconds as it would if plugging it into a PC. I have waited upt to 20 minutes and no lights come on. Some times when I switch on power the USB light on the VMUSIC flashes red, but just keeps on doing that and never turns green. I am driving it with an Picaxe 18X and using the codes you describe but it does not respond. I have check output of the Picaxe serial and the codes are coming fro the Picaxe OK. There is no activity Txd from theVmusic and does not play music. Could you please tell me the sequence of events.
Should the VMUSIC light be Red when power is applied and Green when active and reading the memory stick.
 

piclt

Member
Got the Vmusic2 Module working.
CTS needs to strapped low. Then when power is applied &quot;Vmusic USB LED&quot; lights RED,then USB Drive light flashes and within a few seconds &quot;Vmusic USB LED&quot; goes Green. I then sent &quot;V3A&quot; and module played the MP3 file on the memory stick.
 

hippy

Ex-Staff (retired)
Thanks for letting everyone know. I'm afraid it seems you were left on your own to sort that out and almost certainly because no one here, including Technical, has a massive amount of experience with the VMUSIC2 or other Vinculum devices.

While Rev-Ed will almost certainly produce some examples of using those devices, user experiences, example code and projects and details of anything waiting to catch-out the unwary is always geatly appreciated.
 

Technical

Technical Support
Staff member
Read the example code above again!
We dod say CTS needs to be tied to a PICAXE output - or 0V!

; CTS - RTS output0 (not essential, can tie to 0V)
 

piclt

Member
Yes, I can see now what you mean. On first reading I assumed it meant if the comm port wasn't using hardware flow control then it wasnt essential to connect it. I found it to be &quot;essential&quot; to connect it to 0V. Also if you have the wrong serout signal (N4800 instead of T4800) the Vmusic will not bootup the Rxd line seems to need to sit Idle High for it to boot. I only testing it out on a breadboard so I keep connection to a minimum. I didnt need the E's to start it up and I had a 1GB memory stick and the light goes green in a few seconds. I am interested in how fast it can play short sounds or parts of files. I used the following test program.


SETFREQ M8

pause 1000

serout 2,T4800,(&quot;VPF bch.wav&quot;,CR)

playa:

pause 500

serout 2,T4800,(&quot;VST&quot;,CR)
serout 2,T4800,(&quot;VPF ach.wav&quot;,CR)

pause 500

playb:
serout 2,T4800,(&quot;VST&quot;,CR)
serout 2,T4800,(&quot;VPF bch.wav&quot;,CR)

goto playa

This was the fastest I could get it to play one sound then stop and play another. There would be approx delay of 250ms between each sound.( ie pause 500 at setfreq m8 ). The picaxe is fast enough, the delay is in the device. I see in the data sheet there is a &quot;SEK&quot; command to seek to an offset within the file. I wonder would this be faster access. I assume then you would have several sounds saved one after the other in a file and seek to different points to get the required sound. I use .wav files as they are easily edited to take out any quiet space at the start of the file etc.
Any ideas how to do this please or is there any faster chips ???. or talk to serial flash memory via the serial port if that would be faster ???

Thanks for your help, your previous postings were very helpful in getting me started.
 

Technical

Technical Support
Staff member
Are you sure the VST stop command is actually required, we simply started a new tune and it seemed to work.

The delay between songs will also depend on how big your memory stick is - use the smallest possible capacity for your sound lengths e.g. 128MB rather than 1GB.

It would be good practise to put a 'high 2' at the very start of your program. This would put the serout pin in the correct default high state before the first serial transaction. That is why we had echoes - because the very first byte sent after powerup could be 'seen' by the VMUSIC as corrupt because the serout pin was not high before it started.

Edited by - Technical on 30/04/2007 01:10:54
 

piclt

Member
Yes the stop seems to be required because I am not playing to the end of the sounds. In fact in most cases I only play a few milliseconds at the start of the file and then if another event happens in the picaxe then it sends a play command to play the start of another file for that event. If I dont use a stop I get a loud click as the playing is changed from one file to another midstream. It is OK if I play to the end of the file. I will try a smaller memory stick and see but a 128MB and a 1GB boots up initially in roughly the same time ???

Thanks for response
 

piclt

Member
I said I would try other Memory sticks.
I tried a Disgo 32 MB and a Dell 128 MB with the same 2 wav files. Both were slightly slower than the 1GB memory stick. The fastest the Dell and Disgo would play the sounds reliably without missing any was with a pause 600 in the program. The 1GB stick is a CnMemory MicroX 1GB stick............ The VMusic device is OK for playing longer sounds, quality is good and has the advantage that &quot;Real&quot; sound, voice, music tracks etc. can now be played easily under program control.
 

hippy

Ex-Staff (retired)
A question piclt, while you're experimenting and testing it out. How easy is it to fade down and fade up the volume of a playing track ?

I want to update my Ambient Music System to use a VMUSIC2 and rather than have sharp off's and on's it fades down before stopping and fades down and up when paused/unpaused. On the PC I currently use it fades the soundcard volume down over 2.5S and up over 1S but the times aren't really important.

A PICAXE + VMUSIC2 + USB Stick has to beat a noisy, power hungry PC any day, and most USB Sticks are bigger than the HDD it has these days.
 

piclt

Member
Hippy, I actually didnt try adjusting the volume, I was using headphones, I think is plays by default at full volume. From the Vmusic datasheet there is a command to write to a control register in the VS1003 codec &quot;VWR address(1byte) Value(2bytes) LSB first CR&quot;. Looking at the VS1003 datasheet there are 16 SCI control registers and Volume control is 0xB. It needs a value sent to it to change the volume. It is actually an attenuation value from full volume. ie 0x0000 is full volume to 0xFEFE for silence. There is a calculation on the datasheet (adjusts in 0.5 dB steps). I think this is the sort of thing we need to do, so to fade in or out a series of values would need to be sent to gradually increase or decrease the volume. I you just wanted a quick switch off, use the stop command, there will be a slight delay when you send play again. I will try it out later and post again......... cheers
 

Technical

Technical Support
Staff member
See our ealier VMUSIC post for other useful commands like volume... The default is indeed 0 (full volume)

<code><pre><font size=2 face='Courier'>
; 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>
 

piclt

Member
Technical had already some of the commands posted.

This is a wee test loop to fadein and fade out.

SETFREQ M8

high 2

pause 5000
serout 2,T4800,(&quot;vwr &quot;,$0B,$FE,$FE,CR)
serout 2,T4800,(&quot;VPF abc.mp3&quot;,CR)

fadein:

for w1 = 150 to 50 step -1

pause 200
serout 2,T4800,(&quot;vwr &quot;,$0B,w1,w1,CR)

next w1


fadeout:

for w1 = 50 to 150

pause 200
serout 2,T4800,(&quot;vwr &quot;,$0B,w1,w1,CR)

next w1


'stop then start again

'serout 2,T4800,(&quot;VST&quot;,CR)

pause 2000
serout 2,T4800,(&quot;VPF abc.mp3&quot;,CR)

pause 5000
goto fadein

............................
 
Top