Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Distance / Time measure and clock tuning

Distance / Time measure and clock tuning

Scheduled Pinned Locked Moved Development
5 Posts 2 Posters 1.5k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • qqlapralineQ Offline
    qqlapralineQ Offline
    qqlapraline
    wrote on last edited by qqlapraline
    #1

    Hello All,

    I have built a nice little distance sensor using a Sensebender micro. The power footprint is very low: batteries would last several months.
    I'm trying to push it further. To do so, I'm wondering if I could play with the clock of the Atmega.
    I have understood that delay(), millis(), .. primitives don't behave appropriately after using clock_prescale_set() usage.
    Here is my question: is there a standard library (like NewPing) that handles these changes appropriately ?

    Regards,

    QQ.

    1 Reply Last reply
    0
    • cimba007C Offline
      cimba007C Offline
      cimba007
      wrote on last edited by cimba007
      #2

      Its not like "defaultish"-library but currently I am using this piece:

      https://github.com/fschaefer/Prescaler/blob/master/prescaler.h

      It features some code to get the "real" millis but all librarys that depend on arduino "delay" and "millis" function might do wrong delays/timings.

      All my nodes run at 1mhz to power them up with even 2xAA batteries @2,4volt or less. If some nodes have a more stable supply I use the library this way:

          uint8_t old_ps = getClockPrescaler();
          setClockPrescaler(0x00);
          oled.setCursor(0,1);
          oled << mymin << "," << sum << "," << mymax << "," << (diff < 1024 ? diff : 1024) << "," << (acc < 1024 ? acc : 1024) << " " << endl;
          oled << "sf: "  << spike_forgiveness << " " << endl;
          oled.setCursor(64,3);
          oled.print(readVcc());
          oled.print("mV  ");
          oled.setCursor(0,3);
          oled.print(RF24_readByteRegister(OBSERVE_TX),HEX);
          setClockPrescaler(old_ps);
      

      Regarding the power-footprint. Are you using the sleep-function of mysn?

      1 Reply Last reply
      0
      • qqlapralineQ Offline
        qqlapralineQ Offline
        qqlapraline
        wrote on last edited by
        #3

        Well, I've adapted the NewPing library in order to handle different clocks (using inline definition of millis(), micros(), ...) and....it works perfectly !
        Now I have a low power, low clock ultrasonic sensor that will last for years on a set of 2 AA batteries.
        If I'm not too busy, I might packed it up and publish it :)

        QQ.

        1 Reply Last reply
        2
        • cimba007C Offline
          cimba007C Offline
          cimba007
          wrote on last edited by
          #4

          At least in theory .. how much power does the ultrasonic-part consume and/or do you switch it off between measurements?

          1 Reply Last reply
          0
          • qqlapralineQ Offline
            qqlapralineQ Offline
            qqlapraline
            wrote on last edited by
            #5

            I will publish my voltage curve once I get enough history.

            And yes, I do shut down the sensor (and the booster, and the logic level adapter) between measures ;)

            Qq.

            1 Reply Last reply
            1
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            16

            Online

            11.7k

            Users

            11.2k

            Topics

            113.0k

            Posts


            Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular