IMSlo
Newbie level 6
Microchip recently put out a PDF describing how to use only ADC for Capacitive Touch Sensing. It works on the voltage divider principle. I stumbled upon Cap Touch while looking for something else and became very interested in it.
My ultimate goal is to use thumb tacks stuck in a wooden board for my shop switches.
I now have this procedure working. It is written in JALv2. I will not try to learn assembly again.
The sensor I am using is a piece of aluminum foil about 1 1/2 square under 1/8" / 3mm Lexan.
The code works with this set up. It may or may not work with another type of sensor or even if the wire is lengthened. I have already tried with a thumb tack and it does not work.
I have a statement in my code that say "if measure < 175 then" meaning the sensor has been touched. The 175 is the problem. I want this number to adjust according to the capacitance in the sensor. I have a line of code that should do this but it does not work and is commented out. The line is Average =( (average * 15) + measure )/16). I know my code shows an 8 for the * I made that mistake when I put it back in for this discussion.
When I leave this line in the code the program the numbers go crazy and it locks down on touched with very small numbers.
I cant handle 10 bit math. Look at the line "measure = ADRESH + ADRESL. I get an 8 bit number from this probably left justified. I don't know what ADCON1 defaults to.
To sum all this up I would like to get the average thing working and maybe get 10 bit adc resolution.
I am attaching the following files,JAL, ASM, HEX, 01298A PDF and a picture of my breadboard setup.
My ultimate goal is to use thumb tacks stuck in a wooden board for my shop switches.
I now have this procedure working. It is written in JALv2. I will not try to learn assembly again.
The sensor I am using is a piece of aluminum foil about 1 1/2 square under 1/8" / 3mm Lexan.
The code works with this set up. It may or may not work with another type of sensor or even if the wire is lengthened. I have already tried with a thumb tack and it does not work.
I have a statement in my code that say "if measure < 175 then" meaning the sensor has been touched. The 175 is the problem. I want this number to adjust according to the capacitance in the sensor. I have a line of code that should do this but it does not work and is commented out. The line is Average =( (average * 15) + measure )/16). I know my code shows an 8 for the * I made that mistake when I put it back in for this discussion.
When I leave this line in the code the program the numbers go crazy and it locks down on touched with very small numbers.
I cant handle 10 bit math. Look at the line "measure = ADRESH + ADRESL. I get an 8 bit number from this probably left justified. I don't know what ADCON1 defaults to.
To sum all this up I would like to get the average thing working and maybe get 10 bit adc resolution.
I am attaching the following files,JAL, ASM, HEX, 01298A PDF and a picture of my breadboard setup.