Mtouch switch using PIC 12F510
Hello everybody, I am having a small project that is create a 220v light bulb switch using PIC 12F510 but I don't have experience in working with mtouch so can everyone help me answer some question:
1. About the touch: we can't create by ourselves or have to buy?
2. About PIC 12F510: I can't find comparator function in this kind of PIC so how can we have the comparison in order to define whether we touch on it or not ?
Plz help me
Re: Mtouch switch using PIC 12F510
Re: Mtouch switch using PIC 12F510
Not sure what you are asking. This thread answers the 2 questions you posted: http://www.picbasic.co.uk/forum/showthread.php?t=2671
And since you already posted in that thread, seems like you need new questions.
Re: Mtouch switch using PIC 12F510
Can you explain the algorithm of that circuit for me ? I read the code but didn't really understand it :(
Re: Mtouch switch using PIC 12F510
Taken directly out of Mister_es sample code:
Code:
' Short explanation of the whole thing.
' 1. Send a high level to all sensor input => GPIO<2:0>
' 2. Read GPIO port
' 3. Send a low level to all sensor input
' 4. Keep only GPIO<2:0> bits
' 5. Test result
'
' If no sensor has been touched, the result will be 7 => 0000 0111, case
' else, the body capacitance will introduce sufficient delay between
' step 1 and 2 wich will keep the according bit to 0.
'
' Results will be as follow
' NoSensor => 0000 0111 => 7
' GPIO.0 => 0000 0110 => 6
' GPIO.1 => 0000 0101 => 5
' GPIO.2 => 0000 0011 => 3
Seem like a pretty good description. If you are more specific, I am sure someone here can answer your question.
Re: Mtouch switch using PIC 12F510
What if I just use 1 sensor ? Is this the same ?
Re: Mtouch switch using PIC 12F510
And what is the role of these resistors ?
Re: Mtouch switch using PIC 12F510
1,2,3,4,5,6,100, 100 000 sensor solution is the same.
Rough explanation, your body act as a capacitor between the sensor and the circuit ground. By the time the Pin is low, if you add an small capacitance on the pin, set the pin high the read then pin, the pin will read low because the capacitor haven't got time to "charge"... period. simple. Really old way to do it.
You can also do it with a spare CMOS input,Darlington transistor, FET, OpAmp... etc etc etc.
Plug your home theater sound system, set it to line input, crank the volume to the max, insert a needle in the RCA center pin woohoo you got a signal!!!
mTouch use ADC reading, probably more accurate and versatile... no real extra parts.... on both solution, you need a fairly good PCB design.
Re: Mtouch switch using PIC 12F510
Hey mister,
I almost understood what you did however there are some places I still don't really understand:
data @3,3,0,2,1 ' table to convert 'Sensor' variable result to according
' LED blink. See Result list bellow
=> I don't really understand this code? what is the meaning of value: 3,3,0,2,1 ? is this loop variable will get this value ?
' 4. Keep only GPIO<2:0> bits => what is the meaning of keep only GPIO<2:0> bits ? Does it mean that we just read the value of GPIO bits?
repeat
Generator = 1 ' enable sensor power
Sensor = GPIO ' read sensor
Generator = 0 ' disable sensor power => this is send low level right ?
Sensor = Sensor & 7 ' keep only Sensor bits => don't understand this :( is this the comparison ? and what value will sensor get?
'
until Sensor != 7 ' redo the test untill one sensor is touch
'
' Now we will flash an LED to confirm wich sensor has been touch
' GPIO.0 => 1 Blink
' GPIO.1 => 2 Blink
' GPIO.2 => 3 Blink
'
read sensor,loop ' convert result to blink
repeat
LED = 1
PAUSE 200
lED = 0
PAUSE 200
loop = loop - 1
until loop = 0
=> if in this case I use 220v light bulb and I want it lights until we touch again what should I do ?
Re: Mtouch switch using PIC 12F510
Hey is this code true for the 220V light bulb ? I don't mention the syntax just the algorithm.(I familiar with C language )
Code:
While (1) do 'this creates an infinity loop'
{
repeat
Generator = 1 ' enable sensor power
Sensor = GPIO ' read sensor
Generator = 0 ' disable sensor power
Sensor = Sensor & 7 ' keep only Sensor bits
until Sensor != 7 '
' If the light bulb is lighting we will turn off it when we touch
' else we will turn on.
if (LED == 1)
LED = 0;
else if (LED == 0)
LED = 1;
}
Re: Mtouch switch using PIC 12F510
Nobody helps me check the code ? :(
Re: Mtouch switch using PIC 12F510
If you understand C, I would suggest to look for answers in C forums.
Here we all do Basic and specifically Melabs Pic Basic.
Ioannis
Re: Mtouch switch using PIC 12F510
No I just ask about the algorithm not about the language. So plz help me check the algorithm whether it's true or not?
I changed mister's code in order to use that code for turning on or off the 220v light bulb.
Plz help me answer the misunderstanding and answer whether my code right or wrong ?
Re: Mtouch switch using PIC 12F510
I'd answer to your post here, but ONCE AGAIN SOMEONE DELETE MY POST...
It really play on my nerves. If at very least MOD could warn the user before deleting a post with a good reason, life would be good... BUT NO... ?%#$??&@%$%@%$
Re: Mtouch switch using PIC 12F510
Plz help me.
I don't understand the value "7" in the code above :( what does that mean ?
Re: Mtouch switch using PIC 12F510
7 decimal = %00000111
So, when Mister_e states:
Code:
sensor = sensor & 7 ' keep only sensor bits
The code does just what it says. It keeps only the values of the port bits GPIO 0,1, and 2.
and when Mister_e 's code:
This code checks GPIO to see if it is not = %00000111.