Pentax IR Interval Timer

Hey, look at that, my blog website is still alive and working. Last post was Sep 2010, a long time ago.

I’m planning a trip to the desert, and one of the things I wanted to make for myself were time lapse movies of sunrise or sunset, and the night sky. My DSLR does not have a wired remote capability and Hoya has decided not to include an interval timer on their low end DSLR

I could have purchased a timer off ebay, that claims to be compatible with every DSLR ever made but those claims make me skeptical. I also did not care for their user interface. So, many months ago, I tore apart one of the Pentax IR remotes, to see what makes it tick. It was a simple design on the inside, a rather large micro-controller with external clock, a transistor, a capacitor, a few resistors and an LED. The trigger button was one of those resistive pad-switch types. Originally I thought I could just trigger the remote by pulling one side or the other end of the button high or low. This did not work, and when I scoped it, I discovered a handshake was employed between the two terminals of the switch, both leading to micro-controller pins. So it looks like Hoya didn’t want people hacking the remote directly.

Switching to plan B, I tore apart an old pioneer cd changer and harvested its IR decoder chip. Following some arduino code from Lady Ada, I tried to capture the timings of the IR signal using a PIC. This worked to a degree, and probably warrants further study down the road, but I couldn’t get the pulse train quite right and so the camera would not respond.

Abandoning the learning-remote line of thought, I connected the IR decoder to my o-scope and manually measured the pulse train. It was only 26 msec, and consisted of 15 transitions. 13 msec on, 2.8 msec off, and then 1 msec on/off repeated eight more times. Using the 12F683 chip (one of my favorites), I had access to an 8MHZ internal clock and a hardware PWM module. Microchip claims the hardware pwm maxes out at 20khz, but I had no trouble getting a stable 37khz carrier out of it. Then I whipped up a little subroutine in proton basic which toggled the carrier on and off with the appropriate timings. I had setup the pic’s pwm output on channel 1 of the scope, and output of the ir decoder on channel 2. I could fire the pentax remote at the decoder and compare it to my pulse train from the pic. When they were an exact match, I got the camera and presto, it started snapping pictures.

Cam Remote Schematic

That schematic is what I’ve worked out for a bare-bones version of the remote. A single button is used to program the interval, there’s a status led and room for two IR emitters. My current prototype is only using one emitter, because that is all I have right now. I’m also using a 2N3904 which isn’t ideal, but it was working on the breadboard and now it’s soldered in place. I just now looked up the specs, and the poor thing is only rated at 200ma collector current – that could explain the lack of output power I’m seeing on the emitter.

In interest of saving time, I didn’t make a PCB for this revision, but I’ll probably do that for the next prototype. All point to point wiring, I tried to be neat. I used a tiny SMT resistor to drive the transistor, it worked out real handy.

The timer and two AA batteries fit in this mint tin I’ve been saving for years. I don’t know if they are still in production; I would like to get a few more.

I field tested the timer at tonight’s sunset – I’m trying to figure out how to convert a bunch of jpeg’s into an avi now – stay tuned!

Update: Here’s the video, turns out Picasa can generate a timelapse … only 8 seconds, need more frames!

Capacitive Sensing Continued

Hello readers from MAKE: as well as all other readers 🙂

My prototype touch sensor worked so well, that it hasn’t needed much changing. I sent the design off to Custom PCB, and less than a week later, I had a pile of circuit boards waiting for me.

I changed the layout around a little, mostly adding a 2×8 header for accepting a ribbon cable style connection. The header combines power, ground and outputs into a single connection, making it easier to connect to the main board of my larger project (sprinkler controller). Each touch output is paired with a ground wire, which I suppose makes it more resistant to interference. The caps I used this time are polyester film 220 nF, doubling the amount of capacitance compared to what was used on the prototype.

Yes, the ugly piece of plexi is still ugly. Don’t worry, it will be hidden from view. In the final configuration, this board and its plexiglas spacer will be inside a plastic project box. I’ll have a laminated “keypad” overlay affixed to the outside of the box so I can see where the buttons are. The spacer will be flipped around, going on the solder side, giving me enough clearance to flush-mount the sensor with the wall of the box. Flush mount is very important, as even the slightest air-gap will ruin the proximity sensing effect.

Nothing much to see solder side… a few smt passives set options on the chip, as well as decouple and filter the incoming power. The big resistor limits current for the meager power led which no one will ever see once the board is in use.

I’m very close to finishing the larger irrigation control project, hopefully sometime this week! Thanks for reading!

Audio Matrix Switch

I’ve had some down time project wise lately, most of my SMPS research is on hold, since I need to order even more parts (namely diodes and switches)… so, I’ve taken the time to draw.

One of my ‘back burner’ projects is a whole-house audio distribution system. So, this past week or so, I set out to design the heart of the system, a matrix switch. Originally I had tried to go “too big”, designing a system with four inputs and eight outputs. However, routing the signal lines and control lines was too much of a challenge, even using a two layer board. So, scaling things back, I wound up with a 4×4 matrix that was barely manageable.

audio matrix switch 4x4 74hc4052 74hc595 schematic

There is the schematic for the latest ‘stable’ version. I call it a stable version, because it passes all of the DRC tests and all the nets are routed. I have another version in design, which adds ESD protection to the external audio connections in the form of high speed schottky diodes which will clip any voltage coming in that rises above or falls below Vcc and Vee.

Control will be provided by either a serial / parallel connection to the audio server PC, or from a “controller board” powered by a microcontroller. I haven’t really figured out how complex I want to make the interface yet. Control of the switch itself is fairly straight forward. Two 74HC595 latching registers are daisy chained together, forming a sixteen bit register. This register is used to provide the eight bits which tell the multiplexers which connections to make. Each multiplexer has a two bit interface, A and B, which selects one of the four IO channels to be connected to the COM channel. I selected the 4052 multiplexer which is internally divided into two sets of four channels each, ideal for stereo I thought. So the first eight bits of my 595 register are connected to the eight control lines on the 4052’s. Second, to provide a “hardware mute” or “output enable” feature, another four bits of my 595 register are connected to the /Inhibit (enable) control lines on the 4052’s. This allows the output of each 4052 to be electrically disconnected from all the sources. The final four bits of the register are used to power four “general purpose outputs”, perhaps to control relays, external indicators, whatever. The control lines connecting to the GPO header have inline resistors, to limit current draw to a safe level, so not to damage the 595 in the event of a short or connection to an unsuitable load. The four bits connected to the inhibit lines are also connected to four LEDs, so I can see which zones are active.

The 74HC4052 is an “analog” multiplexer, in that it allows voltages other than digital 1’s and 0’s to pass through. It is also a bidirectional multiplexer, allowing current to flow in either direction. This allows the multiplexer to handle the “AC” nature of an audio signal. In order to allow a true bipolar sine wave to pass, the 4052 requires a dual rail voltage supply. For simplicity, I will be using a five volt supply with positive and negative outputs.

two layer pcb layout audio matrix switch

Here is the ‘bare’ pcb layout, without the top and bottom pours rendered. This is a composite, showing both the top layer and bottom layer at the same time. It’s easier to follow the traces this way I think.

two layer pcb layout audio matrix switch

Adding in the ground planes or copper pours, it makes the board look mostly purple. I tried to maximize the size of the pours, to help minimize any interference or crosstalk. Although, at such low frequencies, I don’t really expect much trouble.

pcb parts layout silkscreen audio matrix switch

Finally, the board with just the silkscreen or layout layer selected. This again, is a composite, showing parts on both the top and bottom of the board, which makes it look like some of the parts are overlapped.

There is a lot more to come on this subject, but it will be a while. Overall, this was just a fun project to draw, and hopefully one day it will actually get fabricated. I need to figure out how complex I want the interface to be, and what options I have for interfacing with the audio server.

Touch Sensing Building Blocks I

The “core” building-block I mentioned in my last post is nearing completion, at least, the software.

I have my microcontroller handling “switch emulation” tasks. It can emulate either group of momentary switches or a group of toggle switches. Response time is real good in a dimly lit room, and it works decently well even with the overhead fluorescents turned on.

Right now I’m working on a basic keypad PCB I can throw together, for a ‘proof of concept’ prototype. The first keypads will likely only support 6 keys, and I’ll build from there. Six keys requires twelve LEDs, six of them need direct and discrete anode and cathode connection to the microcontroller. The other six LEDs are providing bias light for the sensors to “see”.

I should have a video up tomorrow of the breadboard in action, and hopefully some pcb’s by next weekend.

Water Filter Controller

The old adage “measure twice, cut once” has a realitve in the field of electronics engineering; “measure twice, design once” … ok, well maybe that’s a bit corny but anyway.

Turns out the controller I designed for my water filter is pretty much useles. My filter’s pump is not the 12vdc that I imagined it to be, instead, it is 24vac. So the two smt mosfets which I soldered to my pcb with generous amounts of solder, are not capable of switching AC. Worse, I had planned to power the controller itself off the psu for the pump, so the 7805 vreg I’m using will not appericate AC on its input terminals either.

I plan to salvage this situation however… using relays, either mechanical or electronic, as well as a separate power supply. So, I will use a ~12 volt unregulated supply to power a pair of mechanical relays, one for the pump, one for the valve, which in turn will be switched by the mosfets. Or, I can desolder / destroy / jumper over the mosfets, and run a +5v control signal to my outputs, for control of a solid state relay.

I need to price out the cost of mechanical vs solid state …. probably solid state will win, I think I can build a triac based ssr for under $2.

Water Filter Controller

As a fan of taking my dihydrogen monoxide in straight, uncut, uncorrupted liquid form, I purchased a six stage reverse osmosis filter some years ago.

My filter is a few years old now, and the super calcium enriched water we have in Michigan has taken its toll. The filter used to shut off when the production tank was full. However, the filter has recently developed a leak in the auto shutoff valve, so it’s constantly consuming water, even if the pressure tank can’t hold any more. This leak started slow, and I could live with it. In a few months, it had sped up to wasting a considerable amount of water. So, rather than replace the auto shutoff valve, which would have been too easy, I decided to add a microcontroller instead. The other problem my filter has, I discharge the brine water out to storage tanks next to my house, which hold the waste water, for watering plants and other uses. Problem is, when the temperature gets too low, the discharge line can freeze, which is very bad for the filter. So my microcontroller solves this problem as well.

The mcu is performing a few simple logic operations, with a few twists. First, it checks to see if the pressure tank reads “high” or “low”, via a pressure sensitive switch. If the tank reads “low”, that is the first “1” in my logic comparison – a simple AND operation. Second, the mcu checks to see if the outdoor ambient is above 38°F. That is my second “1” in the AND operation. If the pressure is low and the temp is good, a flag is set to enable the boost pump and water supply valve. A timer detects this flag and begins a countdown of 30 seconds (roughly). I chose to use a timer to buffer any false readings that may occur for whatever reason. After the 30 seconds has elapsed, the mcu turns on two mosfet switches, controlling the current for a solenoid valve and the boost pump. The mcu continues to monitor the two variables of the AND operation, if either changes, the “make water” flag is cleared, and the mcu turns off the water supply valve and the boost pump.

schematic diagram of water filter controller
(click for super-sized version)

Two N-Channel mosfets control the current for the boost pump and the solenoid valve. The valve is a 24VAC lawn sprinkler valve, but I have tested it and it works well on 12vdc. The boost pump is a 100 gpd, 100 psi diaphragm pump, which delivers slow but steady high pressure water for optimal membrane operation. Pull-down resistors R3 and R7 are provided to prevent mosfet self-destruction should something happen to the microcontroller. The connectors TEMP, PRES and DISABLE are pin headers for connecting to external transducers. For reading temperatures, I chose the Dallas DS18B20 high precision digital thermometer with 1-Wire interface. The pressure switch is a simple normally closed pressure sensitive switch that opens around 45 psi. It is wired to present the PIC with a logical “1” when the pressure is low. The disable connector will be connected to a shut-off switch, allowing me to temporarily halt production. The LEDs are just for indication of various operational conditions and modes. A 7805 regulator provides the pic with 5v from the 12v supply for the pump and valve.

water filter controller assembled top view

Rather than cobble this together on protoboard, I made up some PCBs real quick. Here is a top view of the controller, without any connections, except for the thermometer. When installed, the thermometer will be installed at the end of a ~10ft shielded cable, for sensing the ambient temperature near my water storage tanks.

water filter controller assembled bottom view

Here is the messy solder side of my controller. I haven’t hosed it down with alcohol yet to clean off the flux. I waited till it was good and late before soldering anything, so some of those joints are pretty nasty – I apologize.

water filter controller pcb layout
(click to download full res)

The PCB layout was pretty easy – I had a lot of room to work with, as the enclosure I have selected is pretty big. This image shows the parts layout, along with the bottom copper artwork. The top layer artwork (in red) is for two jumper wires. Clicking on the above layout will get you a 300 DPI monochrome TIFF of the bottom layer artwork. Print this out at 300DPI and you should have a 1:1 scale of the pcb, incase anyone wants to make their own. Hit the contact justDIY link on the side menu if you want the firmware source code – it is written in Proton Plus basic.

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!