I2c, srf02, 16f688 -> ultrasonic rangefinder


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default Re: I2c, srf02, 16f688 -> ultrasonic rangefinder

    Peter, thanks for chiming in. I added the parentheses. Still nothing, but it's a good point nevertheless.

    Yes, FAR is greater than NEAR. In fact, the way I have the pots configured, NEAR can never be greater than FAR.

    I just checked again; during the 5-second "blinky" phase, the SRF02 is quiescent. It then responds by pinging on command (I can "see" the ping with an ultrasonic receiver and a scope--and it's appearing about once a second, as it should).

    Al, is there an error in the 16F688 manual? I'm looking at Table 1-1 (page 6) and it shows A4 as TTL in, CMOS out. (In fact, I can't find an OC legend anywhere on the chart!)

    I'm fairly convinced the problem is somewhere in how I'm manipulating the data, or perhaps I have misdefined something.
    Last edited by RussMartin; - 24th February 2011 at 09:47.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Default Re: I2c, srf02, 16f688 -> ultrasonic rangefinder

    You want to write directly to ADCON1 so you have at least Fosc/8 for 4MHz.

    ADCIN doesn't do this for you - so your AD conversion clock is way too fast with ADCON1 = 0 by default.
    Regards,

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

  3. #3
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default Re: I2c, srf02, 16f688 -> ultrasonic rangefinder

    Quote Originally Posted by Bruce View Post
    You want to write directly to ADCON1 so you have at least Fosc/8 for 4MHz.

    ADCIN doesn't do this for you - so your AD conversion clock is way too fast with ADCON1 = 0 by default.
    Thanks, Bruce.

    I've used ADC with other devices (12F683; 16F88; 16F1827) and always gotten by with the RC clock.

    Can I use DEFINE ADC_CLOCK 1? Or if I use ADCON1=%00010000, do I simply omit the DEFINE?
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Default Re: I2c, srf02, 16f688 -> ultrasonic rangefinder

    Hi Russ,

    DEFINE ADC_CLOCK xx only works if the clock select bits are in ADCON0, so just write directly to ADCON1 to set the conversion clock. ADCON1 = %00110000 for RC, ADCON1 = %00010000 for Fosc/8 (recommended).
    Regards,

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

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