|
|
View previous topic :: View next topic |
Author |
Message |
GiG
Joined: 03 Sep 2021 Posts: 39
|
Using spring Capacitive Touch (CSM) |
Posted: Wed Jan 19, 2022 3:21 am |
|
|
Hello masters
I am launching 4 spring touches which is connected to PCB pad and using the CSM module of micro PIC 16f1939.
A few questions have puzzled me:
-Can I use the Timer0 and Timer1 when I am using this module, and what happens if I use it?
-The second question is with what software or hardware combination can I adjust the distance sensitivity of the touch sensor from the hand?
I changed RANGE to H but was not enough!
-the last: Is any hardware combination necessary to prevent noise Or is it enough to connect the pads directly to the micro alone?
Code: |
#include <16f1939.h>
#fuses NOWDT,NOPROTECT,NOLVP,NOMCLR,NOBROWNOUT,PUT
//#fuses NOWDT,NOPROTECT,MCLR
#use delay(internal=8000000)
#use TOUCHPAD (THRESHOLD=5,RANGE=H,SCANTIME=32MS,PIN_D0='A',PIN_D1='B',PIN_D2='C',PIN_D3='D')
#define LED1 PIN_A0
#define LED2 PIN_A1
void main(){
char c;
enable_interrupts(GLOBAL);
output_low(LED1);
output_low(LED2);
output_high(PIN_A3);
for (;;){
if (TOUCHPAD_HIT()){
c=TOUCHPAD_GETC();
if(c=='A'){
output_high(LED1);
delay_ms(500);
output_low(LED1);
delay_ms(500);
}
else if (c=='B'){
output_high(LED2);
delay_ms(500);
output_low(LED2);
delay_ms(500);
}
else if (c=='C'){
output_high(LED1);
output_high(LED2);
delay_ms(500);
output_low(LED1);
output_low(LED2);
delay_ms(500);
}
else if (c=='D'){
output_high(LED1);
delay_ms(100);
output_low(LED1);
output_high(LED2);
delay_ms(100);
output_low(LED2);
}
}
output_low(LED1);
output_low(LED2);
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Wed Jan 19, 2022 7:18 am |
|
|
Timer0, is used as the clock for the CPS module, and Timer1, to clock the
scan interval. If you change the settings for either, the CPS will stop
working. Use Timer2, 4 or 6 for anything else you want.
You can add a handler for Timer1 if you want, but this will be called
at the 32mSec interval.
Reducing the threshold will increase the sensitivity, but at a risk of more
accidental triggers. The biggest thing that changes sensitivity is the actual
design of the sense pads themselves. The design of the PCB under the base
of the spring. Guard rings, etc., affect the sensitivity enormously. There is
an enormous amount of stuff published online about this, but be prepared
for weeks of reading!...
How good the decoupling is around the PIC, and the general quality of
the supplies also enormously affects the overall reliability.
If the capacitance of the sensor itself is low, selecting 'H' may actually
take the oscillator frequency too high and sensitivity will then decline.
Do an empirical test with all three current settings and see which is best.
You can use test_mode to record the actual readings from the sensors for
this.
You are not using the calibration option. This massively improves the
performance of the touch sensor. Call touchpad_state(1); before using
the touchpad, with the hand well away from the sensor. This performs
the initial calibration of the sensor. Without this you will only get a fraction
of the real sensitivity. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|