Anyone have a simple code snipped for Cap sensing (CTMU?)

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
jasonaaronfox
Posts: 5
Joined: 19 Aug 2012 07:58

Anyone have a simple code snipped for Cap sensing (CTMU?)

#1 Post by jasonaaronfox » 30 Aug 2012 05:57

I have a hobby project I'm working on that involves cycling through sixteen cap sense buttons with a Texas instruments multiplexer. Allowing for only one pin to sense all sixteen inputs. I already have the code running for controlling the multiplexer.

The only problem I'm running into is the lack of an mtouch library in microc and the only examples I can find being morbidly complicated implementation.

I can work with pic16,18, or 24. Any example for any of those families will work.

I appreciate the input all!

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Anyone have a simple code snipped for Cap sensing (CTMU?

#2 Post by filip » 06 Sep 2012 15:04

Hi,

I'm afraid that we don't have this multiplexer at our office, so we are unable to help you,
but I'm sure that some of our user have experience regarding this.

Regards,
Filip.

jasonaaronfox
Posts: 5
Joined: 19 Aug 2012 07:58

Re: Anyone have a simple code snipped for Cap sensing (CTMU?

#3 Post by jasonaaronfox » 06 Sep 2012 16:36

filip wrote:Hi,

I'm afraid that we don't have this multiplexer at our office, so we are unable to help you,
but I'm sure that some of our user have experience regarding this.

Regards,
Filip.
You misunderstood me. i already have the cpde for the multiplexer written, i am only lookung for a simple example of capacitive touch on one channel, one pin.

johnt
Posts: 204
Joined: 01 Jul 2010 13:24

Re: Anyone have a simple code snipped for Cap sensing (CTMU?

#4 Post by johnt » 18 Sep 2012 12:27

Microchip do a tricks and tips application note that gives a way to do this sort of thing.
Essentially you use one GPIO pin to charge a cap and add a resistor chain with your
buttons along it. You then use a timer to time how long it takes to charge
the cap and this tells you which button was pressed. Their example suggests
16 buttons can be used on a pin - thats seems optimistic to me but maybe
the resolution can be that good.
and I dont know how it would apply to your capacitive panel though (I'd be interested in how you get on)
It may be possible to adapt it.
Their tricks and tips notes are well worth a read for anyone who hasn't seen them.
(search "tricks n tips" in their main site)

jasonaaronfox
Posts: 5
Joined: 19 Aug 2012 07:58

Re: Anyone have a simple code snipped for Cap sensing (CTMU?

#5 Post by jasonaaronfox » 18 Sep 2012 23:16

Well, my idea was to use a set of multiplexers that are all controlled from the same four pins using bcd. That way you can scan as many cap touch channels * 16 as you have available. I.E. four cap touch pins would each service 16 buttons through the multiplexing lattice; each giving a full resolution. I've got the CTMU code nearly completed, but the issue I ran into is that the compiler of my preference (mikroc) does not yet provide support for multiple adcon1 registers as seen in some pic18 and pic24 chipsets. I need to get down to the nitty gritty and use ASM to access the registers during the CTMU setup, but that's beyond my current coding capabilities.

johnt
Posts: 204
Joined: 01 Jul 2010 13:24

Re: Anyone have a simple code snipped for Cap sensing (CTMU?

#6 Post by johnt » 19 Sep 2012 11:18

Sorry I havn't used that module but perhaps there is an example on microchips site somewhere (most of their
examples tend to be in assembler) - you might get a response on their forum if no one else here has any ideas
but it doesn't seem to be very active.

edit
Looking for keypads myself I stumbled across AN1250 which describes a matrix touch keypad using the CTMU
with assembler code. Just thought it worth a mention here for anyone looking.

cuhnkedrik@gmail.com
Posts: 1
Joined: 28 Sep 2023 11:21

Re: Anyone have a simple code snipped for Cap sensing (CTMU?)

#7 Post by cuhnkedrik@gmail.com » 28 Sep 2023 11:23

My plan was to employ a bank of multiplexers that could be programmed with bcd and so operated from a single set of four pins. If you have 16 cap touch channels, you can scan all of them at once. For example, the multiplexing lattice might allow just four cap touch pins to service 16 buttons at full resolution. I've nearly finished writing the CTMU code, but I came into a snag when trying to take advantage of additional adcon1 registers present in some pic18 and pic24 chipsets, which my preferred compiler (mikroc) does not currently support. During the CTMU setup, I need to go down to the nitty gritty and access the registers through ASM, but that's beyond my present coding talents.

salmawisoky85@gmail.com
Posts: 1
Joined: 19 Dec 2023 09:06

Re: Anyone have a simple code snipped for Cap sensing (CTMU?)

#8 Post by salmawisoky85@gmail.com » 19 Dec 2023 09:08

Capacitive touch sensing involves detecting changes in capacitance when a conductive object, such as a finger, comes into proximity with a capacitive touch sensor. This change in capacitance can be measured and used to detect touch inputs.

Post Reply

Return to “mikroC PRO for PIC General”