- Cheap Trimpot, ohm rating doesn't matter as long as it goes from zero resistance to pretty much a short
- LM7805 -- Linear regulator
- Power supply for the microcontroller, needs to have around 300 mA of current.
- Power supply for solenoid, needs about an amp of current and roughly 18V give or take
- Pull type solenoid
- 47 uF electrolytic capacitor, to clean up the power signal
- Dual seven segment display -- pinout
- NPN Transistor
- Electromagnetic Relay
- Crystal Oscillator(I used 10 MHZ, but it doesn't matter)
- PIC18F4520, could be any PIC with enough IO, this is just what I started with.
Below is the basic schematic. One thing to note is constant power is given to light up a C(For closed) on the second display, and one of the output pins on the pic is shorted to several to create the O(For open) when needed.
The circuit was quite easy, although I did have to plus up my microcontroller power supply with a 9V, to get enough current to drive the relay(I originally had a smaller display that broke, and adding the larger one sucked just enough amps to stop the relay from reliably switching).
The code for the PIC is in MCC18 and was compiled in MPLab. Source code can be downloaded here. Also the hex file for PIC18F4520 is here.
It's a pretty simple analog to digital conversion, then chop off all but the upper bits to get the proper hex value. It uses a separate thread to monitor how long the number was held for. One issue that took me forever to debug is the conversion takes several cycles and the number you are storing to has no definite value at that time. Meaning if another thread interrupts in the middle and tries to read that value it will get garbage. This is easily mitigated with a temporary variable being used during the conversion.
Soldering it up was hassle free, although I had a lot of wires that were required. 2 Power supplies to the control box, then 4 wires of power to the solenoid and microcontroller, 9 wires from the microcontoller to the control box for the display, and then a phone cord was used to hook up the trim pot to the microcontroller. If I had been willing to, it would have been *much* nicer to have embedded everything into the door, control box and all, so there were only the power wires.
Picture of the spaghetti wiring:
Rehashed video from an earlier post of the electronics running(Note: I'm manipulating a potentiometer offscreen to scroll through the numbers):