Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a "touch" library ?
07-01-2014, 07:49 AM,
#1
a "touch" library ?
Hello !

I'm working on a (simple) library to get easy touch sensing on recents (26J50 and 47J53) PIC (using CTMU).

I've attached a first try (a single sktech for now, to make tests easier).

There is still a lot of improvements to do, in particular in the (auto)calibration process and it was only tested on 47J53A. It handles, for now, only singles sensors (no sliders or matrix touchpads).

I'm interested in any feedback : useability, library API, stability, etc.

Ajaborsk


Attached Files
.pde   touch_test.pde (Size: 8.48 KB / Downloads: 6)
Reply
07-01-2014, 10:54 AM,
#2
RE: a "touch" library ?
I've also started something sometime ago.
Please see if it can be useful for you :

.c   ctmu.c (Size: 12.71 KB / Downloads: 11)

I used it so (without pdl file) :

Code:
#include "ctmu.c"

void setup()
{
    pinMode(USERLED, OUTPUT);    
}

void loop()
{
    /// CAPACITANCE MEASUREMENT

    float C;
    
    C = 1000*CTMU_getCapacitance(0);
    CDC.printf("C=%f\n\r", C);

    /// CAPACITIVE TOUCH SWITCH

    if (CTMU_isPressed(0))
        digitalWrite(USERLED, HIGH);
    else
        digitalWrite(USERLED, LOW);
}
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
08-01-2014, 09:16 AM,
#3
RE: a "touch" library ?
Thanks for the code,

I was not (yet) able to compile it for my 47J53A, but I used some parts to improve my functions (on the ADC part).

Therefore, my objective is slighly different : I don't want to make a complete CTMU layer (for now) but a "user friendly" touch library that could be used by beginners or programmers whom don't know (or don't want to know) about current generators, capacity and charging delay (in the same way the analogWrite() function put the PWM stuff in the background). Just wire, call 'autocalibrate()' and 'touched()' without parameters and "Look : It works !".

Ideally, this lib should be based on a full/good CTMU lib, but I'm not sure it's so easy...

I'm working on multiple touches (pads) and more denoising processing (Microchip has very good applications notes on these subjects).

ajaborsk
Reply
09-12-2015, 11:01 PM,
#4
RE: a "touch" library ?
(07-01-2014, 10:54 AM)regis Wrote: I've also started something sometime ago.
Please see if it can be useful for you :


I used it so (without pdl file) :


Code:
#include "ctmu.c"

void setup()
{
   pinMode(USERLED, OUTPUT);    
}

void loop()
{
   /// CAPACITANCE MEASUREMENT

   float C;
   
   C = 1000*CTMU_getCapacitance(0);
   CDC.printf("C=%f\n\r", C);

   /// CAPACITIVE TOUCH SWITCH

   if (CTMU_isPressed(0))
       digitalWrite(USERLED, HIGH);
   else
       digitalWrite(USERLED, LOW);
}

I used your code but when i  put compile send me a error.
[OUT] ERROR: 30: #error 'Your proc. has no built-in CTMU module'

[OUT] 37: No such file or directory
[OUT]

how i can  repair?
Reply
09-12-2015, 11:39 PM, (This post was last modified: 09-12-2015, 11:48 PM by gtcbreizh.)
#5
RE: a "touch" library ?
What 8bit-microcontroller do you use ? Some microcontrollers have no ctmu !
Look at this in ctmu.c file which controls your compilation
#if !defined(__18f25k50) && !defined(__18f45k50) && \
!defined(__18f26j50) && !defined(__18f46j50) && \
!defined(__18f26j53) && !defined(__18f46j53) && \
!defined(__18f27j53) && !defined(__18f47j53)

#error "Your proc. has no built-in CTMU module"

#endif
Therefore 18f2550 or 18f4550 have no ctmu !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)