This is a button a little bit smarter. (Microcontrollers and coffee, who doesn't like)
I i'm using it to fill my Coffeemaker with water. This way its a little bit more fun and i always get the same amount of water.
Its a simple project, and it's a good excuse to play with a PIC10F, one really small micro-controller. Code is written in C, a nice way to start with it.
It interfaces with the user blinking one led. so you can chose how much time the valve will open ( giving a good control on the amount of water). On the current firmware settings ( and with my valve) are for 1-2-3-4 cups of coffee ( i have a big cup, 300ml).
Just keep in mind that this button can be used for other uses.
The design (and problems that where solved) are on the next page, but if you just want to build this thing go to the building instructions page and download the project files.
Arthur Benemann 2011 Brazil
Step 1: In the Beginning...
This started as a weekend project, me and my girlfriend where making a coffee after lunch. Then a i had an idea, what about making a timed water valve so i can always make the same tasteful coffee, simple , a little useful, and easy to build.
As always a good pile of junk it's great for this, a big yellow button and a water valve from a washing machine ( both in the pictures below).
Things need to be as simple as possible so a small micro-controller would be perfect. Luckily i had some spare PIC10F206 on my parts box. A 100mA transformer and a 78L05 would do the power supply, and a relay to control the valve ( mains power).
All parts are set up, now the board.... ( next page)
Step 2: Schematic V1
I think i would get this one at the first try, i was so simple... ( jump this if you are not interested in failures)
Ok, it was just a question of putting building blocks together.
Power supply - -> Line - Trafo - Brige - Big Cap (100uF would do the job)- 78L05 - and done
Relay --> Resistor ( 1k will saturate the BC548) - 5v relay - protection diode (1n4004)
PIC --> Internal pull up for button - a simple LED - connection to the relay block
OK that was easy.I should work nothing wrong until where. ( schematic below).
Draw the board, tone transfer, soldering ( forwarding so we don't blow the surprise)
Now just add some codding ( explained on the next pages), and programing with temporary wiring.
Turn it up !!! And it doest work properly :(...
Next page for the solution...
Step 3: Board V1
It fail "sometimes"...
Man i hate when someones work is left like this. So lets investigate...
There is a picture below of the original prototype v1, it's full of wiring and solder because of the testing...
I tried a lot of things, powering it up from a external source, changing the relay supply to before the 78l05 regulator, putting huge caps on some points of the circuit....
The i worked, i had put a direct wiring for the Microcontroller supply. Currents running to the relay was messing up with the PIC power ( one oscilloscope would be great by now ).
The picture has some highlights on this.
Problem solved, let go to v2.0.
So what can be improved:
Relay power does't need to be regulated.
MCU position could be more away from mains voltage ( relay).
Don't use MRCL pin, just to be sure.
Just a question of redesigning the board ans schematic. Final result is below:
This solved the problems. :)
Step 5: Coding
I wrote a program to control the button, but it was not very friendly to the user ( i prefer not to comment it). Here i have to thak Jéssica for her idea for the program.
Button press is used to change between modes of operation,
n° press | Dose | LED
0 press - 0 off - off
1 press - 1 cup - slow blink
2 presses - 2 cups - blink
3 presses - 3 cups - fast blink
4 presses - 4 cups - on
5 presses --> return to off position
There is a timeout in "cups mode" if there isn't a press for 2-3s it go to filling mode. And stays there until the filling timeout, that deepens on the mode.
I implemented this with a state machine, and a debouncing routine.
The on time of each mode is defined in the top of "main.c" file, this control how much water goes to the coffeemaker. Experimenting with the valve in place give me this results ( and they don't seem to change too much because pressure is constant).
You must change this values to agree with your installation.
This is my first low end microcontroller project programed in C, i used to think that C would't be as easy to code as assembler, and the code would be so big. I was wrong C is great,fast development and relative small code.Code was compiled with hi-tech C compiler lite (free).
Step 6: Building It
The project was already tested, so if you want to build this is the way:
There are no special parts on this project, only the valve needs some attention. I use a washing machine valve to control the water.
Qty Part Value
1 Cap 100uf 25v
2 Cap 100nf 0805
1 Diode 1N4004
1 Res. 1k 0805
1 Res. 330R 0805
1 Transistor BC548
1 Relay 12v
1 LED RED 5mm
1 IC 78L05
1 IC MB6S
1 IC PIC10F204OT
1 Transformer 220v/6v+6v 100mA
Schematics and Board layout are on the projects files.
I use tonner transfer method. Source was compiled with MPLAB and Hi-tech litle.
Step 7: Wiring
Just follow the picture to do the wiring...
Step 8: The Ending
Just to finish a little movie of it working. ( sorry about the darkness, one of the kitchen lights broke just now).
I will post a better video tomorrow.
Enjoy your Coffee.