Thursday, December 11, 2008

Archos V2 Jukebox Recorder input current measurement

I was just investigating the "external voltage" measurement on my Archos V2 Jukebox Recorder. I already knew it was actually current, and I was wondering if it is could be displayed at the charging screen. When charging via the charger input, it is an accurate measure of input current; just divide by 10 and you have the current in amps. When charging via USB, it still measures current, but the scale factor is different, with 7 V equalling 0.5 A.

Wednesday, December 10, 2008

Weird backlight control on the Archos V2/FM Jukebox Recorder

When turning off, the backlight on my Archos V2 Jukebox recorder sometimes turns off and sometimes brightens and then fades out. I investigated this a bit today. The backlight is controlled by the square wave output of the STMicroelectronics M41ST84W real time clock. Rockbox configures it for 32kHz and then enables and disables it as needed. Apparently disabling it means high impedance mode (high-z/3-state) instead of off. What happens to the backlight depends on the last state of the square wave output. If it was off, it stays off. If it was on, it stays on and slowly fades as the charge leaks away. This is brighter at first because it is steady on, not flashing at 32kHz as usual.

Setting the frequency bits to 0000 does the same thing, and changing them doesn't reset the counter. The only software workaround would be to shut off the backlight at the right moment, and it may be possible to wait for the right moment based on the 10ths of a second value, then decrease the frequency and shut off the square wave. If the place from which the charge slowly leaks away is accessible outside the chip (eg. if the output drives a external MOSFET), it would be possible to add a resistor. However, I'm not sure this is worth doing.

Edited on December 13th:
I found a simple workaround and submitted a patch. Apparently, the square wave output is controlled by its own counter which is independent of the clock, and the counter is reset when the output is disabled. So, the solution is to disable the square wave to reset the counter, re-enable it so the backlight is off, and then finally disable it so the backlight stays off. Setting the frequency to 1Hz before the re-enabling ensures the backlight won't turn on before the final disabling.

Sunday, December 07, 2008

Video iPod won't charge via USB, won't turn off from Rockbox

I've decided to document this problem because I've seen it several times on the Rockbox Forums.

This applies to Video iPods (5th or 5.5 generation). The symptoms are constant detection of USB power, inability to charge via USB, and inability to turn off from Rockbox.

USB power management and battery charging is done via an LTC4066 IC. The USB power part of the IC may fail so that USB power cannot be used and power is output via the IN pin (#9, 3rd from the left on the bottom). This causes the USB power input to stay at a few volts when nothing is connected, which makes other circuitry detect that USB power is present. This voltage can even be measured from the end of a USB iPod cable. This is an easy and non-invasive check which could be done first.

The iPod cannot stay off because false detection of USB power turns it on. The original firmware's "off" is actually sleep, so that still works. When Rockbox tries to turn off the iPod, it restarts.

There are several things which can be done about this:
  • Use the original firmware. Its off is sleep, and sleep is still possible.
  • Cut the trace leading to the IN pin of the LTC4066. This is what I did. The power output from the IN pin doesn't get to the USB power detection circuitry, so it's possible to turn off from Rockbox.
  • For power while connected via USB, use a USB+FireWire cable and a FireWire charger on the FireWire end. (For example, here are some cables at Amazon.)
Other possible solutions I've thought of are:
  • Replace the LTC4066. I thought this was too hard because there is a large solder tab under the chip for heat sinking and there are very tiny parts very close to the chip.
  • Cut the trace and connect a diode from the USB +5V input to OUT of the LTC4066 to restore USB charging ability. I wanted to do this but there wasn't enough space for the diode. I also had some concerns about voltage drop and the diode's heat dissipation.
  • Short the USB +5V input to ground when not using USB, eg. via a modified dock connector. It should be easy, but would waste power. I didn't try this.
  • Replace the motherboard.
  • A purely software workaround which allows Rockbox to shut down the iPod. In firmware/drivers/pcf50605.c, pcf50605_standby_mode() sets conditions which turn on the iPod. Removing the condition relating to USB charging, probably CHGWAK, would allow the iPod to stay off, though FireWire charging might not turn it on either. But be careful, because according to the comment, it is possible to turn off the iPod in a way that requires disconnecting the battery or waiting for it to discharge (a month or more I guess).
Here is a photo of the front an iPod motherboard with a blue circle around the LTC4066 and a red line showing which trace needs to be cut and suggesting a location for the cut. (Click on it to see the full-resolution version.) Note that the wheel has been swung away and that the wheel's ribbon cable passes right below the LTC4066.

Here is a closeup of the LTC4066 area. Remember that this is a small part of the iPod, and what you see here is actually very tiny.
(Both images are from another iPod which doesn't have this problem, which is okay because the LTC4066 doesn't have to look any different when it fails.)

What is this 6502-based device?

While I was a student at the University of Waterloo I used to go to the surplus sales. This is one of the more unusual things I picked up. It used to belong to the psychology department, and it still has stickers from psychology experiments. I suppose it was used to collect data in experiments.

It is from Observational Systems Inc. in Seattle, WA. Inside are several circuit boards. Here is the main board, with the 6502 processor, EPROM, RAM and I/O.

Here is the board with the keypad and LCD. Along the top are a lot of LCD driver ICs.

Finally, here is the rest of the device, with the backplane and a small daughterboard for the CPU board which contains some analog electronics.

The device seems to require 5V power. It does turn on, but it doesn't seem to function consistently so I think it is probably broken. Occasionally I'm tempted to take it apart and build a new 6502 based system from it. The CPU was used in many 8-bit home computers, including the Apple I, Apple II, Commodore PET and more, so there is plenty of information available on it.

Friday, December 05, 2008

Stripped down RomBox build of Rockbox for the Archos V2 Jukebox Recorder

Earlier I posted about how Rockbox increased in size and greatly reduced available buffer space on targets with 2 megs of memory. Well, here's my solution for the V2 Recorder. It's an older version, from November 2007, because that gives me more buffer space. To get more buffer space I've also removed language and codepage changing, the voice interface and radio support. The database has been removed to allow for RomBox. The build also has a fix for charging screen related bugs. I get 1.750 MB of buffer.

Once in a while, I make attempts to strip out more, with the eventual goal of having RomBox and the database. I'm not very devoted to this pursuit however, because I don't really need the database.

As for that older post, I sometimes think I should delete it. I really like Rockbox and I also don't want to upset others who like it, but I also don't feel like censoring myself.

WARNING: This build disables low battery shutdown. If the device is left on but not playing, it may be possible to overdischarge the battery. According to various sources, overdischarge damages lithium-ion batteries. Also, recovery from that state may require charging the battery externally or jump-starting the device. Under normal use, the device will shut down when the hard drive is used before the battery is overdischarged, and if not playing, idle shutoff will shut it down.

SDL AcidWarp for Windows and SDL full screen mode issues

AcidWarp is an eye-candy program by Noah Spurrier. It draws patterns based on mathematical functions and then animates them via colour cycling. It originally ran in MS-DOS, and used the VGA 320x200 256 colour mode. In 2000 I was developing a library to emulate palletized 256 colour mode in the X Window System, and I modified the Linux SVGALib port of AcidWarp to use that library. Now I just had to modify it again to use SDL instead.

I was partly right about it being trivial. Using SDL for display was trivial. Adding keyboard input was very easy. However, full screen mode was a problem. Much to my surprise, SDL defaults to the windib driver, not directx (windx5). This means it uses the obsolete WinG interface to draw images instead of (the DirectDraw component of an older version of) DirectX. Windows doesn't normally allow programs to alter the whole palette, and SDL uses SetSystemPaletteUse to try to get access to the whole palette. Windows 2000 and XP can allow access to the whole palette (if the uUsage parameter is set to SYSPAL_NOSTATIC256) but other versions of Windows at least retain two entries for black and white (if uUsage is set to SYSPAL_NOSTATIC, which I think is an inappropriate name). This leads to some colours being remapped at the upper end of the palette, with multiple colours mapping to single colours. When this happens, part of the AcidWarp display is degraded, and with some patterns it's very obvious. It's easy to get around this by setting SDL_VIDEODRIVER to directx, but then Windows Vista turns off Aero when the program goes fullscreen, and Aero stays off until the program exits. The way around this problem is to totally shut down SDL with SDL_Quit and reinitialize it when switching from full screen to windowed mode. Aero is still shut down when in full screen mode, but that is not a problem. Initially I used the windib driver for full screen mode and directx for windowed mode. Soon I realized I probably only had to do the shutdown when leaving windowed mode and I could always use the directx driver, but when I made these changes I found that full screen mode sometimes becomes extremely slow (about 1 FPS animation) with high CPU usage. It seems like the version which switched between windib and directx didn't have this problem, but I'm not certain.

If you're not using Windows, you can ignore all that and try to compile the code for your operating system. The Makefile may need tweaking, but the code should be portable. All of the Windows-specific hack described above is conditional on WIN32 being defined.

Finally, here's a link to a zip file with the source and binaries. Take note of this notice which appears on Noah's page on AcidWarp: I do not accept responsibility for damage to persons or property that comes from the use or installation of this software. Use this software at your own risk. This software is free. Also, note that what I'm offering here is a new port which hasn't been tested extensively. I also think that the colour cycling patterns displayed by AcidWarp may cause seizures in individuals who are vulnerable to that sort of thing, especially if the animation is sped up, so please be careful.

[ Edit: Updated to latest version with some fixes in the Vista full screen workaround and a .reg file which should finally allow 256 colour full screen mode in Windows 7. ]

Wednesday, December 03, 2008

Bolt, RealD and circular polarization

Yesterday I watched Bolt in RealD 3D. I wasn't really expecting much from Bolt and I mainly went because I wanted to try out 3D. Many years ago I watched IMAX 3D at the Pacific Science Center in Seattle and I was quite impressed. It was exciting to see 3D technology available in ordinary cinemas. Bolt exceeded my expectations, and 3D failed to live up to them, but neither were a disappointment.

The trailers for Bolt made me imagine a movie that's amusing but shallow. I expected a storyline without much detail, and stereotypically cartoonish fun. I found a storyline with enough depth and detail so that it didn't seem at all hollow. There was certainly some stereotypically cartoonish fun, but there was far more to the movie, and it certainly seemed unique and creative.

The 3D effect was subtle but definite. With IMAX 3D, I remember things seeming to pop out far in front of the screen. With Bolt, I mostly just felt some subtle added depth information. It might have made the movie more engaging, and it might have even subconsciously made me feel better about it, but it generally wasn't amazing. On a few occasions when the 3D effect seemed underwhelming I removed the glasses to see distance between the two images, and it was surprisingly small. Some scenes were more impressive and a few felt intense. However, the intense feeling wasn't entirely pleasant, and on two such occasions I heard someone sitting nearby say it might make them sick. So, based on that, maybe high intensity needs to be avoided.

The glasses appeared new and they came sealed in their own plastic bag. I decided to keep them as a souvenir and for experimentation unless some notice told me I must return them. There was a message at the beginning to please return them for recycling, and there was a cardboard recycling bin for glasses at the exit, but nothing said that they were on loan and had to be returned. Therefore I decided to keep them.

(It's weird to say that's for recycling for environmental reasons. The environmentally sensible thing would probably be to reuse the glasses by inspecting, cleaning and disinfecting them. If they said they wanted the glasses back for reuse for environmental and/or cost-cutting reasons, I would have left my glasses behind. I wonder if they're using recycling and environmentalism as buzzwords that they expect people to be programmed to respond to.)

After coming home I already found one interesting thing about the glasses: they act differently based on the direction that light is coming from. If light comes from the front (as intended), rotating them changes most LCD screens from a blue tint to a yellow tint and back. If light comes from the back, the glasses behave more like polarized sunglasses, with the screen appearing normal when they are vertical and going almost totally black when they're horizontal, with only the dust on the screen glowing.

This led to me finally understanding circular polarizers. They consist of two components, a linear polarizer which selects for a particular linear polarization, and quarter wave plate which transforms light between linear and circular polarization. With the quarter wave plate before the polarizer, this combination selects for circularly polarized light by transforming it into linearly polarized light and then selecting for a particular linear polarization. This is what the RealD glasses do. The linear polarization of the output is irrelevant because human eyes don't see it any differently because of that. With the quarter wave plate after the polarizer, the combination selects for linearly polarized light and then circularly polarizes it. This is what camera circular polarizers do. To get the effect, one only needs to select for linearly polarized light. However, depending on orientation, linearly polarized output would reflect less from mirrors in the camera and cause problems, so the quarter-wave plate is used to transform it to circular polarization. The most serious problem would be through-the-lens (TTL) metering receiving less light, resulting in overexposed photos. Some cameras like typical non-SLR digital cameras do not have internal mirrors and they can work with linear polarizers (or even polarized sunglasses) without any problems.

The plastic pouch the glasses come in has multilingual and pictorial warnings not to use them as sunglasses. It is explained that they do not block UV light. Actually, wearing them outside would also be pointless because there is very little circular polarization in nature. For the familiar linear polarizing effect, the lenses are both backwards and sideways. So, for now I'm not sure what else I can do with these glasses, and they'll just be a souvenir. If I think of something interesting, I will probably post about it.

Finally, here's my favourite polarized photo, purely here as eye-candy: