Archive for the ‘Uncategorized’ Category

Tool hack: free “helping hands”

Wednesday, March 20th, 2013

I discovered this hack a while back–I don’t recall what project I was working on, but I’ve used this a lot ever since I discovered it.

Ladies and gentlemen, may I present:

It’s great when tinning wires, soldering free-hand, and when you just need a little bit of help holding something steady. And it didn’t cost me a cent.

Last-minute road trip hack

Wednesday, March 20th, 2013

The family is about to head out on a trip. Somehow, the cigarette-lighter-power-adapter-plug thing has lost its tip, and I don’t have enough time to order a new one.

On the plus side, I have a cell phone charger with plenty of extra space inside. So I added an auxiliary power jack to the side. Now the kids can watch movies and the cell phone can charge at the same time.

I had to squeeze in a few tricks along the way:

1) The fuse in the cell phone charger is only 500mA. The DVD player takes a bunch more than that. I don’t have a higher-rated fuse of that physical size, so I bypassed it and soldered in a 5A fuse in its place.
2) It’s easier to have the DC jack point out the side, so that’s how I did it. Turns out the jack fits perfectly inside the case. It’s held in place with super glue and melted plastic.
3) Speaking of melted plastic, I used my soldering iron set on a low heat to melt a hole exactly where I need it. I then enlarged it with the knife off my Leatherman.
4) I cut the DVD player’s cable off its PCB and spliced a 5.5×2.1mm barrel plug onto the end. So if we don’t want the cable clutter, I can unplug it and it goes back to being a regular cell phone charger.

Mini project: How a rotary encoder is built

Wednesday, September 12th, 2012

The power button/volume knob on our minivan became flaky.  Rather than getting a whole replacement stereo (and giving up steering wheel controls), I decided to replace the part.  And since the old one doesn’t work, I get to take it apart and see what makes it tick.

Here’s the patient:

After removing the casing, it pulls apart into two main pieces.

The white circle in the middle of the bottom half is a rubber dome switch, much like what you find in inexpensive keyboards.  The two sets of three contacts on the left and right are connected to the common (center) contact.  The two sets of contacts on the far side are connected to the two outputs.  The top half holds a conducting spoked disc which at times connects the common pin to the two quadrature output pins.  How does it work?  Wikipedia to the rescue!

So that’s the electrical side of things.  What about the detents?  That mechanism is visible once you take apart the top half.

The black wheel has a ring of notches around its top side, and a copper disc spring provides friction.  A kink in the disc fits into the notches, giving the tactile feedback.

And that’s about it.  Simple, effective, and (usually!) reliable.

Reversing an RGB LED remote

Thursday, May 10th, 2012

I have this dream to someday light our basement with RGB LEDs. They often come with remotes and controllers, which are surprisingly inexpensive. The problem with the remotes you get for cheap on ebay is that you *have* to use the remote to change the lights, and that of course limits you to the buttons on the remote.

I’d like to make an in-wall dimmer/color changer for LED mood lighting, but with the added feature of being compatible with the existing cheap LED remotes on the market.

That means reverse-engineering one. And here it is:

Hardware

What’s the first thing I do when I get a new gadget? Take it apart, of course. Inside, it’s pretty simple:

There’s a 256-Byte two-wire serial EEPROM in the top left, a 5V linear regulator along the lower edge, and an unmarked 16-pin IC that is the main controller. Three transistors along the side drive the three colors of LEDs, and an external IR receiver connects to the board via the Red/Blue/Black triad.

I’m really not sure what the serial EEPROM is there for–perhaps the memory setting I couldn’t get to work?

IR Protocol

I soldered a couple leads to appropriate points and hooked it up to the oscilloscope to capture the incoming signals. Some day I hope to own a logic analyzer, but for now the oscope will suffice, especially when I only need one or two channels.

Run a Single trigger, press a button on the remote, and here’s what I got:

A bunch of zooming/shifting/saving/etc later, I had a bunch of data captured. Here’s the signal you get when pressing the “Red” button (click for big):

When the IR LED is on, the signal goes low, and when it’s off, the signal goes high.

There’s a 9ms low pulse, a 4.5ms high pulse, and then the data starts. Off I ran to find some IR protocols. I found myself in a familiar place–SBProjects, which contains a remarkably thorough knowledgebase on IR remotes and protocols. As it turns out, the protocol is the NEC protocol Each bit is encoded by a 560uS on pulse followed by an off pulse of varying length–560uS off is a logical 0, 1680uS off is a logical one. There are 32 bytes total. The first byte is an address, the second is the inverse of the address, the third is the command, and the fourth is the inverse of the command, with a final on pulse after the last bit. It’s little-endian, so least-significant bit comes first for each byte.

I mapped out all the remote’s buttons, and here’s the result. For all buttons, the address was 0xFF. Only in the command did it differ. The following table contains the buttons and commands. Note that these are little-endian, and written in hex.


Up  Down Play Pwr
0x3A 0xBA 0x82 0x02

Red  Grn  Blu  Wht
1A   9A   A2   22

2A   AA   92   12

0A   8A   B2   32

38   B8   78   F8

18   98   58   D8

RUp  GUp  BUp  Quick
28   A8   68   E8

RDn  GDn  BDn  Slow
08   88   48   C8

DIY1 DIY2 DIY3 AUTO
30   B0   70   F0

DIY4 DIY5 DIY6 Flash
10   90   50   D0

JMP3 JMP7 Fade Fade7
20   A0   60   E0

It’s pretty much a binary key matrix–the remote is just sending a code for the key that was pressed, rather than RGB values or anything more complex. The first four rows have A as the second nybble (little-endian, though!), the next four have 8 (0xA minus 0x1), the last three have 0 (0x8 minus 0x8). The second column is the same as the first column except for the first bit being flipped. The third column is the same as the first, except the second bit is flipped, and the third column has both the first and second bits flipped compared to the first column.

All the decoding must be done in the controller.

Outputs

The controller outputs a PWM signal for each color. I noticed that the PWM frequency didn’t seem all that high–I could at times detect the flashing. (As an aside, it drives me nuts that car companies use stupidly low PWM frequencies for LED tail/brake lights, but that’s another subject) So I checked out the wave form for the outputs.

Each output is turned on for 840uS per cycle. To vary the brightness, the controller adjusts the off time. That varies from 5.36mS at the dimmest setting to 320uS at the brightest. That means the controller only gets up to about 72% duty cycle at its brightest setting, and down to 14% at the lowest setting. Since humans percieve brightness logarithmically, there’s a big low end that’s getting missed, although it might be too dim at that end to be useful.

Where am I going next with this? I’m not sure yet, but at least it’s now documented.

Finally! Function generators back in stock.

Thursday, March 22nd, 2012

Our suppliers were out of a critical part, and it took several weeks to get more.  But they’re back!

Breadboard Adapters for ATMega 16/32/164/324/644/1284 Back in Stock

Wednesday, February 29th, 2012

Find ’em here.

That was quick…

Thursday, February 9th, 2012

I had no idea there would be so much interest in the function generator kit, and ran out almost immediately.  More are on the way!  If you’d like to be notified as soon as we have more, you can click the “Notify me of updates to Tiny Function Generator Kit 1Hz-40KHz”   link in the right-hand column of the product page, or email me at info@allgaiershops.com.  Thanks for your patience!

ATTiny25-based function generator

Wednesday, February 8th, 2012

One of my very first forays into programming microcontrollers came when I needed a square-wave generator.  It was super simple, based on a Tiny25, only had sixteen discrete frequencies (each frequency was double the previous), and was housed in a rough wood container I made for it.  Now, I’ve made something better.

An ATTiny25 still forms the core of it, but it’s a whole lot better. The frequency range is 256 steps, increasing exponentially from approximately 1HZ to 40KHz. It outputs simultaneous sine, triangle, and square waves, with adjustable duty cycle/triangle wave shape. It has independent amplitude control on each output. And it’s all on one palm-sized, single-sided PCB.

The output isn’t perfect–it’s only 6-bit, although the firmware originally was 8-bit and can easily be reverted. The output filter could probably be improved (it’s currently a simple RC filter). The maximum frequency is limited by 1) the speed of the built-in PLL on the microcontroller (64MHz), which I use for the PWM clock and 2) how fast I can load the timer with the proper values for generating PWM. I have it down to 20 cycles + ISR overhead. And it updates the output 48 times per cycle maximum (and fewer at high frequencies, so the triangle and sine waves aren’t as accurate up there).

But it works pretty well. Here’s an o-scope screenshot (yes, someday I need to hook up the o-scope to the computer):

I got enough parts for several prototypes, and since it works, I’ve put together some kits in the store. You can find those here.

Also, if you’re interested in making improvements (and I’m sure there are plenty to be made), here is the source code, the schematic, and the board layout.

Shoot the engineer and start production

Wednesday, February 1st, 2012

A coworker at my previous job had a sign in his office that read:  “There comes a time on every project when you just have to shoot the engineer and start production.” Why?  Because engineers will continue to tweak a design ad infinitum, even if it’s already suitable for production.

Such was the case of a recent post on Hackaday, which detailed one person’s creation of a USB-powered LiPo battery charger.  One commenter suggested ditching the USB plug in favor of using the PCB itself for the USB connection.  So I did it.  But, being an engineer, I found that insufficient.  So I also managed to shrink the footprint.  And did it all on a single-layer PCB.  For fun.


And if you’re interested, here is the schematic and layout.

“It’s like a woodpecker!”

Tuesday, August 9th, 2011

Several years ago, after reading a thoroughly entertaining piece on old IBM buckling-spring keyboards (seriously, go read it!), I set off to the local thrift store, and was lucky enough to score an IBM Model M2.  It’s smaller and lighter than the Model M, but has the same wonderfully tactile and noisy buckling springs under the keys.

I loved that keyboard, right up until it stopped working.  I considered creating an all-new PS/2 controller for it, but then in my many hours of unoccupied time at my old job I found that someone had done something similar on a Model M, but with a USB interface.  Thank you, Chris, for the excellent work!

So after reverse-engineering the keyboard matrix, I modified the keymap file, designed my own board (schematiclayout), compiled it, soldered the whole thing together, and….it worked.  Well, it wasn’t *quite* that simple–I had a few errors in my keymap, I realized belatedly that the keyboard is too slim for a regular USB-B connector, an errant shield wire in the USB cable shorted one of the data lines (no damage, thank goodness), a too-long leg on one of the components made for a poor connection with one of the membranes, I dropped the keyboard a couple times while inserting all the buckling springs, I *lost* a couple springs and had to order new ones, etc.  But with those wrinkles ironed out, the keyboard finally worked.  And works.  Source code.

My new controller board, next to its predecessor:

A close-up of my board:

The matrix:

The pile of buckling springs and key caps.  Yes, you have to remove all 101 of each. And then very delicately replace all the buckling springs when reassembling the board.  If you’re going to do this, take all the keycaps off before doing anything else.  It’ll make it much easier to undo all the plastic clips that hold the board together.

And lastly, the whole thing back together, hooked up to my modern-day Thinkpad:

The title quote comes from one of my bosses when I asked him if he wanted one, too.