Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 07, 2016, 05:15:09 17:15


Login with username, password and session length


Pages: [1]
Print
Author Topic: Touch Switch with 16F628(A)  (Read 8811 times)
0 Members and 1 Guest are viewing this topic.
aldi
Newbie
*
 Muted
Offline Offline

Posts: 15

Thank You
-Given: 148
-Receive: 8


« on: December 02, 2008, 04:05:23 04:05 »

hi...i have a question. can we make a touch switch with a 16F628 and powered from battery? i have no idea...thanks

best regard


Aldi
Indonesia
Logged
service
Junior Member
**
Offline Offline

Posts: 45

Thank You
-Given: 32
-Receive: 35


« Reply #1 on: December 02, 2008, 05:46:25 05:46 »

The quick answer is NO if you are talking about a touch plate as used commonly in lighting.
Touch switches use AC from the mains, with your body acting as a path for Active to Earth when you touch the plate.
This can't be done with DC from a battery.
Using a PIC you could work with the capacitance of your finger but you would need two contact points you place your finger across.
One of the contact points will need a pulsed signal (ie 1KHz). When you place your finger across the contacts the signal should been seen on the second contact. You may need an op-amp or schmit trigger before sending this signal back to the PIC. The PIC can then wait to see this signal.

See my post below where I have proved myself wrong and included an example using a PIC16F88. Files in Mikrobasic & Proteus
« Last Edit: December 18, 2008, 06:42:03 06:42 by service » Logged
aldi
Newbie
*
 Muted
Offline Offline

Posts: 15

Thank You
-Given: 148
-Receive: 8


« Reply #2 on: December 02, 2008, 07:15:36 07:15 »

thaks for quick replying service, i have an attachment showing a touch sensor with 16F627 that work only with 1 wire. the author sez:
"The actual data from the touch sensors is quite erratic and requires some software processing.   Basically you create a pulse for each of the ports and read the data with the instruction following the pulse signlal rise.  Then read the ports the same way looking for a gap of 0.1 seconds with no data detected.  This does the 'debounce'.   This results in fairly clean data capture from the sensors"

is this project working? coz i cannot contact the author for confirmation

here the project pic and the source of his/her project
thanks and best regards,


Aldi
Indonesia
Logged
zuisti
Senior Member
****
Offline Offline

Posts: 371

Thank You
-Given: 219
-Receive: 567


« Reply #3 on: December 02, 2008, 02:17:25 14:17 »

thaks for quick replying service, i have an attachment showing a touch sensor with 16F627 that work only with 1 wire. the author sez:
"The actual data from the touch sensors is quite erratic and requires some software processing.   Basically you create a pulse for each of the ports and read the data with the instruction following the pulse signlal rise.  Then read the ports the same way looking for a gap of 0.1 seconds with no data detected.  This does the 'debounce'.   This results in fairly clean data capture from the sensors"

is this project working? coz i cannot contact the author for confirmation

Hi;
It's interesting... I found nothing, only this site but it presents the principle:
http://mondo-technology.com/touch.html
Good luck
zuisti
Logged
Parmin
Hero Member
*****
Offline Offline

Posts: 544

Thank You
-Given: 357
-Receive: 126


Very Wise (and grouchy) Old Man


« Reply #4 on: December 03, 2008, 01:10:52 01:10 »

Microchip have codes for Capacitance touch AND I heard that they will release INDUCTANCE touch soon too..
Visit their site - plenty of FREE data there.
Logged

If I have said something that offends you, please let me know, so I can say it again later.
bbarney
Moderator
Hero Member
*****
Offline Offline

Posts: 2403

Thank You
-Given: 405
-Receive: 544


Uhm? where did pickit put my mute button


« Reply #5 on: December 03, 2008, 03:21:39 03:21 »

read this one
http://www.picbasic.co.uk/forum/showthread.php?t=2671&highlight=touch+switch
Logged

Ever wonder why Kamikaze pilot's wore helmet's ?
yahoo
Active Member
***
Offline Offline

Posts: 106

Thank You
-Given: 40
-Receive: 50


« Reply #6 on: December 04, 2008, 12:45:51 00:45 »

Is this only for direct finger touch over the coper pad or it will work behind glass/plastic/ceramic surface? Does it have good sensitivity?
Logged
aldi
Newbie
*
 Muted
Offline Offline

Posts: 15

Thank You
-Given: 148
-Receive: 8


« Reply #7 on: December 04, 2008, 03:06:49 03:06 »

thanks zuisti, Parmin, bbarney for all the info...i will try it and inform you...

Is this only for direct finger touch over the coper pad or it will work behind glass/plastic/ceramic surface? Does it have good sensitivity?
AFAIK if we use capacitance, (Capacitance Proximity Touch Sensor) it will work under a thin surface of glass,plastic etc... check the attachment out
Logged
Lumos
Junior Member
**
Offline Offline

Posts: 89

Thank You
-Given: 63
-Receive: 11


« Reply #8 on: December 04, 2008, 05:45:20 05:45 »

Hi,

look here

http://www.qprox.com/products/Page-16035.html

best regards
Logged
service
Junior Member
**
Offline Offline

Posts: 45

Thank You
-Given: 32
-Receive: 35


« Reply #9 on: December 18, 2008, 06:40:42 06:40 »

After saying it couldn't be done, then seeing other posts on the subject, I decided to spend some time proving myself wrong.
Here is my example for 4 touch switches on a PIC16F88. Files in Mikrobasic & Proteus. (The ISIS schematic has the switches connecting to VDD, this is just for ISIS simulation only)
« Last Edit: December 18, 2008, 06:45:40 06:45 by service » Logged
aldi
Newbie
*
 Muted
Offline Offline

Posts: 15

Thank You
-Given: 148
-Receive: 8


« Reply #10 on: December 26, 2008, 03:20:22 15:20 »

Thanks Service for the reply and a sample of a touch switch, unfortunately i cannot open the ISIS file, the software sez i must have later version of ISIS in order to open your file..what version if ISIS do u use for designing the circuit? mine is 7.2 SP 2..

best regards


Aldi
Logged
maddoc
Newbie
*
Offline Offline

Posts: 32

Thank You
-Given: 49
-Receive: 14


« Reply #11 on: December 28, 2008, 11:08:16 11:08 »

Hi aldi!

Here is my touch switch code, I use small metal push-pins (1$ for 250 pieces). I found some that are color coated and look very good.
All pushpins have a 1 MOhm resistor permanently connected to +5V, so 4 resistors are used in this example.
The pins are checked 1000 times and negative state is recorded in variables B1 to B4
If a B variable is higher than 124 then it is considered that the button is pushed and a LED on PORT B is lighted.

PORTA.1 is input for LED on PORTB.1
PORTA.0 is input for LED on PORTB.2
PORTA.7 is input for LED on PORTB.3
PORTA.6 is input for LED on PORTB.4

This is the code for a 16F628A in PicBasic:

Code:
DEVICE 16F628A
DECLARE XTAL 4
BOOTLOADER OFF
CONFIG WDT_OFF,PWRTE_ON,LVP_OFF,CP_OFF,BODEN_OFF,MCLRE_OFF,INTRC_OSC_NOCLKOUT
ALL_DIGITAL=TRUE
PORTB_PULLUPS = OFF


DIM Z AS WORD
DIM B1 AS BYTE
DIM B2 AS BYTE
DIM B3 AS BYTE
DIM B4 AS BYTE

;ALL INPUTS
PORTA=0
PORTB=0
TRISA=255
TRISB=255

;DEFINE OUTPUTS
TRISB.1 = 0 ;LED1
TRISB.2 = 0 ;LED2
TRISB.3 = 0 ;LED3
TRISB.4 = 0 ;LED4


START:

GOSUB VERIF          ;see what buttons are pressed

IF B1 > 124 THEN
HIGH PORTB.1
ELSE
LOW PORTB.1
ENDIF

IF B2 > 124 THEN
HIGH PORTB.2
ELSE
LOW PORTB.2
ENDIF

IF B3 > 124 THEN
HIGH PORTB.3
ELSE
LOW PORTB.3
ENDIF

IF B4 > 124 THEN
HIGH PORTB.4
ELSE
LOW PORTB.4
ENDIF


GOTO START



VERIF:                               ; HERE WE CYCLE TO 1000 AND SEE WHAT BUTTONS ARE GROUNDED BY USER
CLEAR                                ; THIS METHOS IS USED TO REJECT ACCIDENTAL FALSE POSITIVES.
FOR Z = 0 TO 999
IF PORTA.1 = 0 THEN INC B1
IF PORTA.0 = 0 THEN INC B2
IF PORTA.7 = 0 THEN INC B3
IF PORTA.6 = 0 THEN INC B4
NEXT
RETURN


GOTO START
END ' END OF PROGRAM

I find this approach very natural to the feel of a button.
Never had a missed push and never had a false positive.
The colored pushpin look really good.


Edit: removed a line in CODE right after START: ( LOW TXE ), sorry, it was a left over from another code!
« Last Edit: December 30, 2008, 02:54:20 02:54 by maddoc » Logged
bbarney
Moderator
Hero Member
*****
Offline Offline

Posts: 2403

Thank You
-Given: 405
-Receive: 544


Uhm? where did pickit put my mute button


« Reply #12 on: December 28, 2008, 04:05:28 16:05 »

Got a picture of these pins and maybe a schematic before 50 people ask the same thing Wink
Logged

Ever wonder why Kamikaze pilot's wore helmet's ?
maddoc
Newbie
*
Offline Offline

Posts: 32

Thank You
-Given: 49
-Receive: 14


« Reply #13 on: December 28, 2008, 07:25:40 19:25 »

Sorry, but I don't have schematics, all in my head, will try to make some.
Here is the picture with the pushpins I use and recommend to connect to PORTA pins:
« Last Edit: December 28, 2008, 07:44:29 19:44 by maddoc » Logged
aldi
Newbie
*
 Muted
Offline Offline

Posts: 15

Thank You
-Given: 148
-Receive: 8


« Reply #14 on: December 29, 2008, 03:00:07 03:00 »

thanks maddoc fof the idea...but small problem here..in the start routine there is LOW TXE, i`ve got error here when compiling
what is LOW TXE?

how lenght the cable from the pushpin to the input is recommended from you? 50 cm is ok?

BTW, nice pushpin there...

excuse me for my very bad english, i hope u understand what i mean..

Best Regard


Aldi
Logged
bbarney
Moderator
Hero Member
*****
Offline Offline

Posts: 2403

Thank You
-Given: 405
-Receive: 544


Uhm? where did pickit put my mute button


« Reply #15 on: December 29, 2008, 05:00:15 05:00 »

Ok you guy's let's start calling the pushpin what it really is a common "THUMB TACK " Grin Grin
Just like the box say's Grin very good idea though  to bad they didn't make square thumb tack's
Logged

Ever wonder why Kamikaze pilot's wore helmet's ?
yahoo
Active Member
***
Offline Offline

Posts: 106

Thank You
-Given: 40
-Receive: 50


« Reply #16 on: December 29, 2008, 03:33:42 15:33 »

maddoc, the idea for the pushpins as key pads is very good but changing the pulse with constant 5V conection seems to me that will not work very well. The pulse define a time frame where you check for voltage change and it is much more stable if there is outside noise like sparks, rf field etc. If you check that 1000 times you need a lot of time for large number of keys so the time responce will be low and the micro cannot do anything else during this verification. I think that one more pin for pulse generation is much better.
Logged
aldi
Newbie
*
 Muted
Offline Offline

Posts: 15

Thank You
-Given: 148
-Receive: 8


« Reply #17 on: December 30, 2008, 01:29:54 01:29 »

i want to use this touch switch in my car, to control various thing that normally using switch...is it ok to use this type of switch in car environment (noise, sparks, rf, etc etc)??

thanks and best regard
« Last Edit: December 30, 2008, 01:31:56 01:31 by aldi » Logged
maddoc
Newbie
*
Offline Offline

Posts: 32

Thank You
-Given: 49
-Receive: 14


« Reply #18 on: December 30, 2008, 02:49:19 02:49 »

thanks maddoc fof the idea...but small problem here..in the start routine there is LOW TXE, i`ve got error here when compiling
what is LOW TXE?

how lenght the cable from the pushpin to the input is recommended from you? 50 cm is ok?

Sorry for being late, had a hard drive failure. Sad
Just delete LOW TXE, and it should compile just fine. It was a leftover from a former code change.
I used 10cm cable pieces from a flat ribbon cable.

I tested the above code and schematics by holding near and powering up/powering down a drill and a 100W soldering iron, and using a GSM phone. No false reports have been generated. I use it in my home instead of classic light switches.

If you are going to make a time sensitive application then combining subroutines will help you further. I strongly advice to make a few hundred readings to determine a touched button - especially in noisy environments.
Yahoo, that subroutine to check for buttons only takes about 20ms to complete. But then again my application is user centered and not time sensitive.

bbarney you're great, I never figured out the obvious name of those thumb tacks, even with the box in front of me. Cheesy

Edit: Aldi, just make a simple testboard and try it in your car with the engine started.
« Last Edit: December 30, 2008, 02:51:48 02:51 by maddoc » Logged
bbarney
Moderator
Hero Member
*****
Offline Offline

Posts: 2403

Thank You
-Given: 405
-Receive: 544


Uhm? where did pickit put my mute button


« Reply #19 on: December 30, 2008, 04:51:34 04:51 »

Quote
bbarney you're great, I never figured out the obvious name of those thumb tacks, even with the box in front of me.
yea but if you look real close they spelled tack's wrong in their english translation  Grin Grin
Logged

Ever wonder why Kamikaze pilot's wore helmet's ?
Vague
V.I.P
Junior Member
*****
Offline Offline

Posts: 49

Thank You
-Given: 359
-Receive: 27


« Reply #20 on: December 30, 2008, 10:23:18 10:23 »

Have you had a look at the microchip mtouch website? It has examples of using PICS with inductive and capacitive touch sensing.
Logged
service
Junior Member
**
Offline Offline

Posts: 45

Thank You
-Given: 32
-Receive: 35


« Reply #21 on: January 01, 2009, 09:22:57 09:22 »

Thanks Service for the reply and a sample of a touch switch, unfortunately i cannot open the ISIS file, the software sez i must have later version of ISIS in order to open your file..what version if ISIS do u use for designing the circuit? mine is 7.2 SP 2..

best regards


Aldi
The ISIS file could be from 7.4sp3.
Logged
sherm
Junior Member
**
Offline Offline

Posts: 44

Thank You
-Given: 14
-Receive: 9


« Reply #22 on: January 06, 2009, 03:22:13 03:22 »

The June 2008 edition of Nuts and Volts magazine had a good article on Capacitive Sensing. You can find a link to it if you search the forum. The article was called "Firmware You Can Touch" and could be of good value to you in your endeavours Smiley

Good luck!
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC