11h.net

The blog of 11h

April 12th, 2009

Reelight SL-120 circuit theory and making it flash flasher

I noticed the other day that my front, white, Reelight SL-120 had a crack in the plastic. Since it was partially cracked and needed to be fixed I decided to take it apart to see how it operated.

Reelights work through magnetic inductance. Two magnets on the spokes of the wheel spin around and briefly pass by the light. The light has an iron core that meets the magnets as they pass by. The iron core is wrapped with enamel coated wire. As the magnets pass by the iron core, the collapsing magnetic field creates and electric current that travels through the wire. The electric current in the wire travels to a capacitor where the energy is stored. The energy in the capacitor is then used to power a 555 timer circuit to flash the two white LEDs.

Simple right?

But what if you wanted to make your Reelight SL-120 flash a little faster?

First we need to look at the LM555 datasheet to figure out all the elements of the circuit and how Reelights has implemented the circuit.

It looks like the SL-120 uses an Astable waveform. The frequency is 2.2 Hz (roughly - I counted the number of pulses over 60 seconds).
The astable equation looks like
2.2 Hz = 1 / T = t1 + t2.
t1 = 0.693(Ra + Rb)C
t2 = 0.693(Rb)C

Looking at the Reelight SL-120 I see that 560k is Ra and 56k is Rb but the cap is un-marked. Damn. Gotta do this the hard way…
2.2 Hz = 1/0.45
0.45 = 0.693(Ra + Rb)C + 0.693(Rb)C
0.45 = 0.693(616)C + 0.693(56)C
0.45 = 426.89C + 38.8C
0.45 = 465.69C
C = 0.000966 (roughly 1uF)

If we wanted to make the lights flash more often, we would need to change Ra.

For fun I threw a 100k resistor on top of the 560k resistor. What happens is that Ra is now 84.85 [1/(1/560 + 1/100)] so the frequency would be:
1/(0.693(84.85 + 56)0.001 + 0.693(56)0.001) = 7.33 Hz

January 30th, 2009

Timestamp in Linux using ftime for millisecond timing

I am working on an embedded project at the moment that prints debug messages to a serial console.  Interestingly, it seems that some of the prints are arriving out order from the actual flow of the software when they originate from the same thread.

To debug the printing problem and to add another, better layer, of debugging to the project I added a time stamp to a preprocessor definition for the existing printf() macro.

Here is the existing print macro:

#define debug_print(fmt, arg)          printf (fmt, arg)

To add a time stamp we need to use the timeb struct from sys/timeb.h.  Since a struct is used, we need to give it a focus. Otherwise we’ll get compile errors. It will need to be put in a false do while loop.

#define debug_print(fmt, arg) \
  do { \
    struct timeb tp; \
    ftime(&tp); \
    printf(“%ld.%d: “ fmt, tp.time, tp.millitm, arg); \
  } while (0)

Now, in your program you need to make sure sys/timeb.h is added and then use the new print macro.

#include <stdio.h>
#include <sys/timeb.h>

#define debug_print(fmt, arg) \
  do { \
    struct timeb tp; \
    ftime(&tp); \
    printf(“%ld.%d: “ fmt, tp.time, tp.millitm, arg); \
  } while (0)

int main() {
  while(1) {
    debug_print(“This is dbg print and a number: %dn”, 10);
    usleep(10000);
  }
  return 0;
}

Enjoy!

December 16th, 2008

Engineering scholarship opportunities!!! Or just a terrible mailing list?

I’m a, or was, a proud member of IEEE for the last eight years.  The beginning of the ninth year is off to an incredibly rocky start.
In the last year I have received more junk mail on behalf of IEEE.  Most of it was from travelers insurance.  Some of it was life insurance nonsense…  Nothing more than recycle bin fodder.  Then the IEEE Spectrum magazine started to lag behind the times.  And not just lag a little - Make: magazine was beating them to new and interesting stories by six months or more.  At one point in time I would read Spectrum from cover to cover as soon as I got it.  Now… They aren’t as interesting and go unread for months.

Monday evening starting around 17:00 someone sent an email to ieee-oregon@ieee-or.org and ieeeoregon@LISTSERV.IEEE.ORG which set off a storm of replies, replying to everyone in the mailinglist, asking to be “removed” or “unsubscribe.”  The really intersting comment was from one individual who [replied to the list and] said “Sending “unsubcribe” messages to this list has no effect, beyond demonstrating thoughtlessness.  No human operator is standing by 24×7 waiting for your unsubscribe message - it is robot software, mindlessly rebroadcasting everything you send to it.”

I was a bit shocked at this statment.  Could there really be an engineer this oblivious?  I guess he answered that one all on his own.  Sending unsubscribe will unsubscribe you from mailing lists; on a mailing list that was set up correctly or run by proper software.  I guess IEEE doesn’t have that software.

If someone had not been nice enough to post the some-what obfuscated link to remove your [illegally added] email from the IEEE Oregon chapter this nightmare of emails would probably continue.

If you have found your email address illegally added to the Oregon IEEE mailing list you can remove it here:

http://listserv.ieee.org/cgi-bin/wa?SUBED1=IEEEOREGON&A=1

November 20th, 2008

please insert correct map disc

Well, I made that error appear because… I’m an idiot.

That’s an error that can be displayed on a Toyota/Lexus MFD after changing the map region in a service menu.  I managed to select one that’s not for the disc I have.  This setting stays in flash in the navigation unit, which has a battery backup.  In order to ‘re-set’ the navigation unit, it must be dismantled and a board that has the battery must be disconnected.

My many thanks to htmlspinnr from priuschat who described the processes perfectly.

Pull NAV ECU:

  • Remove rear plastic cover by pulling plastic retaining clips/pins. I found two flathead screwdrivers helped with this.
  • Remove 4 8mm/philips screws, 2 on each side retaining ECU.
  • Remove 4 harness connectors at front of driver’s seat.
  • You’ll need to spread bracket just a tad in order to dislodge the ECU from the bracket.

Open NAV ECU, perform “fix”:

  • Remove 8 screws from the bottom of the ECU.
  • Cover is held in place by 1 tab on each side that fits around a small bump on the top cover. Using a small flathead screwdriver, spread the cover at the bump. The ECU cover should then tilt up and come right off.
  • With the plugs at the front, the left board is the NAV logic, and the right appears to be the AVC-LAN interface and power supply. There is a ribbon cable separating the two. These boards should lift right out, as the cover screws are holding them in place.
  • At whichever location is easiest, lift the retaining clip at one end of the ribbon cable connecting the power supply board to the “logic” board, then gently pull the ribbon cable free. This effectively disconnects the battery backup from the ECU.
  • I also spotted a black momentary switch on the power supply board. This may also be a reset/backup power interrupt, however being a multi-layer board, I couldn’t easily follow the traces to double-check. For safe measure, I press and held this for a few seconds as well.
  • Re-insert the ribbon cable, ensuring that it’s aligned correctly. Push the retaining clip back down to secure the cable.
  • Replace the boards, ensuring that the boards fit onto the alignment tabs. The power supply board was a bit tricky here.
  • Replace the cover. I found that securing the screws over the power supply board first helped to keep it aligned as mine wanted to pop out of place.
  • Replace the ECU, reversing the steps of removal.
  • Power on. You’ll see on the NAV screen: Loading application, do not power off.
  • I then saw the “Agree” screen. Success!

Interestingly, when I re-applied power to the navigation unit, the default GPS location was 1374 Pennsylvania Ave NW.

November 19th, 2008

New laptops, BBC, IT Crowd, iTunes backup

I am currently preparing for a data migration from my current laptop to either the same laptop with a re-freshed Windows XP install or a new laptop with a fresh Windows XP install.  The IT guy helping me with a failed forced update patch had the same reaction to my system as Derek did to Chip’s system and suggested that I migrate.

The only real thing I care about on my laptop is my iTunes (yeah go ahead, make fun of me) library.

In the process of the preparation for a new system I have been re-organizing my iTunes library to make it smaller so that the migration would not take so long.  I discovered that I have a number of duplicate songs and a lot of the songs that did not have proper metadata.  I assume that when I ripped the CDs (on my file server), my Perl script did not add the ID3 tags correctly which would explain why I added the songs again from another source (with proper tags).  Bugger.

Now, here I am, re-organizing my iTunes and watching the second show of IT Crowd season two.  I ended up listening to a song from my music that was un-tagged and realized that it was Delia Derbyshire from the BBC’s Radiophic Workshop.  She was most famous for her work in creating the Dr. Who theme song.

There was a youtube video that I saw of her doing reel to reel loops and mixing in the form of monome.  Only 40 some years earlier than when monome came out.

If there is someone that I would have liked to meet, it would have been Delia.  She’s awesome.