Another hair-brained idea!

One of these days, I’ll get around to re-wiring my house, however there are a number of obstacles in the way … the largest being the 2ft of clearance between my crawlspace and my floor joists.

Along with plenty of 20a rated outlets to go around and ethernet glaore, one thing I’d like to have is music in every room, well, nearly every room. I’d especially like to have audio in the kitchen, work shed (attached), bedroom and dining room. The bedroom would be a special case, I’d like to have the audio system, and an additional thin/fat client for full AV usage.

My idea for the audio system revolves around using a linux server. Here’s the basic idea … each room would have a small LCD screen and some buttons (or maybe old pda’s?). So I’ll call that the interface, whatever it ends up being. Each interface will be able to select the source (perhaps four or five source channels, whatever I can get away with, plugging cheap sound cards into my linux box). If the source is digital, i.e. mp3, the interface should be able to pause playback, next track, previous track, random track. The interface would also need to present a pre-programmed list of Internet radio stations (my main source of music, I have a very small cd/mp3 collection). In the case of internet radio, the interface should let me select the previous station, next station, random station, play, pause, etc. When using a live source, cable, tivo, etc, I dont want to mess with an inter-device interface, so, the only option would be mute. For any source, the interface will also provide a local volume control.

MPG321 and the linux kernel modules apparently have support for multiple DSP audio devices, so a rather simple script should allow for a specific input (file or live) to be routed to a specific output. For mixing of sources, that is, two rooms want the same source, I plan to use a series of analog multiplexors, designed for just this application. These simple ICs can be controlled by the server, and connect specific analog ouputs to specific analog inputs. For example, a 8 channel mux arranged as 2×4 will allow a single stereo output to select from a choice of four inputs. So one IC is required for each stereo output, allowing each source channel to select any of the four sound cards as inputs. A similar IC setup would be used to allow the sound cards to share live-output sources (tivo, cable) as inputs, connecting their line-input to any live source available.

I’m not sure about distribution. I could either go with matching transformers, and send line level signals over cable to the room, and use local amplification… or, I could go with central amplification and just use some heavy speaker wire to drive speaker jacks in the rooms. My house isn’t huge, so there wouldn’t be any runs more than 50-70 ft, so inexpensive 14ga speaker wire should serve nicely … I’m not looking for killer sound while I’m stir-frying … just want to be able to hear the tv or shoutcast stream without having to blast my stereo at the opposite end of the house. The advantages I see of central amps, I can build up a big power supply using old computer psu’s, and drive inexpensive car-audio DC amps, one for each source. The server could control the power to the amps, turning off unused sources. Secondly, line level signals are really low voltage… trying to send them over a long run of wire seems to be asking for trouble … unless I use something expensive like RG58 or RG6. Local amplification also means I need to locate an amplifier somewhere in the room, and provide power for it … not that big of deal I suppose.

This project is a long ways off, but its something that keeps crossing my mind, so I figured I should write it down.

Later!

Booster Board

Here are a few pictures of my boost-mode converter, originally posted in my thread on linear1.

switch mode power supply boost step-up breadboard
breadboard with 10 led series string, and boost converter circuit


just the boost converter circuit – here you see the output capacitors, the rectifier (buried under the heatsink), the switch (on the other side of the heatsink) and the inductor

pwm waveform
this is the pwm pulsetrain from the PIC … only 10khz and already not quite square – it looks a lot worse at 20khz

out current waveform
output current measured across a 10 ohm resistor, with a basic choke filter on the output from the converter.

Down to the wire

Well well well – time is running short, and only one of three outstanding orders has been filled.

The boost converter is coming along – I’ve made refinements to the software that offer some good features and better performance. However, I think my hardware design needs more work… and for that, I need parts!

Out of desperation, I visited Satan’s Lair aka Radio Shack and was pleasantly surprised to find some of the items I had been missing. I managed to get a 2a 100uH inductor and (only) two 1uF tantalum capacitors. Having a proper inductor really made a big difference in the output of my boost converter – it sails to the limit I set for 25mA without any problems now, the old hand wound torrid would struggle to get past 20, begrudgingly giving me 25mA along with a lot of HEAT. The real test will be tonight – I’m going to wire up some power resistors as a test load and see if my boost converter can give me half an amp. Why 0.5A you ask? I need half an amp to drive my Moon LEDs at their fully rated 2w power.

The boost converter was originally intended to be a power supply for two parallel strings of LEDs, installed as under cabinet lights.

The lights themselves will be made of aluminum C channel and plexiglas, using 2 watt IO Moon led modules, spaced evenly along the length. I’m not sure what the spacing should be – there is probably some math that would tell me, based on viewing angle and what not. Since these are a prototype, I’m going to ballpark the spacing, so the LEDs I have (4) are spaced evenly across the length of the countertop. I need to take a few covert measurements to figure out how long the channel needs to be. I managed to find a local source, and have secured sixteen feet of aluminum C channel. This stuff has a chunky 1/8″ wall thickness and 1.5″ x 0.5″ outside measurements… combined with a little Arctic Silver, this should be an awesome heat sink for the LEDs.

Pictures to come shortly!

PIC Based Boost Regulator

I have a running thread over at the linear1 forums, chronicling my experiences with building a digital switch mode power supply.

Here is a re-cap of where I’m at now.

The boost converter is a coil, a few capacitors, a diode and a darlington transistor. The PIC manages switching the transistor. Switching is done autonomously by a PWM generator inside the PIC. Constant current regulation is achieved by measuring the voltage drop across a 100 ohm resistor. The voltage is measured approximately 5000 times a second, and the pwm duty cycle is adjusted up or down, depending on the read voltage’s deviation from the set voltage. With a 100 ohm resistor, the math works out real easy – 100mV is 1 mA. Of course, 100 ohms will not work for a heavy current load – so I will have to reduce it to 1 ohm or 0.5 ohms, which changes my math a little, but no big deal.

oscilloscope digital tds 210 Tektronix current ripple

I’m having problems with noise in the output current corrupting the A2D input to the pic. Better capacitors and a real ‘power’ inductor are on order and should arrive wed or thur. When they get here, I will rebuild this project so I don’t have, for example, a 12″ piece of wire connecting my switch to my pwm output.

PIC Based Boost Converter

The idea of using a PIC microcontroller as a replacement for the analog circuitry of a smps controller was originally suggested to me by SurJector over on the linear1.org forums.

Originally I felt the topic was over my head. I also dismissed it because I thought it added unnessecary complexity to an already difficult to understand process. However, as I read more about how switch mode power supplies and dc/dc converrts worked, I realized that using a PIC as the brain was indeed a good idea, and very cutting edge. ‘Digital’ switch mode power supplies are just now starting to ‘pop up’ in the industry, with all the current “all in one” controllers still relying completely on analog.

As I understand it, a digital controller offers the potentional for great efficiency, by adjusting the operating frequency of the switch dynamicly with the load. I’m not sure how that all works yet, but I have a few other things in mind, related to using these converters in the field of solid state lighting. Firstly, I like the idea of being able to digitally controll the output current to the load. Instead of having to dim a bulb using PWM, which is very non linear, I can instead dim a bulb using current mode control… using whatever interface suits me. Secondly, a digital controller could be integerated into a larger project, an illumination manager. For example, combine the dc/dc conversion routine with a routine reading a thermistor – monitor your bulb temp and dynamicly vary the current to keep it at a safe level. Another possibility – with a digital processor monitoring the current draw of the load, a faults such as shorted or open diode could be detected and an alarm condition set – in addition to reducing the current to compensate, a small indicator led could light up – “Check Lights”.

I have some pictures and schematics to share when I’m back home – more to come!

Rainbow LED Chaser

I was bored this past sunday, and needed something to ease my racing brain … so I picked an easy project with lots of flash.

The parts list:

Eight Tri-Color or RGB leds … each led package contains three LEDs
Three 74HC595 Shift Registers … serial load, latching. other varieties would probably work too.
One Microcontroller … doesn’t matter what it is, I used a pic18f252 since it was handy.
Twenty-Four Resistors … I used 150 ohm to set my led current at 20mA, but use anything from 56-220 ohms

The tri-color leds I used are wired as common anode LEDs … each led inside the package has its own cathode pin and shares a common anode pin. So, all my anode pins connect to the postive rail on the breadboard. There’s no reason a person couldn’t use twenty-four discrete LEDs, or eight common cathode leds. Since my leds are “active low”, outputting a 0 turns them on, outputting a 1 turns them off… if you used common cathode leds, they would be “active high”, a 1 would turn them on and a 0 off. If you used discrete leds, well, hook ’em all up one way or the other.

Next comes the connections to the shift registers. Think of each register as a chip containing eight switches you can turn on or off remotely. Each of the 24 LEDs gets connected to an output on the register, and they need to be grouped by color and kept in order. So looking at the picture below, working left to right, I connected all the red leds to the first register, all the blue to the second, all the green to the third. This resulted in the rats nest of wires you see between the chips and the leds. Concerning the registers themselves, they have three connections of up-most importance. Pin seven is the ground connection, pin fourteen is the +5v connection, and pin thirteen is the enable or tri-state pin. The tri-state pin must be tied to ground in order for the outputs on the register to work. Next up is the data connections. The 595 offers a nifty feature of serial pass-through. Using this feature, you can chain a bunch of them together, and treat them as a large number (in the programming). This is done with the QH* and SER pins. QH* connects to SER on the next ic ‘down stream’. On the first IC (the rightmost in my picture), SER connects to the microcontroller. Now in order to ‘load’ the chips with serial data, the microcontroller has generate a ‘clock’ for all the chips to sync to. This clock signal is transmitted on the SCK (serial clock) line. All three SCK lines are wired in parallel to the microcontroller. Last, since we want the data to be retained by the registers, even if the pic stops transmitting, we need to latch the data. This is controlled by the last data line, RCK. When the microcontroller is finished transmitting data, it needs to pulse the latch clock RCK high briefly. Upon receiving this signal, the registers display the data which they just received, and continue to display it until told otherwise. I have some other lines connected, but don’t use them… they are the SCLR line, which clears the data from the buffers, and the enable line. The microcontroller keeps the enable line high (disabling the registers outputs) until it is read to start sending commands… this prevents the registers from powering up with weird random data being displayed.

That’s it for the hardware side … really simple. All the magic happens in software… which I will write about in part two (yes, I’ll post the code too). As a spoiler, all the software does is boolean math, shifting and inverting 8-bit words of 1’s and 0’s around.

Here is the breadboard:
rgb led microcontroller 74hc595 shift register
The parts in the grayed out areas are just stuff left over on the breadboard from an earlier project, or support components for the microcontroller.

Here are some videos:
Initial Testing Video
Center Pulse Effect

UPDATE:
Due to all the connections (24 of them between the registers and the LEDs), drawing a schematic can get messy. I chose to avoid this mess by using Eagle “BUS” feature, which allows a large number of signals to be combined into one wire. The schematic below is drawn using a much less expensive and smaller PIC than the one pictured in the breadboard … however the idea is still the same.

74hc595 shift register microcontroller rgb led chaser

Here is the source code (in BASIC of course) for the “center pulse” effect, it’s pretty much just taking binary patters of 1’s and 0’s and moving them around to create the ‘animation’.

click to download centerpulse.bas

Long Time, No See

Sorry I’ve been neglecting my blog!

I’ve been doing a lot of reading and research, as well as playing with a new toy.

Here are the top-5 items in my current project queue, sorted by priority:

1) LED backlit Rooster Project – Christmas Gift
2) High-End LED under cabinet lights – Christmas Gift
3) Rainbow LED chaser – New Toy / Fun Project
4) LEDs as Sensors – Interface Project
5) LED Matrix Display – 8×8 display modules

I’ll write more about the rainbow chaser tonight (I promise!)… The backlit rooster is just a cheezy Christmas gift I hope to do up cheap for someone who likes roosters and chickens in their kitchen decor. The high-end under cabinet lights are based on Nichia Jupiter LEDs – this project is currently in the very early design stages. I hope to get a proof of concept prototype built by xmas. LED as Sensors is sort-of stuck – I became obsessed with trying to build a large sensor array, but decided today, I don’t need a large sensor array… so I’ll regroup and start a fresh with actual application development for the sensors as I have them now, and worry about building them larger down the road. The LED matrix display will probably never get built, I just had some fun drawing up the designs… Once I priced out the cost to build them, my interest diminished (64 super flux LEDs for each module, 10-16 modules for a good sized display!).

I might be close…

Wow, a long time with no posts – sorry about that!

I have been busy the past week, I wanted to take Thursday and Friday off, so I had to cram a weeks worth of work into the first three days.

I’ve also been racking my brain, trying to figure out how I can integrate a matrix wired LED array into my sensor project. I think I’ve come up with a solution, partly hardware, partly software. Originally I had wanted to have all the LEDs on, and turn them off to do a measurement. This created a lot of problems, mostly due to the current demands. Well, I think I can achieve the same goals, without having all the LEDs lit simultaneously, which will reduce the current demands and should simply the circuit a little.

led matrix sensor array 74hc595

There is the PCB layout for my latest design… I think I’ll make one to test out, and if it doesn’t work for my sensor array, I can use it as a mini marquee. Sixteen vertical columns, anode connected, each driven by a 74HC595 serial shift register. Seven horizontal rows, cathode connected, each driven directly by the PIC’s analog input / digital output pins. To keep current demands low, I will only illuminate one column at a time. I think that still exceeds the design recommendations of the 595, but heck, its all I can think of at the moment.

More than a few days…

More than a few days have passed since my last posting. What have I been working on? Well, the same stuff.

I’d been getting my a** kicked by a logic gate thingy for two days, and turns out, all I had was two wires transposed – ahh well. Here is a re-post of a thread I started on linear1.org:

As part of my continuing effort to develop LED sensor technology, I’ve been trying to tackle the problem of expansion… My original brute-force method was an army of PIC microcontrollers, discretely controlling individual LEDs. While this method worked and was rather simple from a hardware stand-point, there were several drawbacks. The most ADC ports I was able to use was ten… there are microcontrollers with more than this, however they have certain drawbacks that make them unsuitable for my application. Knowing the limit of 10 leds per slave, to build an array of a useful size, say 3×10, would require three slave microcontrollers. Although not enormously expensive, each mcu costs at minimum $3, which adds up quickly.

The method I am currently exploring involves linear logic chips, specificly the 74HCT595N 8 bit serial load latching shift register. Here is the idea, and I’ll throw up a schematic shortly. The cost of a 595 for hobby purposes is roughly 75 cents. Even a modest quanity of 20-25 shifts that price down below 50 cents a piece. Far better than the cost of individual microcontrollers.

The 595 is used to source current, driving the anode axis of the array (columns). I fill the register with 1’s, which sets each output as a current source. While filling with 1’s, I clear the bit for the column which contains the LED I want to sample. The 595 holds this state indeffinately, until it is changed by the microcontroller. The microcontroller, which is directly interfacing the cathode axis of the array (rows), then samples each LED in that column by applying a reverse bias charge and then switching to a high-z input for the A2D reading for each row. This is done one bit at a time (each bit equals a row), so neighboring rows are left “on” at are lit, allowing a good amount of light to be reflected into the led currently being read.

This new arrangement allows a single microcontroller to handle a matrix of ‘unlimited’ columns by ten rows (each row needs to be connected directly to the microcontrollers unique tri-state IO port). A 160 pixel array of 16 columns by 10 rows needs only one microcontroller and two shift registers. Of course, the actual size of the array will be determined by how fast the PIC can scan through the columns, since one column is always ‘dark’ to allow for the reverse bias and read operations. Currently my microcontroller can scan my 3×3 array at a rate of 27kHz, which gives me a WIDE margin, since anything over 70 hz is practically impreceivable.

There are some flaws I need to sort out, mainly power related. The 595 can source 35mA and sink 75mA. 35mA is fine for a 3×3 array, but it won’t cut it for anything much larger. I need to find a way to increase the current handling abilities of each port, without a huge component count or complexity. If I build an array with 10 rows, each column needs to source 200 mA of current. But it also needs to retain the ability to sink a small amount of current. I figure I can solve this with a pair of transistors, one small npn for sinking, one larger pnp for sourcing.

Secondly, my microcontroller can source 25mA of current which is more than enough to reverse bias an led quickly, but it can only sink 35mA of current. So, when sinking a row that may be 16 or more columns long (at 20mA per led), some serious power handling capacity comes into play here. A simple TO92 mosfet can sink an amp of current without breaking a sweat, but I also need the ability to source current and the ability to go “high-z” to allow the microcontrollers internal circuitry to do the A2D sampling.

I think I am close to lickin this issue. More to come.