Sharp pulse on ADC input and NAP


Closed Thread
Results 1 to 12 of 12

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Sharp pulse on ADC input and NAP

    I would use a wake on comparator interrupt or pin change with a permanent sleep instead
    @ SLEEP

    a PIC10F204/206 can wake from a comparator or any pin change, really cheap, would be a perfect choice. Would require only a few lines of code.
    http://ww1.microchip.com/downloads/e...Doc/41239D.pdf

    Is it mandatory to supply 5V to your PIC? What's the requirement for the Output pulse amplitude?
    Why i'm asking, refer to figure 13-2 and later.
    Steve

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

  2. #2
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: Sharp pulse on ADC input and NAP

    Thanks for the fast response, Steve. Funny, I'm using a 12F675, but did think it was an overkill and a 10FXXX would be a fine fit.

    Also thought the @ SLEEP would be the answer, but I have to admit interrupts (specially the ADC triggerred ones), are not my Forte. Could you possibly point me in the right direction?

    Actually, the supply is 3.3, and the PIC merely needs to pull down an external pin thats held high (also at 3.3) with a very weak pull-up.

    For those interested, this is a wired remote for DSLRs that uses a smartphone as a triggering device with s/w thats available free (for Androids for sure, dont know about other platforms)

    Regards,

    Anand Dhuru

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: Sharp pulse on ADC input and NAP

    I have not tested this since I don't have a 12F675, but something like this should work. You might need to tweak the internal CVref settings.

    Hook your sensor output to GPIO.1 Vin-. When your sensor outputs 1V (or anything > CVref) it should wake-up from sleep.

    If you don't have PBP3 just get rid of the config line, and use what you have.

    Code:
    #CONFIG
      __config  _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _CP_OFF
    #ENDCONFIG
     
    DEFINE OSCCAL_1K 1 ' load internal osc calibration value
     
    LED VAR GPIO.2      ' LED output
    CmpFlag VAR PIR1.3  ' alias comparator interrupt flag bit
    CoutBit VAR CMCON.6 ' CMCON.6 is set while voltage on Vin- > CVref
     
    ANSEL = 0          ' disable A/D
    GPIO = 0           ' LED off on POR
    TRISIO = %00000010 ' GPIO.1 = input for Vin- comparator, rest outputs
    VRCON = %10100111  ' internal CVref enabled, low range.
                       ' CVref = (VR3:VR0 / 24) * VDD.
                       ' with (VR3:VR0) = 7 we have (7/24) * 3.3V
                       ' so internal CVref = 0.9625V
                       ' a voltage > 0.962V on Vin- (GPIO.1) will set COUT,
                       ' set the comparator interrupt flag, and wake us up.
    CMCON = %00010100  ' Comparator w/o Output and with Internal Reference
     
    PIR1 = 0           ' clear flags before enabling comparator int
    PIE1 = %00001000   ' comparator interrupt enabled.
    INTCON = %01000000 ' enable peripheral interrupts for comparator
                       ' global interrupts disabled, so there's no jump to
                       ' an interrupt vector. We're just waking-up from sleep.
     
    TEST:
      WHILE CoutBit    ' wait for COUT to clear. This clears when the voltage on
      WEND             ' Vin- falls below the internal CVref
      CmpFlag = 0      ' clear comparator interrupt flag bit before entering sleep
      @ SLEEP          ' should sleep until comparator trips
      HIGH LED
      PAUSE 500
      LOW LED
      GOTO TEST
      end
    Last edited by Bruce; - 13th August 2011 at 16:53.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: Sharp pulse on ADC input and NAP

    Bingo, Bruce! My mistake, the trigger amplitude is more like 0.5 volts, so I just edited the VRCON bits and it works like a charm. But, I measure around 200 uA in standby now. Still a HUGE improvement over my earlier 800 uA, but with the NAP I was getting a draw of about 30 uA. Am I doing something wrong?

    All above readings are on my breadboard at 5 volts, while testing. When its finalized the circuit will work on 3.3 volts, so I guess the consumption would be reduced significantly.

    Regards,

    Anand
    Last edited by ardhuru; - 14th August 2011 at 16:01.

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Sharp pulse on ADC input and NAP

    I have a 12LF1822 running at about 8-10ua in Sleep (the PIC 'LF' variants consume signifiantly less power in sleep, so considering moving over to a PIC that can be had in LF variant. Also, as you point out, the lower the voltage the better)

    It's imperative before putting the PIC to sleep, to get all your IO pins & PIC peripherals in the right 'state' to consume the least power while sleeping - I find the best way is studying the associated ciruit it interfaces with, then a massive amount of trial & error while checking the current draw on my DVM! (ie switch off all the uneeded PIC internal peripherals, IO pin TRIS states have the most impact along with pins being set up as analague or not...whilst there are rules of thumb - http://ww1.microchip.com/downloads/e...hapter%202.pdf - I've found the results in the real world to be somewhat random!)

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: Sharp pulse on ADC input and NAP

    Hi Anand,

    That sounds about right since the comparator & internal Vref use a bit more power than the A/D, but doing it the other way you're going to miss a lot of sensor pulses while it's NAPing for ~18mS.

    If this doesn't have to respond 'immediately' when the pulse comes, you could just setup a loop taking A/D measurements while sleeping, wake, look for a value, return to A/D sampling while sleeipng, but you would have to configure the A/D manually, start the conversion, then immediately @ SLEEP.

    Use the A/D interrupt to wake it from sleep when the A/D sample is finished. It would be sleeping the majority of the time until the A/D result register indicated a change in voltage.

    That would help get the power consumption down with the 12F675. You could also put it to sleep during your high pulse by setting the WDT prescaler, and using the WDT VS a PAUSE 500. Set the pin high, go to sleep, wake-up, clear the pin, return to wait for the pulse.

    I'll 2nd the 12LF1822. This part also allows you to enable/disable WDT, and everything on it uses less power than the 12F675.

    Run it on an external 32kHz LP oscillator, and use the comparator for wake-up. On wake-up, enable WDT with a prescaler set to 512mS. Take your output high, goto sleep for the duration of the 500mS pulse. Wake up, clear the output, disable WDT, and return to sleep to wait for the comparator wake-up pulse.

    That would save a ton of power for a battery app.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: Sharp pulse on ADC input and NAP

    Hank, Bruce, thats a whole lot of suggestions I can work on to optimize the design. The stress on the low current is, because there IS no battery driving this circuit. Its phantom power tapped off the DSLR's control port as shown here http://www.doc-diy.net/photo/hdr-jack/

    Although my app is somewhat different, the powering scheme is exactly as used in the intervalometer project.

    I'm going to try everything you guys suggested, one by one, and see if I can get away with using a 12F675 (just beacuse I have a few lying around), and if I cant pare it down enough I guess I'll just have to switch over to an LF part.

    BTW, did you notice this guy feeds the Vdd to the controller (Atmel, in this case) thru' the signal pins rather than the proper Vdd pin? Is this desirable/acceptable/reliable? On the pic it did work, but did not reduce the current consumption much.

    Will keep reporting back my findings!

    Regards,

    Anand

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