Dealing with Noisy/False reading touch sensing button

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
yoLo_
Posts: 9
Joined: Fri Mar 24, 2017 2:34 am

Dealing with Noisy/False reading touch sensing button

Post by yoLo_ » Fri Mar 24, 2017 3:38 am

I got this code here http://dpaste.com/24DDP4G, thanks to dhylands for his help
It is a simple code that does something when a push button is pressed and held for 3 seconds
any push button works fine except a touch sensing button:
https://learn.sparkfun.com/tutorials/at ... 1478358978
I'm using the one above.
At first i tried de-bouncing the push button with some help from the pydoc tutorial so there isn't any interference
with the 3 seconds countdown but it happens that I could not simply go ahead and press the push button as i pleased
because sometimes the "pressed" isn't detected and it gets even uglier with the touch sensing button
Anyways, as i mentioned, this code works great but touch sensing button is very noisy as if it's left floating
when i press and hold.
when i view this at the terminal, i get a stream of "Button pressed"
as if i'm repeatedly pressing and releasing the touch sensing button at a fast rate or the touch sensor is floating.
I have come across many pdf solutions but i'm pretty much limited to most of the options since i will need to make modifications to the
touch sensing board. I'm quiet certain that this issue can be resolved
via hardware or software is what i'm not sure of.
the board obviously does detect my finger but it's also picking up some other noise which needs to be filtered out.
Perhaps the speed at which the touch sensing button is reading my touch is pretty slow, choppy or something.
One thing i also thought about was that perhaps the capacitive area surface is too large. It is 18mm in diameter
and probably making a round surface area of about 3mm will do the trick since my finger will cover it completely
thus less susceptible to noise

Anyways helps ??

thanks

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Dealing with Noisy/False reading touch sensing button

Post by dhylands » Fri Mar 24, 2017 3:56 pm

If you're in a room with flourescent lights, then the human body will transfer the 60 Hz signal from the lights to the touch plate.

1 cycle of 60 Hz is roughly 16 msecs. So your logic should probably ignore changes which are smaller than that.

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: Dealing with Noisy/False reading touch sensing button

Post by SpotlightKid » Sat Mar 25, 2017 12:39 am

Maybe you need to adjust the sensitivity of the touch plate sensor by replacing the Cs capcitor above the sensor chip on the board? See the datasheet linked on the sparkfun page for the board.

yoLo_
Posts: 9
Joined: Fri Mar 24, 2017 2:34 am

Re: Dealing with Noisy/False reading touch sensing button

Post by yoLo_ » Fri May 05, 2017 6:02 pm

Sorry,
I have been extremely busy with school but now that is over, i can finally focus on this project.
dhylands, SpotlightKid, thanks for the suggestions
I have tried debouncing the capactive touch just for experimentation
this is what i got:
I switched the sensor to low mode which makes the IC less sensitive
for some reason, either IC itself or the capacitor hold the logic applied
to the touch "for i don't know how long" and then releases it to the board
observation:
in low mode, the noise/false reading is still present
the led on the breakout board signals a touch and turns off immediately
when touch is not present(just like a push button)
with a quick touch & release, the pyboard will signal that there's been a touch,
which is true but then after 3 seconds, the pybaord will again signal that there's been
a 3 second pressed which is false as i only tapped on it.
Thinking that this might be a cause of the capacitor's discharge rate,
I increased the elapsed time to 20 seconds instead of 3 and got the same result
pyboard signaled a 20 second pressed.
I'm thinking about getting rid of the capacitor (C2) on the breakout board
the one connected to SNS between SNSK and R1
I previously tried to debounce the sensor but it only got it being very noisy with random false logic
as if the pin is floating.
Unlike an actual push button that works without problem
Anyways I'd best stick with a button.
I also want ask,
Is there a way to pass a variable to pwm.pulse_width_percent(40)
I have created a global variable device_acc = 0
and when i do pwm.pulse_width_percent(device_acc) , i get invalid syntax
is there a way around this ?? because i want to change the speed of the motor while the code is running.

Thanks

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Dealing with Noisy/False reading touch sensing button

Post by dhylands » Fri May 05, 2017 10:51 pm

yoLo_ wrote:Is there a way to pass a variable to pwm.pulse_width_percent(40)
I have created a global variable device_acc = 0
and when i do pwm.pulse_width_percent(device_acc) , i get invalid syntax
is there a way around this ?? because i want to change the speed of the motor while the code is running.
You'd have to post your complete example, and somebody will be able to point out the problem. Passing variables works perfectly fine. For example:

Code: Select all

paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import pyb
=== 
=== t3 = pyb.Timer(3, freq=20000)
=== pwm = t3.channel(1, pyb.Timer.PWM, pin=pyb.Pin.board.LED_BLUE)
=== 
=== PCT = 0
=== INCR = 10
=== 
=== while True:
===     pwm.pulse_width_percent(PCT)
===     PCT += INCR
===     if PCT > 100:
===         PCT = 100
===         INCR = -10
===     elif PCT < 0:
===         PCT = 0
===         INCR = 10
===     pyb.delay(50)
will make the Blue LED on the pyboard fade between bright and dim

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Dealing with Noisy/False reading touch sensing button

Post by pythoncoder » Sat May 06, 2017 7:34 am

It's puzzling that the Sparkfun touch sensor is noisy: their products usually work perfectly. The Arduino sketch in the tutorial is ridiculously simple and treats the device as an ideal switch (one not requiring debouncing). The AT42QT1010 chip is supposed to handle all the necessary filtering.

The chip datasheet indicates that it tri-states its output for 15μs at regular intervals. This could cause problems if you have a pull up or pull down on your Pyboard input pin. If you configure it without a pull, stray capacitance should ensure that this is never detected in your code.

Do you have any way of monitoring the voltage on the output from the board? Unless your location has an unusually high level of electrical noise I wonder if the board is faulty.
Peter Hinch
Index to my micropython libraries.

Post Reply