After finishing up research on the sensor, I moved onto prototyping a control circuit that would interface it with the motherboard. For this particular board, the system power state could be indicated in two ways. The default is to flash the power indicator while in sleep and have it solid while awake. The other is to have a bicolour LED connected and the board switches the two pins between ground and high depending on the state. I have covered these indicator methods in more detail in my
Switch research thread along with ways of interfacing with them.
For this board, I chose the bicolour LED approach since I didn't have to mess around with an ADC. The circuit that interfaces with it is very simple:
The LED is connected through two diodes to two of the micro controller's input pins. If the top pin is high, the bottom pin will be grounded and vice versa. The resistors are there so the pins don't float when the machine is switched off. Again, this is covered in more detail in the dedicated thread.
My original plan was to use an attiny9 to just have a boardless solution. The tiny9 is a minuscule SOT23-6 package so I could just solder it in line with the cables and heat shrink around it. However I acted too hastily without doing enough research and found that this wave of tiny's used a new TPI programming protocol for which I didn't have a suitable programmer. It wasn't a huge loss since they were only about 50c a piece but it could have been a lot worse with a more expensive part. Do your research people. So anyway, I went for the ATMEGA328-AU instead since I had a 328p Arduino lying around that I could prototype on while waiting for the part.
The C source along with the compiled hex is attached at the end of this post. Make sure if you're using the same micro, to set the fuses so the internal oscillator is running at 8 MHz without CLK/8. It runs at 1MHz factory default. If you're using a different micro I suggest you just take the exponential function in the #define and set the timings up yourself. I was going to have the level update rate synced to a second internal timer but I got lazy and just used delay instead. Sloppy programming I know, but I have to wrap this project up and get back to more important things. The function has been scaled to output values for an 8-bit output compare value. So if you want to use a 10-bit PWM instead scale it accordingly. i.e. 2^10/2^8 * f(x). Other than that, the function is the correct shape. Again, check out the other thread if you're curious as to how it was derived.
Poor man's programmer. (Pro tip: Don't do this)
Now, onto the circuit. The interface board is pretty bare bones with five components and a header. I've attached the
board layout as a high resolution .PNG. I would have uploaded an eagle schematic but I did this during a boring day at uni one a machine without eagle (but with autocad for some reason). There's also a solder-mask layer included which I intended to use, but my laminator wouldn't get hot enough to press it completely onto the finished board. So I just left it out.
The pcb blank is just regular single sided FR4 and the layout was printed onto high gsm matte paper. Don't even bother with regular copy paper. I've had some success with photo paper but it leaves a film like residue over the pattern that's much more laborious to remove. High gsm is your best bet.
The copper clad was aligned and passed multiple times though a laminator. You can use a clothes iron for the process as well. In fact it would probably work better. The laminator was just exploratory. As you can see it didn't turn out so well. Some parts had to be recovered with black ink.
To etch the board I used ammonium persulfate. There are a plethora of other etchants available, ferric chloride being the most popular; though it is more of a pain to dispose of. You can also use a 2:1 mixture of Hydrogen peroxide and HCL if your short on the real stuff. Ive used it many times successfully. Ammonium persulfate is the cleanest one to deal with and can be poured down the sink when you're done with it. The only down side is it has to remain heated so a hot plate, or a burner of some sort is a must.
Toward the end of the etching process, the solution turns a light blue due to the copper.
Here's the final board:
Again with the holes drilled in:
Components placed. The diodes are SOD123 packages and the resistors are imperial 0603. No reason why through hole can't be used; I just wanted a small footprint. The micro was preprogrammed before soldering but the attached layout has programming pads included in case things go south.
The board is designed to be case grounded so I brazed on two M3 nuts. Ugly weld but it'll be hidden.
And here's the sensor board connected.