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 support@ccsinfo.com

capacitive touch sensing configuration in CCS compiler

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



Joined: 03 Oct 2016
Posts: 5

View user's profile Send private message

capacitive touch sensing configuration in CCS compiler
PostPosted: Mon Oct 03, 2016 6:50 am     Reply with quote

Hi guys. I'm using the built-in touchpad function of the ccs compiler. My projects also runs as i want on my PIC16F1947.
Now I got a very strange issue. When I add a 5mm glass, touch keys do not work properly under the glass. I change the threshold, range, scan time but problem not solved and my touch keys work random. Does anybody know how I can fix this?


Last edited by saye70 on Mon Oct 03, 2016 1:39 pm; edited 1 time in total
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Oct 03, 2016 7:59 am     Reply with quote

in general if you develop with direct touch or very thin film on the sensing pads -
putting a piece of glass SO THICK over the pads will change the delta-frequency
in the touch circuit by a FAR smaller ratio when you approach with finger meat.
than when you did not have thaa thick piece of glass over it.

And yes 5mm is pretty darned THICK for this application

i suggest you try the same experiment with a thin film sheet of mylar instead

That could easily be where you are in trouble. The frequency change of meat vs no meat may be beyond what you understand or have programmed .

whats your CODE ?
saye70



Joined: 03 Oct 2016
Posts: 5

View user's profile Send private message

PostPosted: Mon Oct 03, 2016 8:08 am     Reply with quote

asmboy wrote:
in general if you develop with direct touch or very thin film on the sensing pads -
putting a piece of glass SO THICK over the pads will change the delta-frequency
in the touch circuit by a FAR smaller ratio when you approach with finger meat.
than when you did not have thaa thick piece of glass over it.

And yes 5mm is pretty darned THICK for this application

i suggest you try the same experiment with a thin film sheet of mylar instead

That could easily be where you are in trouble. The frequency change of meat vs no meat may be beyond what you understand or have programmed .

whats your CODE ?

dear asmboy. thanks for your consideration.
I can not change this layer and it must be 5mm

my code is:
Code:

#include <16F1947.h>
//#fuses WDT
//#DEVICE  ADC=10
 __CONFIG(FCMEN_OFF,IESO_ON , CLKOUTEN_ON , BOREN_OFF  , CPD_OFF , CP_OFF , MCLRE_ON  , PWRTE_OFF , FOSC_INTOSC , LVP_ON  , BORV_25 , STVREN_OFF , PLLEN_OFF , VCAPEN_OFF , WRT_OFF);
#use delay(INTERNAL=16Mhz)
#use TOUCHPAD(scantime=80MS,RANGE=L,PIN_F0='C',PIN_A0='A',PIN_A1='B',PIN_F1='D')

#define led1    PIN_C2
#define led2   PIN_C3
#define led3    PIN_C4
#define led4   PIN_C5

char ctuch;
oid main()
{  //delay_ms(2000);
 
   setup_oscillator(OSC_16MHZ);
//setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
 //setup_timer_1( T1_CAPSENSE | T1_GATE );
   //TOUCHPAD_STATE(1);
   enable_interrupts(INT_TIMER0);
   //SETUP_DAC(DAC_VREF_VREF);
   setup_vref(VREF_ON | VREF_COMP_DAC_2v048);
 
   ENABLE_INTERRUPTS(GLOBAL);
   
   for(;;)
     {
         
         

   
         if(TOUCHPAD_HIT())
         { 
                 ctuch=TOUCHPAD_GETC();
                 
                 if(ctuch=='A')
                 {
                        output_low(led1);
                        output_high(led2);
                        output_high(led3);
                        output_high(led4);
                        delay_ms(100);
                 
                 }//end if ctouch=A
                 else if(ctuch=='B')
                 {
                   output_low(led2);
                   output_high(led1);
                        output_high(led3);
                        output_high(led4);
                        delay_ms(100);
                 
                 }//end if ctouch=B
                 else if(ctuch=='C')
                 {   
                        output_low(led3);
                        output_high(led2);
                        output_high(led1);
                        output_high(led4);
                                   delay_ms(100);
                } //end if ctouch=C
                else if(ctuch=='D')
                {
                       output_low(led4);
                       output_high(led2);
                        output_high(led3);
                        output_high(led1);
                        delay_ms(100);
                } //end if ctouch=D     
         }//end if tuchpadHIT
     }//for     
}//main
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Oct 03, 2016 8:26 am     Reply with quote

what compiler version ??

if i were you i would adjust your #use touchpad statement and see where
it gets you

Code:

include <16F1947.h>

__CONFIG(FCMEN_OFF,IESO_ON , CLKOUTEN_ON , BOREN_OFF , CPD_OFF , CP_OFF , MCLRE_ON , PWRTE_OFF , FOSC_INTOSC , LVP_ON , BORV_25 , STVREN_OFF , PLLEN_OFF , VCAPEN_OFF , WRT_OFF);
#use delay(INTERNAL=16Mhz)
#use TOUCHPAD(scantime=80MS,RANGE=L,PIN_F0='C',PIN_A0='A',PIN_A1='B',PIN_F1='D')

#define led1 PIN_C2
#define led2 PIN_C3
#define led3 PIN_C4
#define led4 PIN_C5

char ctuch;
void main()
{

setup_oscillator(OSC_16MHZ);

enable_interrupts(INT_TIMER0);

setup_vref(VREF_ON | VREF_COMP_DAC_2v048);

ENABLE_INTERRUPTS(GLOBAL);

for(;;)
{




if(TOUCHPAD_HIT())
{
ctuch=TOUCHPAD_GETC();

if(ctuch=='A')
{
output_low(led1);
output_high(led2);
output_high(led3);
output_high(led4);
delay_ms(100);

}//end if ctouch=A
else if(ctuch=='B')
{
output_low(led2);
output_high(led1);
output_high(led3);
output_high(led4);
delay_ms(100);

}//end if ctouch=B
else if(ctuch=='C')
{
output_low(led3);
output_high(led2);
output_high(led1);
output_high(led4);
delay_ms(100);
} //end if ctouch=C
else if(ctuch=='D')
{
output_low(led4);
output_high(led2);
output_high(led3);
output_high(led1);
delay_ms(100);
} //end if ctouch=D
}//end if tuchpadHIT
}//for
}//main
saye70



Joined: 03 Oct 2016
Posts: 5

View user's profile Send private message

PostPosted: Mon Oct 03, 2016 8:35 am     Reply with quote

asmboy wrote:
what compiler version ??

PCWHD V4.13
I try different conditions for #use touchpad, but the problem not fixed
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Oct 03, 2016 8:38 am     Reply with quote

4.13 ??? WTF there was no touch support in early V4
and i did not think headers for that 16f19xx family pic either

first -upgrade to ver 5.060 or later
then -
have you read and understood ?

http://www.lcis.com.tw/paper_store/paper_store/AN1102a-20147122224914.pdf
saye70



Joined: 03 Oct 2016
Posts: 5

View user's profile Send private message

PostPosted: Mon Oct 03, 2016 8:41 am     Reply with quote

asmboy wrote:
4.13 ??? WTF there was no touch support in early V4
and i did not think headers for that 16f19xx family pic either

first -upgrade to ver 5.060 or later
then -
have you read and understood ?

http://www.lcis.com.tw/paper_store/paper_store/AN1102a-20147122224914.pdf


But with this version my circuit work without glass.
Yes I read this document and understand the principles. but no any change happened.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Oct 03, 2016 9:21 am     Reply with quote

How big are your buttons?.

This is a critical parameter to the sensitivity of the pads, as is very careful design of the PCB. You are also going to need good structural rigidity between the board and the glass. If either can flex, the change will be bigger than the touch change. The glass needs to be very close to the PCB (remember air has a much lower relative permittivity than glass - about 5:1, so 5mm of glass is only equivalent to about 1mm of air - no problem at all, but if the glass is spaced much off the board, then 'problems'). This is why you will see designs that print the pads on the inside of the glass or have metal contacts carrying the pads to the glass.

I've got touch sensors working through over 10mm of plate glass. Biggest problem was I had to specify for the PCB company to _not_ water wash the PCB's. Modern PCB processing tend to use water and ultrasonics, rather than trichloroethylene to clean PCB's. Found that this resulted in unwanted moisture absorption into the boards, and higher trace capacitances. Instead they now use an alternative solvent to clean these boards.

The sensing is dependant on the _relative_ touch capacitance of the sensor and the capacitances on the board. The trace capacitance, pad capacitance and pin capacitance. If you reduce these latter sources, the sensitivity shoots up. You need to keep the trace length from the PIC to the electrode as small as possible, and preferably increase the gap between this an the ground pour around it. You may need to consider a hatched ground fill, rather than a solid ground on the layer below this trace.

I agree with Asmboy. I don't think there is any way that 4.013 would actually work. It is before V4 was actually a working compiler, let alone having working capacitive sense code. Something like 4.131, I might believe.

LVP_ON. Are you _sure_. This is not wanted for 99.9% of code, and may well cause operational problems unless the LVP pins have been correctly biased off. Use CCS standard fuse settings, rather than the __CONFIG line. This is provided only for compatibility with Microchip code, and I'm not sure these settings will be functioning correctly.

You can increase the sensitivity (but at an increased risk of accidental triggers), by reducing the threshold. So:
Code:

#USE TOUCHPAD (SCANTIME=80MS, THRESHOLD=4, RANGE=L, PIN_F0='C', PIN_A0='A', PIN_A1='B', PIN_F1='D')


The default is 6.

I think you may well find older compilers had this set lower. It normally needs to go up, to avoid triggers from other sources.
saye70



Joined: 03 Oct 2016
Posts: 5

View user's profile Send private message

PostPosted: Mon Oct 03, 2016 1:37 pm     Reply with quote

Thank you so much for your consideration. I will check these solutions and hope this will work.
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