Capacitive Touch Sensors on an AVR without QTouch (Let's Learn and Code 3)

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ค. 2024
  • I've received a number of requests about how I do my touch sensors. I decided to finally post the full how-to on it. This is my third in my let's learn/let's code series, and my first one where I am combining them into one video (since it was short enough).
    Source code is available here: github.com/cnlohr/magfestbadg...
    Since the schematic at 7:00 is somewhat confusing, and for explaination purposes I should have wired the capacitor to ground, the circuit still works even with it wired to 5V. It is because the voltage slope becomes shallow as the voltage across the resistor decreases:
    I did a spice just to make sure: imgur.com/gALkRea
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 52

  • @BrandonPiner2255
    @BrandonPiner2255 8 ปีที่แล้ว +1

    Fantasic tutorial! your channel contains all the knowledge I was missing for my next project!

  • @CNLohr
    @CNLohr  11 ปีที่แล้ว

    I didn't realize you watched other people's videos, I figured you were too busy with your own space program or something else equally ridiculous and awesome.

  • @RobertGallop
    @RobertGallop 11 ปีที่แล้ว

    Definitely enjoyed that look into a DIY touch sensor! More like it please!

  • @CNLohr
    @CNLohr  10 ปีที่แล้ว

    Thanks! I know. Things have been pretty hectic for the last few months. I have time to do fewer side projects, and even less time to turn them into youtube videos, but hopefully I'll get back into bi-weekly posting next month some time. I actually tried just that, the "pressure" response wasn't great but the "was it clicked" worked out really well!

  • @CNLohr
    @CNLohr  11 ปีที่แล้ว

    Thanks - also, any recommendations would be greatly welcome!

  • @CNLohr
    @CNLohr  11 ปีที่แล้ว

    I will try to get that updated tonight!

  • @OswaldChisala
    @OswaldChisala 7 ปีที่แล้ว +1

    Really excellent work man!

  • @nathanpc
    @nathanpc 11 ปีที่แล้ว

    Great video. You should definitely make more of these!

  • @AppliedScience
    @AppliedScience 11 ปีที่แล้ว +1

    Good stuff!

  • @rongarza9488
    @rongarza9488 3 ปีที่แล้ว +1

    AVR = a microcontroller with memory on board for program storage, like an Arduino. The letters may stand for the initials of the 2 Norwegian developers'plus the R from RISC, Reduced Instruction Set Computer, according to Wikipedia.

  • @gpashok
    @gpashok 10 ปีที่แล้ว

    Nice one man. I am going to try this.. One issue could be, how it will work, if you are not grounded.. still it is worth giving a shot.

  • @wmd5645
    @wmd5645 6 ปีที่แล้ว

    Thanks! How does the resistors value affect this? Will a larger resistance just make that time of the curve decrease? Most folks are saying use at least a meg or it will be a proximity sensor? Not sure if I’m understanding this relationship. Your vid has been the most helpful

  • @AaronEiche
    @AaronEiche 7 ปีที่แล้ว

    Thank you for posting this and describing how it all works. This is really fantastic. I'm working on a project adding a capacitive button (two actually) and was tremendously frustrated to find that Qtouch is only available through atmel studio (I don't have a Windows computer) This solution is perfect!
    To clarify (I've looked at the schematic) the only components you need are a conductor under a dielectric and a properly sized resistor? That seems impossibly simple!

    • @CNLohr
      @CNLohr  7 ปีที่แล้ว

      That is indeed all! Yeah, I'm not sure why QTouch is a thing at all.

  • @WiZeR911
    @WiZeR911 10 ปีที่แล้ว

    Hey Lohr, POST STUFF ;) - Cool videos, 2nd time I've watched this. Wondering, would this kind of setup be good for something like a midi controller. i.e something like a drum pad where you use your fingers to 'tap' out beats? Would be a cool way to do it, I think.

  • @BShah16
    @BShah16 4 ปีที่แล้ว

    Wow, this tutorial was great! Thank you!

  • @KlemenZhivko
    @KlemenZhivko 6 ปีที่แล้ว

    Nice! How would you design circuit to sense longer distance and even more hard - through 25mm thick wood?

    • @CNLohr
      @CNLohr  6 ปีที่แล้ว

      this method wouldn't work that far :-/ you'd have to use RF or other methods.

  • @Khellendros7
    @Khellendros7 10 ปีที่แล้ว

    First off, thanks for your excellent tutorial. Can you provide some pointers for me? I was able to get this working like a charm, but ran into problems when expanding it to multiple pins. Since there is only one interrupt for all pins, I have basically run the relevant code twice, one for each pin, while changing the bitmask the interrupt uses to fire on. This only somewhat works. The inputs sometimes appear to bleed over into each other, not turn off all the time, etc. Any ideas as to how you would adapt this technique to utilize multiple pins? Thanks!

    • @CNLohr
      @CNLohr  10 ปีที่แล้ว

      I use a macro to write the code for me, this does expand a lot, but in the grand scheme of things it's not that bad.
      One thing I always do (and seems to help a lot with the bleeding) is to drive all pins low when they're not in use.
      Idea is: Release pin, count time, drive pin low. Repeat for all pins.

  • @EdwinFairchild
    @EdwinFairchild 9 ปีที่แล้ว

    how are you using a terminal window to view outputs?

    • @CNLohr
      @CNLohr  9 ปีที่แล้ว

      Eddie Amaya Tinyispterm, check it out on github.

  • @ThaWhiteRussian
    @ThaWhiteRussian 11 ปีที่แล้ว

    Awesome that you use a schematic software for drawing:D

  • @CNLohr
    @CNLohr  11 ปีที่แล้ว

    I'm not sure what the website would be like... I have toyed with trying to make blogs, but I assumed people were like me and would rater watch video than read. And thanks! I guess I'll just take everyone's word on it being fun since I only do it out of some sort of unusual obsession.

  • @CNLohr
    @CNLohr  11 ปีที่แล้ว

    It's updated! Simply re-pull the git tree.

  • @user-kh5qx2fi2r
    @user-kh5qx2fi2r 10 ปีที่แล้ว

    Thanks for video!
    I've tried that, but it works buggy in case of grounding the AVR, so I can't use it for controlling the LED Strip.
    So I still use SPST buttons and variable resistors...

    • @CNLohr
      @CNLohr  10 ปีที่แล้ว

      I think I am going to post a video about an isolated version I was working on for a while. Next time I do a project with it, I'll include a video about it.

    • @NicuIrimia
      @NicuIrimia 9 ปีที่แล้ว

      CNLohr so, it's been a year? did you made another one? I can't find it. Very good content by the way.

    • @CNLohr
      @CNLohr  9 ปีที่แล้ว

      >.< I actually haven't needed to make an isolated version, still. A regular version with grounding has been good enough.

    • @NicuIrimia
      @NicuIrimia 9 ปีที่แล้ว

      CNLohr do you have better way of making the schematic? I just can't see why that works....do you use just one micro pin? (and where do you make contact with your finger?)... I mean, I understand the principle and I think the explanations from the beginningtoo, but the last circuit .. maybe it's late here.

    • @CNLohr
      @CNLohr  9 ปีที่แล้ว

      You don't make contact with your finger. You have a plate and an insulator, so it's just one half of a capacitor. Indeed you only need one micro pin!

  • @CNLohr
    @CNLohr  10 ปีที่แล้ว

    If you are not grounded /and/ it is not grounded, it works quite well... Still works slightly better if you're both grounded. IF One is grounded and not the other, it's terrible.

  • @petermcguire8260
    @petermcguire8260 2 ปีที่แล้ว

    Just what I needed. C++ cap sense for arduino will not compile to avr boards. Pico pie.

    • @CNLohr
      @CNLohr  2 ปีที่แล้ว

      C++ cap sense? This is just C. It compiles to anything.

  • @pcservicebt
    @pcservicebt 9 ปีที่แล้ว

    HI and thanks for the video.
    I was wondering if someone can help me with a code for a resistive touch screen.
    The touch screen that I have is a AMT9502 5.7'' and it shud be able to output the data only when touched via uart

    • @nnje3371
      @nnje3371 6 ปีที่แล้ว

      Jove Gyorshevski any luck?

  • @stevedrake5022
    @stevedrake5022 6 ปีที่แล้ว

    Hello are you still here? I am trying to do the cap touch sensor and I have something that looks like your stuff the top voltage it reaches is 400 mv , when I touch my PCB I see the slope of the voltage going longer. Does your voltage rise all the way to 5Volts? Does your scope probe not load the signal ( I have 1Meg and the scope probe is 10 meg so not a lot of difference). Just so you know I am using a tiny13. Any help you can give would be appreciated.

    • @CNLohr
      @CNLohr  6 ปีที่แล้ว

      The systems here are really sensitive so your scope probe will effect it, but it sounds much more like you need a bigger pull-up resistor. Not sure what the impedance of the inputs on the ATTiny are, so maybe that's not suitable? But the voltage should very quickly rise to at least 2-3 volts if being pulled up to 5 v.

  • @mewmew32
    @mewmew32 ปีที่แล้ว

    Great video, but the big question you didn't answer: *why* not just use QTouch? What are the benefits of rolling your own code?

    • @CNLohr
      @CNLohr  ปีที่แล้ว

      Generally portability, and not needing mutual caps in the systems where you normally do. AND you also can use any pins you want for this.

  • @tonykara
    @tonykara 10 ปีที่แล้ว

    Ok so I watched the entire video, and understand what you're doing. It's cool. I think you should revise your commentary and the drawing at seven minutes. It seems to me by what I observed on your video that the resistor and capacitor are in series and the resistor is tied to +5v. The switch (or port pin) is essentially connected across the capacitor to ground. When the switch closes it discharges the cap almost instantaneously. When it opens, the cap charges at the rate you show on your diagram.

    • @CNLohr
      @CNLohr  10 ปีที่แล้ว

      Look at the symbols, the ground is on the other side of the switch, the 5V is hooked up to the other side of the capacitor. I guess I should have drawn them more clearly with the + going up and the - going down.

    • @CNLohr
      @CNLohr  10 ปีที่แล้ว

      Actually!! You are sort of right! I will have to update my annotations a little better.

    • @tonykara6538
      @tonykara6538 10 ปีที่แล้ว

      CNLohr The annotations still won't fix it or make it clear. The diagram is simply wrong. The cap's voltage will not curve up like that with your existing drawing. You need the resistor and the cap in series from +5V to GND and the switch needs to be across the cap only. When the switch is closed, the cap will immediately drop to zero volts. When the switch is open, the voltage across the cap will rise as you show it because it's being charged by +5V through the resistor. I wish I could show you.

    • @CNLohr
      @CNLohr  10 ปีที่แล้ว

      Tony kara
      I ran a spice simulation. I took a picture of it. You can see the link in the description.

  • @CNLohr
    @CNLohr  11 ปีที่แล้ว

    Admittedly they don't work quite as well if you're not grounded, but it's not that bad. For these tests I was touching a ground with my foot.

  • @Dragonmastur24
    @Dragonmastur24 6 ปีที่แล้ว

    3:24
    Dun Dun Dunnnn!!.... :0
    xD

  • @tablatronix
    @tablatronix 8 ปีที่แล้ว +1

    holy shit, how does that compile so fast, and why is arduino so damn slow....

    • @CNLohr
      @CNLohr  8 ปีที่แล้ว +3

      Because arduino is slow. For some reason lots of people don't care about speed. For me, fast development's linchpin is quick compile and test to fail fast.

    • @paulhendrix8599
      @paulhendrix8599 6 ปีที่แล้ว

      Agreed. I'm amazed by how fast your projects are in comparison with almost anything else. Great video.

  • @tonykara
    @tonykara 10 ปีที่แล้ว

    Your circuit and comments at 7 min isn't correct. When you open the switch in the "flipped" circuit, you show a slowly rising voltage as the cap charges. You don't have a complete circuit the moment you open the switch, and therefore you have no current. With no current, there is no voltage drop across the resistor (and the cap), so the voltage is the same on both sides of both components. It will be equal to 5 V immediately when you open the switch.

  • @CNLohr
    @CNLohr  11 ปีที่แล้ว

    Thanks - also, any recommendations would be greatly welcome!