|
|
View previous topic :: View next topic |
Author |
Message |
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
can not use #touchpad with pic 24FJ256GB106 |
Posted: Thu Jul 23, 2015 9:32 am |
|
|
I do real board and i decide test module CTMU of PIC24F first, I use it to make a capacitor touch pad with #use touchpad in ccs v5.048 but in real board, it always receive garbage in LCD. I use example code in ccs help, i don't know whether my real board is correct.
this is schematic:
this is code
Code: |
#include <24FJ256GB106.h>
#fuses HS,NOWDT,NOPROTECT,ICSP1
#use delay(crystal=32M)
#USE TOUCHPAD(THRESHOLD=5,PIN_b0='A', PIN_b1='B',PIN_b2='C', PIN_b3='D')
#include <flex_lcd.c>
void main()
{
unsigned char c;
lcd_init();
enable_interrupts(GLOBAL);
while(true)
{
if (TOUCHPAD_HIT())
{
c = TOUCHPAD_GETC();
}
lcd_gotoxy(1,1);
printf(lcd_putc,"%c",c);
}
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Thu Jul 23, 2015 10:23 am |
|
|
The touchpad needs to be calibrated.
Problem is that the values needed to actually sense a key, depend on the layout of your board. This is why the CCS library has the 'touchpad_state' function.
Look at this in the manual, you will see one way of using it.
With 'luck', you can sometimes get away without this, which is why the default code doesn't show it, but for 99% of boards it is needed.....
As a 'comment', the print really wants to be inside the 'if' otherwise it is going to keep printing the same key, when one isn't seen. |
|
|
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
|
Posted: Thu Jul 23, 2015 11:12 am |
|
|
Where i can get a manual of ccs,can you give me link to dowload please, and "99% real board need it" i don't understand ,what is "it"??? Onething more ,i see in an1250 of microchip ,it need at timer 1 and adc so should i add setup_timer1(t1 internal | t1 div by 1) and setup adc(),set adc (all analog). I was try on all of it ,but nothing appear in lcd,... |
|
|
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
|
Posted: Thu Jul 23, 2015 11:24 am |
|
|
I was dowload ccs manual and see it,it look like a help in ccs ,i don't know where can i find it and what thing i must find to resolve my problem?? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Thu Jul 23, 2015 11:38 am |
|
|
You are getting things crossed.
The CCS touchpad functions use the CSM, not an ADC (or CTMU). The scantime in the #use sets up the timers needed.
If your chip doesn't have a CSM (or CTMU), this function won't work.
There are multiple different ways of implementing a touchpad. The CCS code is for the system shown in AN1171. If you want to do it using an ADC, there is code here:
<http://www.ccsinfo.com/forum/viewtopic.php?t=45995&highlight=an1298>
The CSM measures capacitance by having the frequency of an oscillator change, and then the code reads this.
I've also posted a way of doing it with another module (for some of the PIC12's) in the code library. |
|
|
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
|
Posted: Thu Jul 23, 2015 8:49 pm |
|
|
But my pic just have a CTMU modul, so i need a #use touchpad for CTMU to implement touch pad because in ccs help says "This directive will tell the compiler to initialize and activate the Capacitive Sensing Module (CSM)or Charge Time Measurement Unit (CTMU) on the microcontroller" How can i use CTMU with #use touchpad in CCS , or #use touchpad not support for CTMU of PIC24F |
|
|
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
|
Posted: Thu Jul 23, 2015 9:51 pm |
|
|
oh amazing, today i try one more and i's run, with schematic and code i was post. Thank Ttelmah so much,thank for your help. everthing run fine just one thing, it's not sensitive, if i want tochpad more sensitive than and better, what will i do |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Fri Jul 24, 2015 2:29 am |
|
|
Design of the pads.
It really is the critical thing. Get AN3863 from Freescale. There are other similar documents from everybody involved in touchpads.
There are some very sophisticated 'tricks' you can do, to improve sensitivity, but beware that as sensitivity goes up, so does the tendency to pick up other things.
Use an 'X' pattern ground plane under the pad. Thing is that a big flat ground plane stops noise, but then gives a large capacitance, reducing sensitivity. A nice 'open' X, reduces the capacitance, while retaining most of the noise protection. Similarly an 'X' ground surround.
Remember that extra capacitance on the tracks 'to' the pad, reduce it's sensitivity. Short tracks to the controller, with large gaps, helps.
The capacitance seen from the pad, is seen _in parallel_ with all the other capacitances in this part of the system. If you have a pad capacitance change of 5pF, and the rest of the system has 25pF of capacitance, you see a change from 25 to 30pF (1.2*). However reduce the system capacitances to just 10pF, and you see a change from 10 to 15pF (1.5*). Much better. |
|
|
|
|
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
|