PDA

View Full Version : VINCULUM - Vmusic2 - Vdrive2 - Help



Allister
- 17th May 2010, 23:59
Newbie here and I hope I can get a quick answer as it appears there are a few on this forum the have experience with these Vinculum devices from my searches. But the searches although helpful in many respects they are failing to give me the helping hand I need for this problem.

OK first thing first I'm using the Vmusic2 with current firmware, no problems there I can play the music files and sorts just fine, so all is good on that front and the bread board and core code works. Figured that all out after much trial and error. And help from reading this forum and others. Thanks to those that contributed to this subject already.

But, I now want to add a configuration file to the drive to be read by the pic and this is tossing me for a loop, I'm not setup to debug so I'm at a disadvantage in seeing what and how the Vmusic2 is responding. So I'm hoping someone can toss me a bone with a short code snippet that will get me on the way.

Here is an example scenario, I know the scenario is not real practical but in my opinion it's a good proof of concept example that would get me (and maybe others) started and on the way to bigger and better even if it servers little functional purpose as is.

Scenario

1. There is a text file on the drive called volume.txt, it contains one line with a : separator between two values, the values will be a number between the 0 - 255 aka Vmusic2 happy volume levels.

Example txt file

10:225

2. I would like to simply read that text file and put the two values into variables in the code so they could be used.

Seems simple but not for me

I have attached some pseudo code of where I'm heading, if an array is easier that will work as well, at this point I'll just be happy to get the values off the flash drive and into variables in code.


vol var byte 'first value
vol2 var byte 'second value

main:

serout PORTB.7, T9600, ["OPW volume.txt", 13] 'open file
serout PORTB.7, T9600, ["RD volume.txt", 13] 'read file
gosub rdfile 'jump to subroutine to gather read inforation
serout PORTB.7, T9600, ["CLF volume.txt", 13] 'close file

'''''''''''''''''''''''''''''''''''''''''''''
'rest of program that would use vol and vol2 variables'
'''''''''''''''''''''''''''''''''''''''''''''
end

rdfile:
serin PORTB.6, T9600, 'totaly lost at this point
'
'
' at a complete lose
'
'
return

mackrackit
- 18th May 2010, 00:28
Welcome to the forum.

Give this a try in the totally lost area.


SERIN2 PORTB.6,84,[DEC vol,WAIT(":"),DEC vol2]

Allister
- 18th May 2010, 01:12
Hmm added the serin2 line and the code seems to hang on the jump and never return back to main, I wonder if there is something wrong with the open,read and close file commands I issued that is causing it not to spit up the data? Thus the serin2 can wait all day and never get anything.

mackrackit
- 18th May 2010, 01:21
These VDIP things can be a pain in the butt...

Try reading the data into an array without any WAITs and see exactly what is being sent by the VDIP.

Allister
- 18th May 2010, 02:49
I'm leaning towards this line being wrong.

serout PORTB.7, T9600, ["RD volume.txt", 13] 'read file

The more I read it might be RDF instead of RD and I need to specify the number of bytes to read in there somewhere, I guess.

And typo in the open command.


serout portb.7, T9600, ["OPR volume.txt", 13]
serout portb.7, T9600, ["RDF XXXXX, 13]
SERIN2 PORTB.6, 84,[DEC vol,WAIT(":"),DEC vol2]
serout portb.7, T9600, ["CLF volume.txt", 13]

At a lose what should be in XXXXX

The subroutine above is hanging.

mackrackit
- 18th May 2010, 03:09
serout PORTB.7, T9600, ["OPR volume.txt", 13] 'open file
serout PORTB.7, T9600, ["RD", 13] 'read file

Not sure if RDF will always work in your case because the amount of characters are not constant. But try the above...
I missed the W earlier and I think once the file is opened the name is not used until after it is closed and you need to open it again.

Allister
- 18th May 2010, 04:11
I just wrote a simple program that should test the reading of the file and give me audible alerts, since I'm not setup with any type of IDE or debug.

Here is the code so for those that are helping so we can be all on the same page. There are 4 files on the drive

volume.txt that contains simply

10:225
And three audio files named
vol10.mp3
vol225.mp3
vol3.mp3

In theory and hope,

b0 should play vol10.mp3
b1 should play vol225.mp3
b2 should play vol3.mp3



@ DEVICE pic16f88,HS_OSC,WDT_OFF,MCLR_OFF,LVP_OFF,PROTECT_O N,CPD_ON,DEBUG_OFF

Include "modedefs.bas"
Define OSC 8

CMCON = 7
ANSEL = 0

vol var byte
vol2 var byte
vol3 var byte

vol = 0
vol2 = 0
vol3 = 3

'in/out lines
OUTPUT PORTB.7 'send out
input PORTB.6 'recieve in

'Triggers
input PORTB.0 'trigger
input PORTB.1 'trigger
INPUT PORTB.2 'trigger

'PORTA.6 = OSC
'PORTA.7 = OSC

pause 5000 'wait for vmusic2 to read drive and stabilize
serout PORTB.7, T9600, ["vsv 00",13] 'set full volume
pause 1000 'give time for volume command to take effect

gosub rdfile 'get numbers from text file

main:

if PORTB.0 = 0 THEN
SEROUT PORTB.7, T9600, ["VPF vol",#vol,".mp3", 13]
pause 2000 'debounce
endif

if PORTB.1 = 0 Then
SEROUT PORTB.7, T9600, ["VPF vol",#vol2,".mp3", 13]
pause 2000 'debounce
endif

if PORTB.2 = 0 Then
SEROUT PORTB.7, T9600, ["VPF vol",#vol3,".mp3", 13]
pause 2000 'debounce
endif

goto main


rdfile: 'read variables in text file volume.txt
serout PORTB.7, T9600, ["OPR volume.txt", 13]
serout PORTB.7, T9600, ["RD", 13]
SERIN2 PORTB.6, 84, [DEC vol,wait(":"),DEC vol2]
serout PORTB.7, T9600, ["CLF volume.txt", 13]
return

end 'if it gets lost along the way ;)

Right now as written above it doesn't return from the subroutine jump (it's stuck reading the file somewhere) confirmed when the control button b2 fails to function, remove the jump/recompile and b2 functions as expected.

Remove the WAIT command with say


SERIN2 PORTB.6, 84, [DEC vol,DEC vol3,DEC vol2]
And it still doesn't appear to return

mackrackit
- 18th May 2010, 13:44
I do not have a VDIP on the bench to test any of this but looking at the data sheet and my old code yours should work. But I have not used the VMUSIC, so maybe there is some difference there?

One thing that might be causing trouble is not enough time from Opening the file and Reading it. You have read this?
http://www.picbasic.co.uk/forum/showthread.php?t=7700&p=47605#post47605
See how Brian has the VDIP connected with a Flow pin and the WAIT LABELS in the code.

Do you have the hardware to connect the output of the VDIP monitor to a PC terminal? You will need an inverter chip(MAX232 type).
Would be a big help to you to see what the VDIP is doing.

Allister
- 18th May 2010, 17:24
I have the hardware but not at my current location, thus my handicap.

As for timing I had thought of that and put delays in there but it didn't seem to help, but I might revisit that area. Until then I'll cross my fingers that someone else around these parts might be able to toss a lead as to why it's not working.

mackrackit
- 24th May 2010, 08:27
This has been bugging me enough to dig out a VDIP1 and take it along with me.

Here is what I got working. First off the "flash stick" was loaded with a file named VOLUME.TXT with 10:255 written in it so I think we are using the same file.

I do not have a VDIP Music module so this is working with a standard VDIP1. The attachment shows the firmware setting.
4431
Below is my complete code. The long pauses are just there to make sure the VDIP is initialized before sending any commands to it.
The LCD displays 10 for VAR VOL and 255 for VAR VOL2.
I hope this helps.


' 18F6680 VDIP
' 1384 BYTES
DEFINE OSC 20
@ __CONFIG _CONFIG1H, _OSC_HS_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L
DEFINE LCD_DREG PORTG
define LCD_DBIT 0
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 3000
DEFINE LCD_DATAUS 150

RXD VAR PORTE.2 'VDIP PIN 6 - DATA FROM VDIP
TXD VAR PORTE.3 'VDIP PIN 8 - DATA TO VDIP
FLOW VAR PORTE.4 'VDIP PIN 9 - VDIP RTS
VOL VAR BYTE
VOL2 VAR BYTE

PAUSE 5000
PAUSE 5000 'SAFE START UP TIME FOR VDIP
LCDOUT $FE,1,"MACKRCKIT"
lcdout $FE,$D0," U.S.A."

'INTIALIZE VDIP STICK
HIGH TXD
PAUSE 5
SEROUT2 TXD,84,["ECS",13]
HIGH TXD
PAUSEUS 10
SEROUT2 TXD,84,["IPA",13]
HIGH TXD
PAUSEUS 10
WAIT11:IF FLOW = 1 THEN WAIT11

START:PAUSE 5000
serout2 TXD, 84, ["OPR VOLUME.TXT", 13] 'open file
WAIT01:IF FLOW = 1 THEN WAIT01
serout2 TXD, 84, ["RD VOLUME.TXT", 13] 'read file
SERIN2 RXD, 84, [DEC VOL,DEC VOL2]
WAIT13:IF FLOW = 1 THEN WAIT13
serout2 TXD, 84, ["CLF VOLUME.TXT", 13] 'close file
GOSUB DISPLAY
GOTO START

DISPLAY:
LCDOUT $FE,1,"VOL ",DEC VOL
lcdout $FE,$C0,"VOL2 ",DEC VOL2
lcdout $FE,$D0," U.S.A."
PAUSE 250
RETURN

Allister
- 24th May 2010, 12:49
Dave thanks for continuing to look into this, I set it aside right now as it was frustrating me too much, but I will give you code a shot in the next few days and see what happens. I will re-breadboard it later this week and give your code a try.

The only settings that differ on my setup is that I wasn't using CTS/RTS flow detection, but just the same I'm getting responses from the Vmusic (like the "Stopped" to signify end of song) so i know that communication both ways is working.

Again thanks for the help, I'll let you know if it works.