|
|
View previous topic :: View next topic |
Author |
Message |
saye70
Joined: 03 Oct 2016 Posts: 5
|
capacitive touch sensing configuration in CCS compiler |
Posted: Mon Oct 03, 2016 6:50 am |
|
|
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
|
|
Posted: Mon Oct 03, 2016 7:59 am |
|
|
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
|
|
Posted: Mon Oct 03, 2016 8:08 am |
|
|
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
|
|
Posted: Mon Oct 03, 2016 8:26 am |
|
|
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
|
|
Posted: Mon Oct 03, 2016 8:35 am |
|
|
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
|
|
|
saye70
Joined: 03 Oct 2016 Posts: 5
|
|
Posted: Mon Oct 03, 2016 8:41 am |
|
|
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: 19553
|
|
Posted: Mon Oct 03, 2016 9:21 am |
|
|
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
|
|
Posted: Mon Oct 03, 2016 1:37 pm |
|
|
Thank you so much for your consideration. I will check these solutions and hope this will work. |
|
|
|
|
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
|