Car MP3 Player -- Updates

[ Main Musicbox Page ]

ToDo:

  • Get a serial LCD screen (instead of parallel like the current one) that I can use as a real tty (instead of being output-only with a user-space app writing to it, like the current one).  Parallel requires a custom cable and a custom program to talk to it, but a 4x40 screen is cheap ($35).  Serial uses a standard cable and a standardized protocol etc, but a 4x40 screen is about $135.

  • Install unison so the musicbox can sync with a Windows computer, the way it currently uses rsync to sync with a linux computer.  (Not that I'd ever use Windows, but some people apparently do.)

Updates

(Newest updates are at the top)




March 27, 2004
The musicbox now detects when the car is turned off, and saves its state to disk and shuts down nicely, automatically.  I have a small RC timer circuit that keeps the computer powered for about 11 seconds after the car shuts off.  With this, the system is now completely automatic in the same ways that a normal car stereo is.  The only time you have to touch it is to select the music.

October 19, 2003
Musicbox now has a tiny wireless USB network card, the Netgear MA111.  This thing is about 3x1x0.375 inches -- really small.  Using it, my musicbox now detects wireless networks as I drive around.  In the ~2 miles between my house and my campus, there are >70 networks, and most of them are unencrypted, meaning any old person can log right on to them and get on the internet (assuming that the network is connected to the internet).  I haven't figured out how to do that yet; it logs on to mine OK, but for some reason won't log on to any others.

Sunday September 9th, 2003
The new Via EPIA ME6000 motherboard that I got has built-in temperature sensors, so I installed the i2c and lmsensors packages, and they installed without a hitch (which is highly unusual on a linux system).  So I now have a CPU temperature display on the musicbox.  Awesome.

Also, two other things occurred to me that are really obvious, and I don't know why I didn't think of them before.  The LCD screen has some registers that need to be initialized with certain values and it needs to be done with a certain timing.  But that only needs to be done one time; those values hold until you turn the power off.  So I edited the lcdwriter program so that it only does that initialization when you tell it to, and otherwise it just opens the port between the PC and the LCD on each call.  So it now runs a lot quicker.  The second thing is that I now run the lcdwriter program from the ramdisk, instead of the hard disk.  This also makes it run much, much faster.  The result is that when you're scrolling through text on the screen, it keeps up with your kepresses very closely.

Some other random things.... there was a bug that caused the song's elapsed time to not display sometimes; that is now fixed.




August, 2003
The musicbox got a hardware upgrade (in performance) / downgrade (in size).  It's tiny now.  It's a new motherboard with integrated audio/video/LAN/USB2/Firewire, a built-in Via Eden 600MHz fanless CPU, a new custom-built 7x7x2" case, and a new stick of (DDR) RAM.  The only software change that was necessary was to use a different audio driver.

There is a company called mini-box that makes a tiny 70-watt ATX power supply for this tiny new motherboard that I got.  It's a single PCB that plugs into and sits on top of the motherboard -- no ATX cable, just an ATX connector.  And this power supply runs off a 12V source, so I can power it in the car directly; I don't need to use the DC->AC inverter anymore.

I also solved the reboot-at-ignition problem, by putting a small sealed-lead-acid (SLA) battery (from a $60 APC UPS system) in parallel with the car's battery, and putting a diode on the positive line between the two batteries.  Now when the engine is turning over and depleting the car battery's voltage down to about 9 volts, the smaller SLA battery holds the computer's input voltage at 12V, because the diode prevents current from flowing back to the car battery.




July, 2003
The musicbox now copies each mp3 into a ramdisk before playing it.  Now the audio never ever skips (it did before, once in a while, when I'd hit a big bump, or sometimes just seemingly randomly).

Also added fade-in and fade-out for whenever you pause/unpause/stop the music.




Wednesday July 9th, 2003
The batteries died today in the Gyration wireless keyboard that I use for the musicbox.  So they lasted almost exactly 3 months.  Which isn't amazing, but it isn't too bad either.  But my home keyboard is a Logitech wireless one, and it's 2 AA batteries last about a year... however, its range is only about 6 feet, compared to the Gyration's 25 feet.  Also, the Gyration uses 4 AAAs instead of 2 AAs... that might have something to do with it, but I don't know what.  Finally, the batteries that died were the generic ones that came with the keyboard; I replaced them with Energizers, so we'll see if they last any longer.




Thursday July 3rd, 2003
The musicbox has been in my car for 3 months now, and it's been amazing.  I've been doing lots of updates to the software, but haven't been posting news about them here; I've just been uploading the new software to the mp3script directory.  You can see them by going there and scrolling to the bottom, and looking at the newest ones... whenever I update it, I put a little explanation into the filename itself.  So reading that directory will tell you pretty much.




Tuesday April 15, 2003
Installed a relay so that the computer turns on automatically whenever the car turns on.  I also installed a capapacitor, in the hopes that it would keep the voltage close enough to 12V during ignition so that the computer could stay on without rebooting if you stopped and restarted the engine... but it didn't.  The voltage just drops too much for too long during ignition.  Oh well.  It's not a big deal at all, because you never really turn the engine off but leave the key in the accessory position, and then turn the car back on again.  It'd just be sort of nice.




Sunday April 6, 2003
Musicbox, Golfy.  Golfy, Musicbox.  That's right, I installed the musicbox in my car on Friday!  It's incredibly fun and neat.  I took lots of new photos so check them out!

It's running just fine on the power inverter, though that inverter is drawing too much current because one of my car stereo amps is cutting out occasionally.  [Update: apparently, the amp was cutting out because of a loose power cable, that just coincidentally occurred the first time I put the musicbox into my car.]  I'll have to get one of those overpriced giant capacitors called "Lightning Caps" and/or build that DC->DC power supply and see if that fixes it.  Either way, I'm waiting for a relay to come in the mail, so that the PC can automatically turn on and off with the car's ignition.  (Right now I have the power cord for the inverter running from the hatch to the front, and I plug it in to the standard roundy 12V car power outlet whenever I start the car.)  I'm also running the audio signal directly into my amps, but I'm going to make a cable (to mimic this one) that will send that signal into my Kenwood head unit's CD changer input, so that I can use the head unit's volume, bass and treble controls.

I can't get over how cool it is that with a single keypress, the box plays a random album from among the hundreds on the hard drive.  And if I don't feel like listening to that album, you know what I do?  Just hit the key again.  It's so darn handy.  And to never have to mess with CDs in the car again, that will be nice.




Sunday March 30, 2003
Finally got back to this project after not touching it for months.  I ordered a bunch of power-supply-type chips (actually, got them as free engineering samples   : ) from onsemi.com, and I'm also testing a $50 Rayovac 350watt power inverter.  As disgustingly inefficient as it is, I was thinking about it... I have a new car, a Volkswagen no less, so it might run OK with the power inverter.  If not, I'll build the DC->DC supply.

Also realized that rather than looking for an old motherboard that's new enough to support a large hard drive, I can just use "disk manager" / "drive overlay" software on the drive.  Makes my life 10x easier.  So I'm now rocking with 40 gigs on my old 233mmx system.

Over Christmas break I picked up a Gyration wireless keyboard (and mouse, stupid mouse, they don't sell the keyboard separately).  This thing is tiny, flat, black, wireless (radio), USB, and just generally freaking slick.  I also picked up an FM transmitter, the kind people apparently use to run their discmen through the car's FM radio... except this thing is a piece of junk, this iRock thing... it's all crackley.  So that means I need to run a signal wire from my hatch up to my head unit, or else run the soundcard right into my amps in my hatch.  I want it to go through the head unit because I want to be able to use the volume control there.  So... we'll see.

Software changes: there's now a full playlist editor.  And I added a "primitive" shell prompt pass-through, which lets you type any command you want, and it shows the output on the LCD screen.  I say "primitive" though because 1) if the program doesn't write its output on STDOUT (some use STDERR) then you don't see it, and 2) nothing interactive like text editors will work.  But it's still freaking cool that I have a shell prompt on my LCD screen   : )




Tuesday November 19, 2002
Figured out how to make the system boot directly to a bash prompt, from which I then mount the hard drives, start the sound card, and start the music script... without going through any of the normal system startup stuff (/etc/inittab and the /etc/rc.d scripts).  This is monumental for my music box.  Now he's doing absolutely nothing that he doesn't need to do... he just boots and plays music.  Startup time, from power-on to music-playing, is 36 seconds:

15 seconds of POST (ugh, need a new mobo)
8 seconds for my PCI IDE controller to probe for drives (once I get a mobo that can support my 40gig drive, this PCI card is getting removed, so this 8 seconds goes away)
13 seconds for Linux to load and start playing music

I'm pretty happy with this startup time.  36 - 8 = 28 seconds.  My car stereo currently takes about 8 seconds to start playing music (the faceplate needs to flip over and the amps' poweron-mute needs to unmute), so my music box will take 20 seconds longer.  Which will be a pain for sure, but it's not too bad really.

So this guy is almost ready for production.  He boots quickly and he plays music automatically, and he's got almost all the controls he needs for music selection and playing.  He just needs a slightly improved playlist editor, and a car power supply.




Monday November 18, 2002
Got the pause control to work!  This was tricky since I'm running the mp3 program in a forked detached process.  But by relying on some calculations I made on mp3 framerates, I was able to stop the song, then re-start it at the same frame based on the elapsed time when stopped.  It's so cool.  You can also seek forward and reverse in the song while it plays.

And in other giant news, I finally figured out how to use IPC (inter-process communication) to control the queueing of the next song.  I had been simply polling the child process (the mp3 player) once per second to see when it exited, and then starting the next song when it did.  But that's awful.  The IPC way is to have the child send the parent a signal when it exits, and have the parent run a signal-handling routine that starts the next song when it receives the signal.  So not only is this a million times more proper and clean, it also means that you're not utilizing the CPU like crazy, so you can scroll through your music library at normal speed even while a song is playing.




Thursday November 14, 2002
Got the music box converted from RedHat Linux to Slackware Linux.  This should make configuration much easier, and Slackware is smaller.  Also, a week or two ago, I installed the new (old) motherboard, so the music box is now an Intel Celeron 333 MHz in an old Socket 370 AT motherboard.

Also got it to automatically log in and start playing music when you turn the system on.  That's important.




Friday October 18, 2002
Implemented volume control. Added a reboot option. Made the key bindings code more logical, and made them easily customizable by the user. Oh, and the "Now Playing" screen now shows the elapsed time for the song.

I hooked up my spare 13.8VDC power supply to provide the -VLC contrast voltage, because the AAA battery (that I had been using) died, and I didn't feel like soldering another one up. So I have a 470 ohm resistor in series with a 2.42 kohm resistor across the terminals of the power supply, I have the middle of those 2 resistors connected to circuit ground, and I have VLC connected to the negative terminal of the power supply. This puts VLC at -0.74V (under load, drawing 3.94mA from the 13.8VDC) when the LCD backlight is on, and -0.59V (under load, drawing 4.33mA from the 13.8VDC) when the LCD backlight is off.




Sunday October 13, 2002
Lots more changes and improvements over the past couple days.  I have a huge MIPS programming assignment for school, and when I get sick of that, I take a little break and do some Perl programming on my mp3 script.  Ahhh Perl, so friendly, so powerful, so... perfect.  Anyway, about those updates...

I increased the script's speed and the screen's scrolling a lot by reducing the number of calls to the lcdwriter program about fourfold.  Previously I called the lcdwriter program once per line written to the LCD, but I rewrote the program to accept 4 lines at once, and that's how I send the data now.  So scrolling is almost realtime.

I added an overlay that shows CPU idle percentage and free memory.  This is enabled by passing a 1 (that's one) to the script when you run it.  Right now I have 2 idle percentages shown, from 2 different methods of calculating it... the first method is more accurate (i.e., agrees more with the top command) when a song is playing, but the second is more accurate otherwise.  (See my linux page for info about how these are calculated.)  So I'll probably just add some code to choose the method based on whether a song is playing.  But I want to monitor those values for a while yet.

The script now saves your playlist to disk, so when you shutdown/startup you don't lose it.  This will require a second little partition once I put this computer into my car, because I'll be running the mp3 disk in read-only mode so that I can turn the car off without "shutting down" the PC.

The script now remembers your position as you scroll through your music folder.  Since I have about 140 bands (folders) in there, this feature is a necessity.  When you enter a subfolder, select songs, do whatever, and then go back out to the root music folder, it starts you where you left off, instead of at the "A" folders.

I hooked up a 5k potentiometer between the LCD's VLC pin and the -1.5V source, and found out that the contrast is best at around -1.27V (it drops to -0.87V when the screen's VLC is connected).  The resistance is 93.5 ohms, which I now achieve with 3 resistors in series: 51, 33, and 10 ohms.

So I hooked that same pot up between +5V and the LCD's backlight anode, and it adjusts the brightness quite nicely.  The brightness adjustment is somewhat discrete (i.e. doesn't go smoothly from bright to off, but rather "jumps" from one brightness to the next), but that's probably because of my potentiometer.  It's the 3/4 turn type, so you don't have very fine control.  I'll have to find a 10-turn pot and give it a try.  Also, when the pot is turned all the way down (ideal resistance = 0), the screen's not fully bright, so there is some resistance there, or it's not passing enough current, or something.  Again, maybe a better pot will help.




Thursday October 10, 2002
Big changes to the control script.  I'm now using mpg123 instead of XMMS as the mp3 player, because it's a command-line/console application, whereas XMMS is an X-Windows application.  Of course I didn't want to have a graphical interface running and hogging resources on a system in my car with no monitor!  So this was only a matter of time/effort and finding the right player.  mpg123 works well, as long as you're using the latest development version (0.59s-mh4, Oct 27 2000) instead of the latest "stable" version (0.59r), which makes horrible crackley noises when it plays music.

The LCD now displays the info (name, band, whatever I want) about the currently playing song, and also lets you edit the playlist while music is playing.  Editing the playlist during playback is slow, though, because I haven't yet figured out how to pass signals from the child process (which calls mpg123) to the parent process (the control script).  Instead, I poll the child every second to see whether it's still alive (i.e., whether to advance to the next song), so there's about a 1 second lag on the keyboard input during playback.  This also means there's ~1 second of artificial silence between tracks, so on CDs where one tracks fades into the next with no pause, this is annoying.  Not too annoying though, and I don't feel very bad about it since almost every mp3 player in existence has this problem   : )

The script and/or mpg123 is leaking memory a bunch.  In 12 hours, the system went from ~120MB free down to ~50MB free.  Yeah... that's bad.  And bootup time, from poweron to login, is ~55 seconds... way too long.  But that's without any optimizations, and without disabling any of the programs I won't need in the car (like, 98% of them).  So it will be easy to bring that number down.




Tuesday October 8, 2002
I realized today that I'll want to build a custom power supply for the unit, so that I don't need to use an inverter in the car, which would be wasteful because I'd be converting DC-AC-DC.  But the supply that I'll build can't power ATX (switching) motherboards, and the sv25 is such a board.  So I ordered an older AT motherboard (Atrend ATC7110, 440LX chipset) for $17 from piranhatech.com and an Intel Celeron 333MHz processor for $22 from liquidationetc.com.  This means I'll need to use the case from my 233mmx server, or else buy a cheap one somewhere, or of course build one...