DT averaging of interrupt driven cap sensor


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: DT averaging of interrupt driven cap sensor

    If you look at what I think will be you your proper baseline readings (i.e. once you've addressed a couple of those issues mentioned by Darrel)...

    Code:
    14409 
    14439 
    14437 
    14435
    14432
    14423 
    14433
    14440 
    14432 
    14432 
    14426
    14435 
    14434 
    14430 
    14429 
    14431
    they're only varying by about 0.00x% per sample period (interrupt)...and when your finger is pressed on the sensor, you should see the value drop by at least 20% (probably 50% or more if your sensor is decent enough), so there's really no need for averaging.

  2. #2
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: DT averaging of interrupt driven cap sensor

    thank you so much for the insight. that got rid of the erratic readings. I was able to set a threshold, and not update the average during a button press, and also count the amount of time that the button is pressed. I'm pleased.

    but I'm having trouble with the HSEROUT command - I feel so silly, I've never used it before. I saw that the tx pin is the same one as I was using before, so I was encouraged, but all I got in the PICKIT2 UART tool was '????????????????????' and jiberish

    I put these two defines up top, I tried 20h and 24h, 9600 baud and 19200
    DEFINE HSER_TXSTA 24h ' high speed (BRGH = 1)
    DEFINE HSER_BAUD 19200 ' 19200 BAUD rate

    and then I had these in my code
    Hserout ["Hello World", 13, 10]
    HSEROUT [DEC VALUE, ", ", DEC AVE, 13,10]

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: DT averaging of interrupt driven cap sensor

    This is what gets me there on an 16f1828 @115,200 baud (16Mhz Osc)...

    Code:
    Osccon = %01111010   'sets the internal oscillator to 16Mhz
    DEFINE  OSC 16
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 34  ' 115200 Baud @ 16MHz, -0.79%
    SPBRGH = 0
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    RCSTA.7 = 1             ' Enable RB7 for TX USART (not sure if this is needed - needs removing one day to see!)
    TrisB.7 = 0                ' set pin 10 RB7 to be an output

    MrE's picmulticalc utility helps a lot wrt setting defines for your required serial speed...

    http://www.picbasic.co.uk/forum/show...5639#post65639

    your command usage looks fine - have you tried scoping the hserout pin?
    Last edited by HankMcSpank; - 15th September 2011 at 13:15.

  4. #4
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: DT averaging of interrupt driven cap sensor

    yes! I got it working. Thanks for pointing me to the pic multi calc program, what a life saver. I used it for figuring out my interrupt timing, but I didn't see that it also did EUSART settings. It didn't start working until I set the appropriate bit in the APFCON register.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: DT averaging of interrupt driven cap sensor

    I am thinking of using the Cap sensor idea on a project to be battery powered in the middle of the sea.

    Considering that there are no 50/60Hz power lines, will this work?

    Ioannis

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: DT averaging of interrupt driven cap sensor

    Quote Originally Posted by Ioannis View Post
    Considering that there are no 50/60Hz power lines, will this work?
    I don't know what you mean wrt power lines bit (grounding?), but I see no reason why it wouldn't work - as far as I recall cap touch works with batteries too. (though now having a little bit of doubt in that all my exploits where on breadboard & mains sourced power!)

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: DT averaging of interrupt driven cap sensor

    Sorry for that. I got a little carried away, because I was exprimenting with another touch sensor, working with power line interference.

    The Cap sensor is what it say, capacitor sensor, so it has nothing to do with power lines, noise etc.... Reading your reply, a bell was ringing in my brain, making me a little embarrased...

    Ioannis

Members who have read this thread : 0

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