Welcome to the forum.
Give this a try in the totally lost area.
Code:SERIN2 PORTB.6,84,[DEC vol,WAIT(":"),DEC vol2]
Welcome to the forum.
Give this a try in the totally lost area.
Code:SERIN2 PORTB.6,84,[DEC vol,WAIT(":"),DEC vol2]
Dave
Always wear safety glasses while programming.
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.
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.
Dave
Always wear safety glasses while programming.
I'm leaning towards this line being wrong.
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.Code:serout PORTB.7, T9600, ["RD volume.txt", 13] 'read file
And typo in the open command.
At a lose what should be in XXXXXCode: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]
The subroutine above is hanging.
Last edited by Allister; - 18th May 2010 at 04:08.
Not sure if RDF will always work in your case because the amount of characters are not constant. But try the above...Code:serout PORTB.7, T9600, ["OPR volume.txt", 13] 'open file serout PORTB.7, T9600, ["RD", 13] 'read file
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.
Dave
Always wear safety glasses while programming.
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
And three audio files namedCode:10:225
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
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.Code:@ DEVICE pic16f88,HS_OSC,WDT_OFF,MCLR_OFF,LVP_OFF,PROTECT_ON,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 ;)
Remove the WAIT command with say
And it still doesn't appear to returnCode:SERIN2 PORTB.6, 84, [DEC vol,DEC vol3,DEC vol2]
Last edited by Allister; - 18th May 2010 at 05:20.
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/show...7605#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.
Dave
Always wear safety glasses while programming.
Bookmarks