Mtouch switch using PIC 12F510


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    May 2011
    Posts
    10

    Default 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

  2. #2
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Mtouch switch using PIC 12F510

    Nobody helps me ??

  3. #3
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default 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.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  4. #4
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Default 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

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default 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.

  6. #6
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Mtouch switch using PIC 12F510

    What if I just use 1 sensor ? Is this the same ?

  7. #7
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Mtouch switch using PIC 12F510

    And what is the role of these resistors ?

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default 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.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Default 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 ?

  10. #10
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Arrow 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;
    }

  11. #11
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Mtouch switch using PIC 12F510

    Nobody helps me check the code ?

  12. #12
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default 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

  13. #13
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Default 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 ?

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default 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... ?%#$??&@%$%@%$
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    Join Date
    May 2011
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: Mtouch switch using PIC 12F510

    Plz help me.
    I don't understand the value "7" in the code above what does that mean ?

  16. #16
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default 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:
    Code:
    until sensor != 7
    This code checks GPIO to see if it is not = %00000111.

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts