CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Using spring Capacitive Touch (CSM)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
GiG



Joined: 03 Sep 2021
Posts: 39

View user's profile Send private message

Using spring Capacitive Touch (CSM)
PostPosted: Wed Jan 19, 2022 3:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 19, 2022 7:18 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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