Nov 27, 2011

Halloween Build Part 3: Full Schematic

Below you can see the rest of the schematic integrated with the voltage regulator from my last post. As I explained previously, the PIC16F690 is the brains of my system. This PIC is a mid-range option for hobbyists and has much more functionality than I made use of in this project. I originally thought I would make better use of it when I was in the planning stages but everyone who has been following me knows how things turned out. You can see in the schematic I left 15 of the 20 pins open, which is a colossal waste of space. A better controller to use would have been the ATTiny10 from Atmel or a 6 pin micro from Microchip. Even the 16F84 that I had lying around could have saved some space and provided the same functionality (flashing an LED).
I was able to program the chip using an in-circuit configuration with a PICKit 2 and could have included programming headers in the design if I intended to reprogram these devices in the future. I have included another schematic of the in-circuit setup I used for the programming. You can substitute a small signal diode for the 47kohm resistor if that is handier for you. From what I can gather this setup is pretty standard across different families of microcontrollers and you can integrate this header into your printed circuit board design for on-the-fly reprogramming. You just have to make sure that the circuit isn’t operating while you are trying to program it and that no power is supplied to the programming pins when you do want to test the circuit. This is less of a problem if you don’t have anything else connected to pin RA3 (configuration specific).


The software is brain dead simple and written in C using the MPLABX IDE from Microchip (GUI pictured below). All it does is call a delay function by passing an integer to represent the number of cycles through a 100ms countdown. I varied the timing for this function with each different pumpkin to create different patterns. The code I have uploaded to this post is based on a 20Hz flasher to create a strobe effect. I have linked a zip file to this post with all the necessary header files if you want to play around with lighting up some LEDs yourself. You can download it here.

If you look at the datasheet for the 16F690, you will see that PORTC corresponds to the RC0, RC1, RC2, and RC3 pins on the chip so you must first configure PORTC as outputs before running the main piece of the code. By setting these pins high in software, you place the chip’s supply voltage on the pins in question (RC0-RC3) and start to source current to whatever loads the pins are tied to. In my case, they are all tied to LEDs with current limiting resistors. I have assumed Red LEDs in the schematic so different resistor values are necessary for other colors/source voltage combinations. I wanted to drive the LEDs at around 15mA so I used ohms law to determine the correct resistor based on the turn on voltage of the LEDs. You can find online resistor calculators that will tell you what resistor to use based on your LED color and the current you desire. Otherwise, look up the forward drive current calculation for a diode.

That’s about all I have to say concerning this design. It is easy to see why this project doesn’t amount to much more than a glorified LED flasher. Some obvious improvements are software upgrades to lengthen battery life, decreasing the size/pin count of my microcontroller, and adding external triggering options to cue up the light sequences based on movement. My final two posts dealing with this project will look at the circuit board design and the highly anticipated bill-of-materials (BOM).

Nov 25, 2011

Intro to Schematics

I am going to post my full schematic for my Halloween build soon, but before I do I thought it might be worth some of the noob's time to check out this short video from Collin Cunningham of MAKE magazine. He goes through a quick description of each of the component symbols and talks about what a schematic is and what it is not. I doubt I will be posting anything soon that is overly complicated, but it never hurts to brush up on the fundamentals. Enjoy!

Nov 23, 2011

Halloween Build Part 2: Power

The heart of my circuit design for this Halloween display is the PIC16F690 microcontroller from Microchip. The 16F690 is a 20-pin, 8-bit flash micro that comes with a 4MHz internal RC oscillator and a 10-bit analog-to-digital converter across 12 channels. I have generated the schematic in DesignSpark so I can easily talk about each piece and its function. This entry will entirely focus on the power piece of my design, hence the modified schematic in the picture below.

First and foremost, every circuit needs power in one form or another. In my post “Power Your Next Project” I took a high level look at how best to power each of the micros in the system and decided to use a 9V battery with a 5V voltage regulator. Like I stated in that post, I will do a full blog on voltage regulators in the future if for now you can accept that its purpose is to turn higher voltages into lower voltages. However, selecting the right regulator proved to be harder than I initially anticipated. One of the good things about being rooted in power electronics is that I know more about the ins and outs of various regulators than the average electrical engineer. Unfortunately, this can sometimes make it harder to sift through the noise and choose the right part. My biggest concerns were the package size, the output voltage, dropout voltage, and the rated current of the regulator. For simple projects like this those are generally going to be the driving factors. Others like tight line and load regulation are nice to have but I am not switching any heavy loads and the micro can operate on a range of 2V – 5.5V so it is not going to shut down because the power supply is lagging.

I wanted a regulator with a constant output voltage of 5V, a rated current of at least 200mA, and the lowest dropout voltage I could get in a TO-92 package to save on size (I will do a blog on IC packages someday). The standard 5V regulator that meets most of these criteria is the LM7805, but it has a 2V dropout voltage meaning that if the battery voltage drops below 7V the entire system will cease to function as originally intended. The LEDs would start to dim and most likely the timing would start to drift even further out of whack. On the other hand, low dropout regulators (LDOs) can keep drawing energy from the battery down to as little as 5.5V, which increases battery usability. You can see the comparison between the two in the annotated picture from my last post to the right.

After spending a few hours on FindChips, Octopart, and Digi-Key’s parametric search I came across a part I thought would do the job. I chose the LT1121CZ-5 from Linear Technology. The regulator has a dropout voltage of 0.4V and outputs a stable 5V signal with an input voltage up to 30V. It also sports a shutdown pin which can lower the quiescent current consumption from 30µA to 16 µA. The regulator is only rated up to 150mA, but after checking the maximum current the microcontroller would consume in my application I felt comfortable with that figure.

Another downside is that the regulator was about $2.60. LT has a reputation for making quality but expensive parts so I was not surprised the see the cost come out so high. While I know this does not sound like much, it is quite a lot to spend on a single component that doesn’t have any programmable intelligence. Still, I decided I was going to splurge on this part because it has some interesting properties that could be useful in future applications and it provides a stable output with only a single 33µF capacitor on the output. I also needed a 33µF capacitor for an LED driver I am working on so ordering this regulator did save me a little money on capacitors. After the part showed up, I did a quick test with my power supply to confirm that it worked the way I expected. You can see the results in the Figure above.

After I placed my order for this voltage regulator I decided to keep looking for something else that might have worked in its place and almost immediately found an equally matching part for far less money. The Microchip MCP1702 provides a 5V output with a dropout voltage around 0.1V at my loading conditions. It comes in a TO-92 package and operates with input voltages up to 10V (though the datasheet says it can go up to 13.2, roughly a 12V battery + float voltage). Since I only planned on using a 9V battery for this project, I figured the 10V limit would be enough even with the batteries inherent float voltage. Like the LT1121CZ-5, this regulator is stable with an output capacitance of 1µF to 22µF with higher values possible for electrolytic capacitors. The best feature of this other regulator…I was able to get it from Allied Electronics for about $0.48 – roughly 1/5th the cost of the LT1121CZ-5. I bought a bunch of these as well to use in throw away projects like this one. It definitely was not worth splurging on the extra special regulator when this one can do the job for a much lower price. I like putting in the effort to find the lowest cost solution even on one-off boards because it gets me in the right mindset for consumer product design. Look for the full schematic and the software in my next post.

Nov 20, 2011

Halloween Build Part 1: Exterior Design

This is my first real entry showing the build log on my Halloween display that has been the subject of several of my recent entries. I will be focusing on the form factor build in this entry – i.e. carving the Halloween pumpkins and building the bases. Since anyone who follows this blog knows that I secured some fake foam pumpkins from Oriental Trading last month, I am going to skip talking about those and focus on the aftermath.

STEP 1
My first step was obviously to carve the faces into each one of the pumpkins. Out of habit, I cut into the top of the pumpkin as if I needed to place a candle in the center. For anyone who might want to try something similar, I don’t think this is necessary and you will find you have fewer pieces to deal with if you avoid it. The faces I chose can be seen in one of my earlier posts, and as I explained they are a compilation of my ideas and various pieces I could find googling “Pumpkin carving faces”.


STEP 2
I mentioned in another post that I was looking for a way to diffuse the light effectively because my last attempt at this project was largely a bust. After about a week of searching craft stores and online retailers I came across some small storage containers at Michaels. They are made by ArtMinds, but good luck trying to find them online because I haven’t been able to find a link where you can buy them. You will just have to trust that Michaels sells them.

I made small incisions in the bottoms of each of the pumpkins and then gradually cut outward to form a circle such that the containers would slide inside. The containers are ridged on the upper lip, which helps keep them from falling into the pumpkin. I intentionally cut the holes smaller than the diameter of the container because it is made of flexible plastic and can squeeze into the cutout to form a tight fit without the need for adhesive.


STEP 3
I realized too late that I would need something to enclose my circuitry. My original plan was to manipulate the pumpkins into housing the electronics but as my design progressed it became apparent that wasn’t really an option. As a last second panic effort, I bought some cheap paper kids bowls from Giant and painted them black (pictured) so it would be hard to see the bases at night. The idea was to have the LEDs protrude out the top of the bowls and into the storage containers, which would diffuse the light evenly inside each faux gourd.

















STEP 4
I used an Exacto knife to cut holes into the newly painted bowls.  From there I sort of awkwardly positioned the circuit boards so that the LEDs would be oriented how I wanted them. The battery was secured to the bowl using a nut and machine screw combination I had left over from another project. The 9V battery holders from Radio Shack worked pretty well in this application. There is a small hole in the back that allows you to feed through a machine screw. My full BOM will show the exact parts I used for future reference. I included a picture of the underside of the base to the right. You can see how everything is just sort of floating and smashed together. I added a switch to each of the bases because I pretty much didn't care about creating synced animations anymore at that point.



All in all that was the entire form factor build for this project. I want to make some substantial improvements to the design of the base to make it more solid. Right now the design is a last second kludge ball that I managed to throw together before dark on Halloween. I may keep one around to serve as a reminder that no detail can ever be assumed trivial. I didn’t put enough time into the total project design and it burned me this once. This once.

Nov 13, 2011

Halloween Results

The human mind has an incredible ability to rationalize a person’s own shortcomings. It’s only been a few days since my Halloween project was supposed to go live and I have already managed to convince myself that it wasn’t a total failure. I have always supported failure in engineering because most often better ideas and a firmer understanding are born from your shattered dreams. Still, in this instance I had high hopes for exploring new areas of microcontrollers and wireless communications. Instead, I ended up with the video you can see below.


Effectively, I created a series of blinking lights with some pumpkins on top. Was this the end result I was seeking? Yes, in a way. But instead of taking you through my thought process and throwing out some buzzwords to make myself feel better, I thought it would be better to show you how easily you can ignore total failure.

Original Thought: You didn’t get the ADC to work, implement dynamic timing adjustments, or get the microcontrollers to communicate wirelessly.
Rationalized Thought: I couldn’t get the watchdog timer working. I really had no chance to begin with.

Original: What does that say about your abilities that you couldn’t even get the watchdog timer working.
Rationalized: The requirements were too strict. I doubt many others in my positions would be able to get something working so quickly.

Original: You set the requirements for your own project.
Rationalized:

In all seriousness, I did pick up a few tricks doing this project that I can use going forward. I got some exposure to the new Microchip IDE, MPLABX. I figured out how to set pins in C using the free HI-TECH C compiler and the new (or what seem to be new to me) header files.

Nov 4, 2011

Instruction Construction

Instructables is one of the best sites on the web for posting your home projects. For those unfamiliar, people submit small instruction manuals on how they built their projects and those are then posted under the appropriate category on the main site. You can submit anything from recipes, to costume designs, to home electronics rigs. Even better, they often host contests for people who submit the best projects given the contest scenario (holiday themed, using a specific medium/material, geekiest, etc.).

The downside to sites like Instructables is that there is no standard template for submitting your project and people are mostly free to include whatever they want. Several of the projects I have been interested in ended up being extremely lacking in the actual instruction part. Many people don’t bother to post their complete bill-of-materials (BOM) with a description of where you can find the parts or post a schematic for you to follow. It can get frustrating.

At one time I considered submitting my pumpkin display to Instructables’ Halloween contest, but given what my final product turned out to be I didn’t think it was worthy. Instead, I am going to post my build log across a few separate entries on this blog. I have decided to take a backwards approach by showing you what the final project looked like and then showing how I went about assembling everything. I will try to post as many pictures as I can for the visual learners out there. However, I first want to encourage you to go back and check the posts I did about my original idea so you can see just how far away I ended up from that original plan. Plus, I will be assuming in future posts that anyone reading them will have some context concerning what I was trying to build.

In the coming days you can expect to see a few different entries related to my project. The first will go into detail on how I created the form factor (i.e. carved the pumpkins and created the bases). Next, I will show the circuitry I used including the theory of operation and the construction of the circuit boards as well as the code I used to run the animations – I may split these up into a few posts. Last up I will show my BOM with some advice on recreating the project and areas for improvement.

Maybe next Halloween I will try to improve on my current designs, but until then…screw Flanders.

Nov 1, 2011

Comical Digi-Key Packaging

As I mentioned in a previous post, I ordered some parts from Digi-Key to build my Halloween display and they came in last Friday. Digi-Key has developed a reputation for shipping small parts in absurd packages so I figured I would take this opportunity to throw fuel on the fire. Not much more than some photo documentation in this post.

When you think about it, the box really did need to be that big because it had to hold the tube of simple switcher ICs.












That little black cluster of chips on the left clearly warranted a packing tube five times its length.


Just for scale I put a 2032 coin cell battery next to a close-up of the chips. The coin cell is about 20mm wide (or about 0.8 inches.)