[Staff] VMusic2 - USB on the old 83+ / MP3 playback

Here you can find side projects of the staff and great projects which we think should get extra support. (Note that featured projects are not projects by staff members of MaxCoderz)

Moderator: MaxCoderz Staff

Post Reply
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

[Staff] VMusic2 - USB on the old 83+ / MP3 playback

Post by benryves »

If you've been reading the thread on United TI, you'd know that I'd been persuading rcfreak0 to invest in the new PICAXE and a VMusic 2 module for a TI-83 Plus mod.

I have invested in them both myself (a shiny new PICAXE-28X1 and a VMusic2) and am really impressed with both. :) I'm working with both to give the old TI-83 Plus USB capabilities (and probably 83 too, though the front-end I'll write might need some work due to missing ROM calls).

Image

The VMusic 2 is a smallish, low-cost, compact unit. It's self contained, has a simple jumper switch on the back (to choose SPI or serial UART mode), row of pins (so you can connect the +5V, 0V, and serial I/O lines) and a right/left line out header. On the front is a headphone jack and a standard sized USB port. A red/green LED reports the status.

What, exactly, does it do? :) Well, it is based around the Vinculum VNC1L-1A USB host controller. This controller basically provides a simple level of abstraction on top of USB communications. On top of this it also offers the ability to transparently handle FAT mass storage devices, and this VMusic2 version can also play MP3 files.

You can control it over a standard serial link, and it's pretty much like using DOS. :)

Code: Select all

D:\>
No Upgrade
D:\>
DIR

TIEMEK~1.MP3
VMUSIC2.JPG
WHO DIR
D:\>
CD WHO
D:\>
DIR

. DIR
.. DIR
BORIS.MP3
WHORYOU.MP3
D:\>
CD ..
D:\>
DLD WHO
Dir Not Empty

D:\>
This is inserting a disk ("No Upgrade"), listing files and directories (directories have DIR after the name), changing directory and attempting to delete the WHO directory (which, being non-empty, doesn't let me - just like DOS, indeed!)

The device supports (rough list):
  • Directories - changing, creating, deleting, renaming.
  • Files - reading (all or in chunks), deleting, writing, renaming, seeking.
  • Disks - get free space, suspend (power).
  • Music - play single, play all in current directory and its subdirectories, stop, skip next, skip previous.
On top of this are debugging tools (dump disk information) and manual disk operations (sector dump/sector write). There are a number of commands I won't pretend to understand, mainly relating to lower-level USB communications.

This is all very well, but how can we use this on our beloved TI calcs?

Image

The PICAXE-28X1 gives us what we need. Hardware-based serial I/O can receive data in the background, where we can pick it up from the chip's 128-byte scratchpad RAM. Programmable I/O lines on port C can be used to directly hook to up a TI calculator's link port (we need to read and write to the pins; pins are designated as input OR output, but by setting DIRSC you can set the direction.

Best of all, all you need are five connections - +5V, 0V, reset (tied high), serial in and serial out; no PIC programmer required.

Code: Select all

; ================================================================= ;
; Texas Instruments Link Protocol routines.                         ;
; ================================================================= ;
{

; ----------------------------------------------------------------- ;
; TiLPIn - Input a byte via the Texas Instruments link protocol.    ;
; ----------------------------------------------------------------- ;
; Inputs:   None.                                                   ;
; Outputs:  B0 = Byte input.                                        ;
; Destroys: B1, B2.                                                 ;
; ----------------------------------------------------------------- ;
TiLPIn:
	; Shift in eight bits:
	For B1 = 0 To 7
	
		; Shift >>= 1
	    Let B0 = B0 / 2
	    
	    ; Wait for either pin to go low:
	    Let B2 = 10
	    Do
	    	If Pin0 = 0 Then TiLPInBit0
	    	If Pin1 = 0 Then TiLPInBit1
	    	Dec B2
	    	If B2 = 0 Then Return : EndIf
	    Loop
	    
	    ; Received a 0 bit:
	    TiLPInBit0:
	    	Low PortC 1	    	        ; Hold data 1 low.
	    	If Pin0 = 0 Then TiLPInBit0 ; Wait for data 0 to go high.
	    	Let DirsC = %00000000       ; Release data 1.
			Goto GetNextBit
		
		; Received a 1 bit:
	    TiLPInBit1:
	    	Low PortC 0                 ; Hold data 0 low.
	    	Let Bit7 = 1                ; Add the bit to B0.
	    	If Pin1 = 0 Then TiLPInBit1 ; Wait for data 1 to go high.
	    	Let DirsC = %00000000 	    ; Release data 0.
	    
	GetNextBit:
	Next B1
	Return

; ----------------------------------------------------------------- ;
; TiLPOut - Output a byte via the Texas Instruments link protocol.  ;
; ----------------------------------------------------------------- ;
; Inputs:   B0 = Byte to output.                                    ;
; Outputs:  None.                                                   ;
; Destroys: B1.                                                     ;
; ----------------------------------------------------------------- ;
TiLPOut:
	For B1 = 0 To 7
		If Bit0 = 0 Then
			Low PortC 0
			Do While Pin1 = 1 : Loop
			Let DirsC = %00000000
			Do While Pin1 = 0 : Loop
		Else			
			Low PortC 1
			Do While Pin0 = 1 : Loop
			Let DirsC = %00000000
			Do While Pin0 = 0 : Loop
		EndIf
	    Let B0 = B0 / 2
	Next B1
	Return
	
}
Some rough-and-ready routines for sending and receiving bytes are written in BASIC (yep, you program these microcontrollers in BASIC). Using the new hardware serial routines, you can turn the PICAXE into a crude greylink-alike:

Code: Select all

; ================================================================= ;
; Entry Point / Main Loop.                                          ;
; ================================================================= ;
{
Main:
	
	; Use 8MHz clock speed.
	SetFreq M8


	; Set up background serial receive.
	HSerSetup B9600_8, %01

	; RTS
	Low 0
	
	Do
		GoSub TiLPIn
		If B1 = 8 Then
			#IfDef Debug
				SerTxd("In", 9, B0, 9, #B0, CR, LF)
			#EndIf		
			HSerOut 0,(B0)
		EndIf		
		
		High 0
		
		Let B3 = 0
		Do While B3 != HSerPtr
		   Get B3, B0
			#IfDef Debug
				SerTxd("Out", 9, B0, 9, #B0, CR, LF)
			#EndIf
			GoSub TiLPOut
			Inc B3
		Loop
		
		HSerPtr = 0
		
		Low 0
		
	Loop
	
}
Data coming in from the TI are sent straight to the VMusic2 device; data coming from the VMusic2 are relayed to the TI. The SerTxd lines send serial data out using the serial connection used to program the PICAXE, so by running any terminal app on the PC at 9600 baud you can keep an eye on data flowing through the PICAXE.

Image

All in all, the above BASIC code (main loop and TiLP functions) comes to a mere 183 bytes. The PICAXE-28X1 has a whopping 4KB available, so we can pack a lot more functionality in if need be!

I've cobbled together a really rough program for the calculator.

Image
Click to download (+PICAXE program).


WARNING: Likely to crash your calc. Use at own risk. :) Very rushed development on this.

Keys are as follows:
  • Y= - Play All
  • Window Stop
  • Clear - Exit
  • Up/Down - Move up and down columns
  • Left/Right - Switch columns
  • 2nd - Select
  • Graph - Refresh list
For reliable operation, plug in the flash drive, wait for LED to turn green, then start program. Press F5 if filenames appear corrupted (known issue).

If you don't feel like building this project, a video of what you're missing out on follows:

Image
1.48MB AVI (MPEG-4, MP3)


No comments on my choice of music, thanks. :)

This program will only allow you to browse the first 32 directories/folders. This is by design (the directory listing buffer is savesScreen).

Some interesting problems to solve here; eg speed (it's very slow, currently, to browse directories as it downloads the entire directory listing first).

The only way I can see this working fast is an event-driven system. Creating a directory takes a long time, for example; might be better to send the command, then carry on letting the user browse the interface (but not send any more commands!) until the unit responds, at which point you could let them send commands again.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

Ben, this is completey crazy ... i go away for a day or two and you pull this outta no-where!

I dont want to think about what else you are schemeing on behind closed doors.

You're a damn genius :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

This is bloody awesome!

how did you get the idea to do this?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

I mentioned the UTI thread, but I guess I should have linked to it. :)

It's all rcfreak0's idea. I'm just trying to implement it using the PICAXE solution.

Edit: If this is the chip used for music decoding (which I believe it is) we have an impressive set of features! (MPEG 1 & 2 audio layer 3 (CBR, VBR), WMA 4.0/4.1/7/8/9 all profiles (5-384kbit/s), WAV (PCM + IMA ADPCM), General MIDI / SP-MIDI).
User avatar
Madskillz
Calc Wizard
Posts: 745
Joined: Fri 17 Dec, 2004 10:22 pm
Location: Wandering around in the Jungle...
Contact:

Post by Madskillz »

wow simply amazing...
The Revolution is here...
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

I wrote a simple link console program that is more VMusic-friendly (eg, using '\r' for newlines, having ~ and _ in easy to type places for filenames). There are some examples of communicating with the VDrive/VMusic2 device in the documentation, including how to create and write to a file on the USB drive.

The console program could be useful in other cases, of course, when you need a simple link console. :)

This is indeed the codec used by the VMusic2. It does support WMA, MP3, numerous "WAV" formats and MIDI type 0 (the synthesiser is decent). It also has bass/treble adjustment, and you can do interesting things by fiddling around with the registers (playing a 44kHz file at 11kHz, for example).

-----------------

EDIT: Cross post from UTI:
Ben, thanks for the pic. Im gonna try and order everything wensday or thursday. Could you tell me everything you ordered, so i know i have the right stuff? :)
  • VMusic2 (~£25)
  • PICAXE-28X1 (~£5)
  • Box of paper clips (35p)
I used the paper clips to construct this adapter to plug the VMusic2 into a breadboard. Be warned that the pin spacing is different! Also, be careful inserting fat wires (like paper clips) into a breadboard, as they can bend and break the contacts if forced.

If you do not have a PICAXE programming cable (serial->3.5mm stereo jack adapter) you will also need one of those and a programming board (the simple circuit with a 3.5mm stereo jack socket and a couple of resistors on page 27 of manual 1). I buy my resistors in multipacks, as they are very useful.

A 2.5mm stereo jack connection will need to be made with the calculator. Either cut up an old calc->calc link, or (if you can find one!) buy a 2.5mm stereo socket. They are difficult to find. 2.5mm stereo plugs are usually too large to fit into the recessed socket on the calculator!

A 5V voltage regulator might be useful (I power my circuit off a 9V power supply, so need it).

There should be the more obvious parts - wire, battery clips, stripboard if you feel you need it, &c. I'm not sure what tools and parts you have lying around, you see. :)
Another question, what kind of breadboard do you have? The one i have does not look like yours, its smaller, and looks different.
I have two. I normally use my Protobloc 2, but I also have a small Protobloc for smaller circuits. Either will do in this instance.

In both cases, they can be linked together to make larger circuits. :D
Last edited by benryves on Wed 23 May, 2007 1:51 pm, edited 1 time in total.
rcfreak0
New Member
Posts: 2
Joined: Tue 22 May, 2007 5:32 pm
Location: Juneau,WI

Post by rcfreak0 »

Thanks ben for the info, Ill be sure to order VERY soon. Thanks agian,

--rcfreak0
User avatar
KermMartian
Calc Wizard
Posts: 549
Joined: Tue 05 Jul, 2005 11:28 pm
Contact:

Post by KermMartian »

Ben, you insist on being insane.
Image Image Image
rcfreak0
New Member
Posts: 2
Joined: Tue 22 May, 2007 5:32 pm
Location: Juneau,WI

Post by rcfreak0 »

How is he insane? He's a freakin genius! :D Without him, i would have no code to work with! very brilliant if you ask me...:)

--rcfreak0
User avatar
Madskillz
Calc Wizard
Posts: 745
Joined: Fri 17 Dec, 2004 10:22 pm
Location: Wandering around in the Jungle...
Contact:

Post by Madskillz »

There is a very fine line between a genius and a madman...

And Ben always seems to amaze me.
The Revolution is here...
Post Reply