I prototyped the circuit on a PCB instead of a breadboard
I made this circuit, because i faced several problems with the touch-pad for my keycode doorlock project. I tried many different touch-pad designs, yet all had problems. Designing a touch-pad is not a simple thing after all. There are several considerations to take into account, and as i found out (the hard way) experience is mostly needed. So, here is one touch-pad that works and you can use it as-is for your designs.
The fundamental rule when designing a touch-pad is this: Keep the wires as close as possible. When i designed my keycode doorlock project, i had only one PIC to handle everything including the touchpad. But the PIC was hidden inside the door, so i had long wires (about 10-15cm) to connect the pads with the PIC. That was a bad idea. So, i came to the conclusion that the touchpad must have a dedicated PIC on-board to minimize the wire length. And here is the circuit: (as always, click to maximize the picture)
The circuit is straight-forward. The 16F1937 has 16 inputs for the capacitance module, so you can use whichever input you want. R1 is 10 KOhms and R2 is 330 Ohms.
The Code (updated at 5/8/2011)
It happens... I totally forgot to upload the code, until someone asked me. Luckily i had the same code already uploaded for my keycode lock hack, in which i use this very same circuit. So:
I could not prototype this circuit on a breadboard, so, i had to make a PCB to test it. I usually do not upload PCBs because i do not know how to design an error-free PCB. But this time, i am pretty much sure that this PCB has no significant errors.
As you will notice, the PCB is double-sided. The top side has the pads and the grounding layer, and the bottom side has the PIC along with the connection pads. And as you are also about to notice, is that the pads for the PIC are SMD. BUT, it happens that i did not have this PIC in SMD package. So, i did something that i use to do, when i come across such situations. I bend the pins in such way that i can solder the DIL package as if it was SMD. It is not a very good technique, but it is simple and it works. After all, this is just a prototype to see if the PCB works. I will order some SMDs for future works.
This is the top side of the PCB
This is the bottom side of the PCB
The package of the PIC is DIL
I bended the pins to solder it as SMD
This is the PCB with the PIC soldered
I plan to cut or bend the unused pins...
The top side with the pads has also a grounding layer. For technical reasons i have this region filled with hatch pattern instead of being solid. A solid area will also work. Notice that at the bottom left corner, there is one hole. This hole connects the top and bottom grounding layers together with a wire. The hole is larger than actually needed, because i also used this hole to hold the PCB during etching.
At the bottom side i connected the ground pad to the grounding layer. This way, the top and bottom grounding layers are both connected with the ground of the power supply. Omitting the top grounding layer or leaving it unconnected (floating) will result in malfunction. The bottom grounding layer is not that important, but it is good to exist.
The supply ground is connected with the bottom side grounding layer
The top-side grounding layer is connected with he bottom side grounding layer via the bottom left hole
And here are the PAD I/Os
Insulating the touch-pads
I used thick tape to insulate and elevate the touch-pads. There are 3 reasons for this step: First, the idea of a touch keypad is that the touch-pad will be behind a cover with the buttons artwork. So, the pads must touch the artwork surface tightly, something that a double sided tape can do very good. Second, there must be a gap between the grounding layer and the artwork surface. The air has very small dielectric constant, and it will help to "separate" the touch buttons between each other, that is why the tape must be thick. And third, each touchpad on the top layer has a via to connect it with the bottom layer. This via has a thin layer of solder to hold the wire. So, the pads must be elevated a little bit otherwise they will not touch the artwork surface. Here is how i do it:
I use 1mm thick double-sided tape.
I cut rectangular pieces same size as the pads.
I did this for all 10 buttons.
Notice the gap between the PCB and a piece of wood
The next step is to remove the cover of the double-sided tape and stick the PCB on the artwork surface. I will do this when i finally decide what this artwork will be. In the meanwhile, i will test it as-is. The artwork that i will use has 2 layers. The first layer is a 4mm semi-transparent acrylic glass, and the second layer is a thin transparent film laser printout with the actual artwork printed on it:
And here is the artwork in gif format and original format
@Rogerio Francisco no this is the way it works. Higher-priority pads will block lower priority ones - this project does not have multitouch function. Always the highest priority pad will be sensed as a touch.
Hello Mr. Lazarids. I have been following your project for a long time, I could see that there must be some error in your code, because there are some pads to being touched and block the others and there are some pads that do not block other pads, doing that more than one pad is touched, there is something wrong with your code or even the code that you posted is not the same as you used for testing, thanks for listening and once again congratulations for your job.
sorry sir...pls i need the answers for all those questions especially for the MPLAB 8.8 version there is no case sensitive option for that thing.I have taken the screen shot for the proof so pls tell me how to send the image....
@sri harsha Then maybe you should move to MPLAB 8.8? I have the 8.8 and there is definitely the case sensitive option:
i am using the MP lab 8.66 version i did not see any change for the case sensitive option i this can you now atleast help me now so sort the error in your own code.....i dont have any solution other than using your code so pls help me......:(
@sri harsha you have to have one space for the include code, it cannot start from col 1. Check this first. Also, try to put your code not on the desktop, rather in a C:something directory, where the user name is not part of the directory
i am getting this error after compiling the code of yours..
(Error  C:Documents and SettingsAdministratorDesktopsencode.asm; 2.17 #include syntax error)....
what is the problem pls let ne know
Dear Giorgos, i´m trying to do a circuit with 16 buttons and bcd outuput like yors, but I could not understand his reasoning for the configuration of register CPSCON1 what values %u200B%u200Bshould I use to the other six capacitance inputs. Thanks.
Hi Giorgos! I tryed to rebuild your code but the MPLAB reported many erros i´d like to know if a could send to you the list of erros, becouse i would like to change your code to use the 16 buttons, how can i do to send you the list of errors?
@Juan M. Nuncio i usually do non modify circuits or projects. But i'm preparing this one for a kit. Hopefully it will be ready before the end of the world this year. Along with the kit i will release the code and the PCB design. It might take longer though.
This is exactly what I am looking for (somewhat). The two things I need that you don't address are:
1) serial communications to minimize the number of pins being used by the receiving circuit (i.e. just one pin for the data instead of 4 pins when you use BCD.
2) A "Data_Valid" signal on another pin to signal the using circuit that the data at the serial input to the circuit is ready to be read. This is useful in interrupt driven ISR instead of having to poll when data has changed from 0 to a valid BCD value.
I am a C programmer and will try to modify your ASM code to do what I need but it would be safer to have the original author do this.
Thanks so much for all your work and your excellent videos.
Hello, I'm Brazilian. and living in Brazil.
Their design and very interesting, is that you can send me your code.
I like to do something similar.
sorry I'm using an electronic translator.
my email is firstname.lastname@example.org
@Ion this has gone even further now... steps above challenge... now it is pure curiosity... i'm very curious to see what those people in microchip have done wrong. The cap sense module works like charm
It will be a big one. Before you start, visit this and you will find out by your self http://www.microchip.com/forums/f227.aspx
Also do a short Google on microchip pic18f mtouch projects
You will find out that they are thousands of pages about Pic18f, pages about mtouch - mostly emphasizing the feature, but curious ... no projects, or failed projects with peoples asking for help.
Good luck and let me know your achievements.
Keep in mind that any body can make it working, BUT the challenge is the sensing distance. Never saw one done yet.Everybody wants to have 2-3 mm plastic in top or touch buttons, the plastic cover of the box. Nobody did it yet.
Ctmu on Pic18F it is a big failure of Microchip
Even their development board does not works if the hand does not touch the pad
Microchip forum on CTMU it is full of complains and desperate peoples looking for solutions.
They are some smart guy which said, read the App. notes, but NOBODY proved a working reliable example.
Why do you believe Microchip released so many development software packages, but guess what, ONLY for pic16 and 24? 24 because has 12 bits A/D, and 16 for Cap sense.
If you want to be rich and famous, develop an application for 18F with CTMU. Hey 18F87J90 is what I use :)
Your site will be swamped by visitors to see it, a.k.a. tons of traffic and your You tube channel will go viral.
If you want to beat the challenge, try to do it, and believe me you will be famous.
Biggest problem that everybody complains is sensitivity. With yours I can keep the fingers 10 mm away and it will see it.
With 18F, you put 0.5 gap between finger and button and is gone.
Try it and you will see. Have fun and let me know if you can achieve something
@Giorgos Lazaridis Hello Giorgio,
did you have any luck to implement touch buttons with Pic18f series which have Mtouch module but not Cap sense like Pic16f ?
I am very interested to know, because on mu application i use a PIC18F87J90 for driving the LCD and real time clock and i do not have room to add a pic16F.
I build your examples for 4 and 10 buttons and works great, but for pic18f, following by book all the app notes, including the famous 1250, i just sens my finger when i touch or through thin piece of plastic. With 2 mm plastic it does not see it.
On microchip forum everybody complain about sensitivity, which is not the case on your example. I had to lower the sensitivity on your example because was too high
Please help if you have any piece of code or example
One more question.
I need in some conditions to press a combination of two buttons on the same time
It will work if i press two buttons ?
Lets, say i press I8 and I10 in the same time
What will be the result ?
If does not take two buttons in the same time, will be no problem because i can use an other one to represent the combination of the 2 PB simultaneous pressed
But will be nice to have the opportunity to press two buttons and get the combined result
@Rob Calala The chip that i use (PIC 16F1937) comes also in SMD. Check out here:
It is exactly the same chip, i just got them later. Yet this need programming too. You must find someone to upload the code to the chip after having it mounted on the board. You only need to give them the HEX file that i provide.
For other chips, i know that analog devices have some capacitance touch controllers but i have never use them.
First of all I do love your site.
I am working on designing a ON/Off Slider for various household automation control. Your design is exactly the same way I was going with mine, but alas I know nothing about software programing. So my system will be based on a PLC rather than a PC. The BCD output is exactly what I was looking for.
My question is if there is a SMT chip that would work based off of your code?
thanks, but I thought something simpler ...
unfortunately they are an amateur, I have the knowledge required for this type of changes ...
I successfully executed some of your wonderful projects, perhaps with minor changes, but this does not arrive.
if I can get some more help would be nice ..
sorry for my ignorance
is possible to turn on the switch button to turn on a relay at the touch of each key?
10 keys ... 10 relays
as in the project "PIC-Change Frequency Capacitance Touch Button," but with 10 or more switches on off
@ron Oh i see! This artwork :D. Ok, i was not going to upload it, because i supposed that people should make it better by themselves. But you are right: You may wanna design it yourself, but it will be better if you have the original artwork with the dimensions. So i will uploaded right now.
As for the forum, you can start posting your work in the "Your projects" section.
I am writing this under the "10 Buttons PIC Touch-Pad with BCD Output" comments section. Immediately above this is a picture of your hand holding the artwork... which you said you would post, "when you were ready"
There is nothing wrong with the forums, just so many headings and none said anything about replications of the touch pad. I could post a picture of my start if I knew where it belonged
hello can you help me?
I need to do a project that will utilizes the peripheral mtouch.
I'm going on my project utilizes the pic 16f727.
I need to send via the serial port of the PIC, the states of buttons (touch m). I'll utilizes two models of microcontrollers, a pic 16f727, this will take care of keys and serial communication to send the condition of the keys.
I'll utilizing the pic, 16f876A, this will get your serial port on the conditions in which they are the keys, either open or closed sent through, pic 16f727.
for serial communication between the two pics, I'll start using Zigbee.
you can help me develop this code?
@Rafael Marquez Plascencia Damn, how did i forgot to upload the code! I upload it right away. You can also find the code for this here:
well the reason of this is ask to you, can you help me?
im on the unaversity and im doing a similar proyec but i need 24 touch pads i think ill meke it on a matrix eny way.
im new on this tecnology can you show me your code? asm or c?
@pcb something wrong happens with IE when trying to read large gif files. If you try it with firefox it works perfectly fine. I will upload a zip version for windows users hopefully within coming week.