Distance / Time measure and clock tuning
-
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.
-
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?
-
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.
-
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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login