The process of creating a circuit board using a micro-controller and a couple of relays seemed fairly straight forward. In fact, it still seems straight forward even though I have failed thus far in creating the board. In my first attempt, I purchased an Arduino Pro Mini from Sparkfun, a simple prototyping board from Radio Shack, and various electronic components to be able to read the state of the buttons and limit switches. The Mini has 12 holes on each side in which I soldered male header pins. I made a little socket in which to plug the mini by soldering female headers on the prototyping board.
The garage door opener motor is controlled by switching power on one of two wires. Which wire you switch determines the direction the motor runs and therefore the direction the door moves. I purchased one relay for each wire, but I wanted to make sure that I couldn't activate them both at the same time. The relays are easy to control with an output pin of an Arduino, but rather than wiring a pin to each relay, I decided to put a logic chip in between to make sure that only one relay could be active at a time. I used pin 13 to indicate whether or not I wanted the motor to be active (HIGH means running, LOW means stopped). I then used pin 12 to determine the direction the motor should run (HIGH means up, LOW means down). Pins 12 and 13 are connected to an AND gate with the output of the gate driving the relay that makes the door go up. Pin 13 is also connected to a second AND gate, but I needed to invert the value of Pin 12 before connecting it to the other input. The output of that gate drives the relay that makes the door go down.
I'll stop here to admit that I'm not an EE major, I'm a computer science major. I'm good at programming. Things that may be obvious to an EE major, aren't obvious to me until I screw up good! I purchased a logic chip in a 14 pin DIP package, but I didn't want to waste the board space on an inverter chip, so I contrived a way to use a transistor as an inverter. Again this seems straight forward, but there was some fundamental knowledge that just isn't there for me. Even after I figured it out, I managed to make the mistake again! Here's the diagram of what I did:
The top line in the picture is Pin 12, the one under is Pin 13. The idea was that when Pin 12 was high, the transistor would ground input 6. When Pin 12 was low, the transistor would not connect the collector and emitter and the input on the gate would be high. Unfortunately, I discovered that when Pin 12 was high, all of its current was grounded through the transistor and input pin 2 was pulled to ground. The top AND gate would never yield a high value. Of course, I'm getting ahead of myself because I didn't actually discover this until the second version of the board!The first problem I had was that I couldn't get my program to upload to the Mini. I built a simple little programming board that contained the same female header that I had built on the prototype board. The "socket" connected the appropriate pins of the Mini to the programming header. Unfortunately, the mini wouldn't take the program. I still have no idea why. So I changed gears and decided to use an Arduino Pro that I had purchased a while back.
The next thing that I have to admit is that I make stupid mistakes while I'm soldering up wires and I have to desolder and re-solder too often. The cheap prototyping boards from Radio Shack don't stand up too well to this and the copper foil they use to connect holes peels up. I had already moved the power supply portion of the board to a different area because I had destroyed a whole section. Most of what I had done would have to be moved now because the foot print of the Arduino Pro is so much bigger than the Mini (as the name would suggest). So I started a new board.
As an example of making stupid mistakes, I didn't wire the 7408 from a diagram but from trying to match the wires on the previous board. However I screwed it up, I managed to swap one of the input pins and one of the output pins on each gate. And wouldn't you know it, the relays didn't work! I actually managed to desolder the wires and wire it up correctly without doing too much damage to the board. It was then that I discovered the problem with the transistor. By the time I got that straightened out, I was having problems with the board resetting and my connectors kept coming apart.
So I ordered polarized connectors that would clip when connected, desoldered the old connectors and soldered in the new ones. The board looked pretty nice from the top...the bottom showed off how many mistakes I had made:
At this point I decided to take the learning experience one step further. I would design my own Arduino shield using Eagle and have a PCB custom made for my project. I'll relate my experience with that in part 2!
0 comments:
Post a Comment