View previous topic :: View next topic |
Author |
Message |
igelkotze
Joined: 15 Dec 2015 Posts: 12
|
|
Posted: Wed Dec 23, 2015 12:10 pm |
|
|
Well its not very complicated...
The LEDs are in ports 2 (RA0) and 3 (RA1) with a 470 ohm resistor,
my touchpads are just cables in ports 21-24 (RB0-RB3) and
VDD (port 20) is connected to my pickit2 Programmer... And VDD of course...
Thats everything ;) |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Dec 23, 2015 12:27 pm |
|
|
The devil can be in the details - like capacitive decoupling on power lines - OR- built on a plug board and so much more that can escape easy notice can be a problem
Circuit quality is ESPECIALLY important for touch due to the sensitive ultra low current nature of the process.
And of course to many of us have spent too much effort on SIMULATIONS.
SO a picture of the actual device and a schematic would go a long way to allay those concerns. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Dec 23, 2015 4:22 pm |
|
|
Another note:
when i compile Mr. T's latest program, with 5.042
the first config word looks OK , BUT
the second config word FUSE is set to 0x3FFF
with the notation"NOVCAP"
this means that VCAPEN0, VCAPEN1 bits are both set =1
which the data sheet cautions:
"11 = All VCAP functions are disabled (not recommended)"
BUT i am forced to consider that #USE touchpad may have altered this on purpose. Without a detailed exam of unsupressed .ASM for the program, it is not easy to tell what should be happening. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 23, 2015 6:22 pm |
|
|
Right, but you could just comment out the #use library and functions and
see what it does. With vs. 5.051, I get the 2nd config word as:
0030 NOVCAP
This occurs with or without the library. If I put in an actual fuse, such as
VCAP_A0, then it appears in the Config bits down at the end of the .LST file. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Thu Dec 24, 2015 3:27 am |
|
|
If you look, I used the fuses being used in the original code, and said that I had not tested, since I didn't have a chip.
Now the VCAP stuff is definitely wrong. This setting would be 'right', if you were using the LF chip, and running therefore without the voltage regulator. With the F chip, one pin has to be 'lost', and an external capacitor connected to this. The pins that can be used are RA0, RA5, or RA6. These are selected in the fuses with VCAP_A0, VCAP_A5, or VCAP_A6, and the pin chosen needs a 0.1uF capacitor to ground. The chip is not going to run correctly without this.
As PCM_Programmer says, if you set this up, then the correct fuse is set. Without this all chip operation is going to be 'dubious'....
Quote from the data sheet:
"An external capacitor must be connected to one of the available
VCAP pins to stabilize the regulator."
Note "must".... |
|
|
igelkotze
Joined: 15 Dec 2015 Posts: 12
|
|
Posted: Thu Dec 24, 2015 8:53 am |
|
|
Hi here are the Fotos of my plug board and my diamex pic Programmer (it is equal the pickit2)
Merry Christmas! |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Dec 24, 2015 9:01 am |
|
|
Using a plug board such as yours adds inter-pin capacitance.
I have several in my junk box.
A few minutes ago - i measured the value using an SRI SR-720
FYI: the plug board adds 8.5pf between every adjacent pin.
While this may not be enough to affect cap=touch - i would not use an HF crystal on such a fixture.
also - you need to add the correct fuses as MR. T mentioned - AND use the right PINS as the data sheet calls out. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Dec 25, 2015 8:05 am |
|
|
One great thing about plugboards is that if your project works on it then it WILL work on a PCB!
I've used quality ones for 30 years and never had a real issue though these daya you can but a 'protoboard' style PCB for not much more.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Fri Dec 25, 2015 1:44 pm |
|
|
The old comment applies about the need for decoupling adjacent to the PIC.... |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
|
igelkotze
Joined: 15 Dec 2015 Posts: 12
|
|
Posted: Sat Dec 26, 2015 12:07 pm |
|
|
Hi... Sorry for my late reply. The holidays are/were really stressful
I don't have a 0,1uf capacitor but i will buy one in monday and i will have a look in the datasheet to use the right output Pins... I hope it solves my problems... Thank you!
But i have a question about that... Why did it work that good with the "touchpad_hit"-Version without the capacitor? Was it coincidence?
Happy Holidays! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Sat Dec 26, 2015 12:46 pm |
|
|
Buy several.
There should be one adjacent to the PIC as well as the one to the Vcap pin. These are things that every regular user here will have by the dozen, not singly. |
|
|
igelkotze
Joined: 15 Dec 2015 Posts: 12
|
|
Posted: Thu Dec 31, 2015 6:57 am |
|
|
Ok... i bought some capacitors, but the problem stays the same...
Yesterday i tried something with a friend (two brains are better than one). This code is working... with some funny "errors":
Code: | #include <16f726.h>
#fuses NOWDT,NOPROTECT,MCLR,VCAP_A0
#use delay (INTERNAL=4M)
#use TOUCHPAD (Range=H,scantime=32ms,threshold=95,PIN_B0='A',PIN_B1='B')//,PIN_B2='C',PIN_B3='D')
#define KEYS 4
int16 touch_init[KEYS]; //global array for initial state
#define THRESHOLD 6 //threshold for the raw data
#define LED1 PIN_A1
#define LED2 PIN_A2
#define KEYA 1
#define KEYB 3
void main(void)
{
int8 ctr;
TOUCHPAD_STATE(1);
enable_interrupts(GLOBAL);
delay_ms(300);
//now store the initial values
for (ctr=0;ctr<KEYS;ctr++)
touch_init[ctr]=TOUCHDATA[ctr];
TOUCHPAD_STATE(2);
output_high(LED1);
output_high(LED2);
delay_ms(500);
output_low(LED1);
output_low(LED2);
while(TRUE)
{
delay_ms(32); //allow touch to rescan
if (TOUCHDATA[KEYA]>touch_init[KEYA]) {
output_low(LED1);
} else {
output_high(LED1);
}
if (TOUCHDATA[KEYB]>touch_init[KEYB]) {
output_low(LED2);
} else {
output_high(LED2);
}
}
} |
There are some things that need to be changed:
I think i need to convert TOUCHDATA to INT8... Because my Pad "A" is "1" in the array not "0", and my Pad "B" is "3" in the array... but how can i do that?
THRESHOLD has no effect... but the funny thing is, that i really need to touch the cable to light up the led... (If i am right the led's should light up much earlier, because i am only saying "bigger")
and i don't know why, but if i am writing Code: | if (TOUCHDATA[KEYA]>touch_init[KEYA]) {
output_high(LED1);
} else {
output_low(LED1);
}
|
instead of Code: | if (TOUCHDATA[KEYA]>touch_init[KEYA]) {
output_low(LED1);
} else {
output_high(LED1);
}
|
the led is on and if i touch the button it goes off??? If i am using the second version it behaves like it should!
I hope you understand what i am trying to say... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Thu Dec 31, 2015 8:16 am |
|
|
Why, why, why are you not using the touchpad status version?.
Understand, the direct data version, was a 'bodge' to handle old compilers which did not generate the status for you. Yours appears to generate the status, so use it. However you will have to turn the threshold way down, in view of your lack of sensitivity.
The data is meant to be held in an int16 array. Bytes 0, and 1, are the entry for the first pad, bytes 2 & 3 are the entry for the second pad etc.. Now, this depends (again) on how your particular compiler behaves. On the original thread I pointed you to, on a much older compiler, the poster found that the data was being returned as int8. However I've checked on current compilers and the data is now int16 (agrees with the manual).
Try changing the charge current to a lower value (RANGE=M). The high current range requires quite a large change in capacitance. The actual change you get, is all down to the design of the pad. Do a search on "touchpad design". You will find a lot of application notes about the pad design. I'd suspect your layout is resulting in a high initial capacitance, and a small change. Hence very poor sensitivity. You need to think about how your board/pads are designed to improve this. |
|
|
igelkotze
Joined: 15 Dec 2015 Posts: 12
|
|
Posted: Tue Jan 05, 2016 9:53 am |
|
|
Its me again!
This is only a prototype... I want to make my own SPS light-switches. They always habe 2 functions... If i press the pad for a short time the light goes on or off, if i press it for a long time i can dim the light.
I found a problem with in my code... The 2 touchpad-states were a problem... Now i only have one with state 2... It works perfect, except the threshold-function! So i think i need to make it by my own...
Is it possible to use the threshold i choose in use_touchpad? If not, how would you solve the problem?
Thank you!
Clemens |
|
|
|