![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
ricperez
Joined: 25 Apr 2007 Posts: 14
|
Will this program work on PIC18F66K80? |
Posted: Tue Oct 06, 2015 3:46 pm |
|
|
Hi.
I'm planning to use the indicated part to detect the activation of 8 capacitive buttons. I'm new to capsense and I wonder if the solution published by "robomaniac" sometime ago (which I copied below) will work with my part since the capsense units for 16LF722 and 18F66K80 are substantially different.
I'll appreciate any guidance to get started.
Thanks!
http://www.ccsinfo.com/forum/viewtopic.php?t=42107
http://www.ccsinfo.com/forum/viewtopic.php?t=37024&highlight=mtouch
Built-in mTouchâ„¢ capacitive sensing module
Code: |
#include <16lf722.h>
#fuses INTRC_IO,NOWDT,VCAP_A5
#use delay(INTERNAL=8Mhz)
#use rs232(baud=9600,rcv=PIN_C7,xmit=PIN_C6)
#use touchpad(scantime=32ms,threshold=6,PIN_B0='C',PIN_B1='5',PIN_B3='3')
#define GREEN_LED1 PIN_C2
#define GREEN_LED2 PIN_C3
//=========================
void main(void)
{
char c;
enable_interrupts(GLOBAL);
output_high(GREEN_LED1);
output_high(GREEN_LED2);
delay_ms(300);
output_low(GREEN_LED1);
output_low(GREEN_LED2);
while(1)
{
// TOUCHPAD_STATE(1); //calibrates, then enters normal state
if(touchpad_hit())
{
c=touchpad_getc();
putc(c);
if(c=='C')
output_toggle(GREEN_LED1);
if(c=='5')
output_toggle(GREEN_LED2);
}// end if
} // end while
}// main |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19447
|
|
Posted: Wed Oct 07, 2015 7:59 am |
|
|
Without writing code for your chip, and building a suitable capacitive keypad, we don't know.
Generally, the CCS functions do work, and do support the CTMU, as well as the CSM devices (this was added several dozen compiler versions ago).
The problem in the other thread you attached to the tail of, was that at that time (new chip), the support for the capacitive module had not been correctly added to the data base, and so I showed the poster how to do this themselves.
Different resources on the chip are required depending on the module (read the section entitled 'purpose' in the manual under the touchpad entry). Note also that 'SOURCETIME' only applies when using the CTMU.
Then also note that all of the capacitive sensing solutions do require calibration. The code you pointed to, incorrectly had this in the actual while loop, and then has it disabled. Basically you need to have this somewhere where it can be called when the values have drifted (they will as the weather changes etc.), and the calibration values then stored, otherwise 'long term' the results can become unreliable... |
|
![](templates/subSilver/images/spacer.gif) |
ricperez
Joined: 25 Apr 2007 Posts: 14
|
Your advice regarding use of CTMU |
Posted: Fri Oct 09, 2015 10:22 am |
|
|
Thanks Ttelmah, I'll follow your advice, though CTMU looks more "unfriendly" than CSM. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|