Bangle GPS Power management #2379
Replies: 56 comments
-
Posted at 2021-01-01 by @allObjects It is not that simple that with less updates power goes equally down. Every update has an acquisition time and the longer the updates are apart, the longer the acquisition may take because things may have changed more drastically. It is a matter of 'continuous' tracking with reasonable frequency, with 'reasonable' meaning balancing out pros and cons of each aspect involved in delivering sufficient accurate fix(es). Attached documents explain that there is/are optimum/s in relation to update interval length / frequency, accuracy and power. First reading with good explanations is in the attached document about design considering power consumption minimization for the M6 series of u-blox receivers. Second document includes field tests with the M7 and M8 series. And finally I link to the document - which you also may have found -about the M8130-KT as is in the BangleJS https://www.u-blox.com/sites/default/files/products/documents/u-blox8-M8_ReceiverDescrProtSpec_(UBX-13003221)_Public.pdf - same as you find under Hardware at https://www.espruino.com/Bangle.js+TechnicalAttachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-01 by HughB Thanks for the response. I think I had seen the AppNote before, but was not able to make the What I would like to acheive is to have a OS GRID ref showing as a widget or a line of TEXT in the front screen of the watch. Normally GPS will be switched off so the grid ref line will be skipped What I read in the AppNote:
Section 2.3.1 shows a chart, with PSMOD set to 30seconds the average power consumption is 2mA. The question is how to set this value using the Bangle JS framework. Once I understand how to use the code in GPS-comms.js I can try a few experiments, to see what is practical. I see Gordon has requested votes on the next in depth tutorial, so I have upvoted for a GPS tutorial. Back to more studying of GPS-comms.js against the datasheet, I guess I am going to |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-01 by HughB Had a closer look at the code and the datasheet.
There are some example interval setups in Use update periods of 30 minutes
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-04 by @gfwilliams Hi - sorry for the delay on this - but what you've got there looks like it could work well. It's really just a matter of trying to digest what the datasheet says you can do and come up with the series of bytes. The CRC is handled for you at least. Once you've got the command name you're interested in from the datasheet you may also have some success googling and seeing if anyone has used it anywhere else. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-07 by HughB More experimentation tonight. I can confirm that the UBX_CFG_2MIN() function will get an ACK response from the GPS. However thats not enough as the GPS still sends a fix every 1-2 seconds. The rate appears to be controlled by UBX_CFG_RATE(). So I tried the function below.
This gets neither an ACK or a NACK so I assume that the GPS does not like the format or checksum and is ignoring it. I found the following python code at:
But when I look at the bytes it does not match the datasheet. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-08 by HughB This gets an ACK - seems the length byte is 2 bytes !!!
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-08 by HughB Almost there. Getting updates every 65 seconds, then seemed to loose the configuration. Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-08 by @gfwilliams That's great - thanks for posting up your progress! Yes, I'm pretty sure length is 2 bytes. It'd be great to turn this into a GPS config app - maybe with some presets for 'default','low power', etc. I wonder if even though the GPS data is getting pushed out every second, it is only properly updating every 2 min anyway? If so I guess it's not that bad - it won't be wasting too much power compared with the GPS power saving. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-08 by HughB Found this useful bit code code for configuring a UBX GPS via python. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-10 by HughB This link indicates that UBX-CFG-CFG/ save needs to be called otherwise the configuration is lost when the GPS wakes up. I have built a basic widget but after 4hrs 58% battery was left, indicating that approx 36mA being drawn per hr. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-11 by @gfwilliams
Actually that's quite good news - at least it means it's harder to brick the GPS or mess it up for other applications :) Do you have a link to your widget somewhere? I could run it here on the Bangle I have set up for power usage testing... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-11 by HughB Here is the last version of my widget. Not yet checked into git. I dont think I have low power working yet. Have been looking at other code across the web, github etc. I have added some new functions tonight but they are not tested yet. I've not yet spent the time of the settings file so to switch on and off have using command line whne connected through the IDE.
The Widget.
As a client I have defined a watch face for multiclock.
I will probably have another hack-fest on Wednesday night, get the settings working. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-11 by HughB Here's my test bed code (based on your test code). I just load it into the IDE and test via the command line. Hoping some of the PM2 functions does the trick, though I can see lots of questions on the web on how to get this to work. I am switching evenings between writing bits of code and reading the datasheet and doing a test session on another day.
I am hoping if you can test connected to a milliamp meter on the bench you might be able to find the right sequence to get to the magic 2mA current usage. I am looking for a usable fix update between 30-60 seconds. This is why I have set UBX_CFG_PM2 to 30 and 20 seconds for the update and search times (though as I say, yet to try these new functions, I have just drafted them out tonight). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-12 by @gfwilliams Ok, so quick testing: Normally, Bangle.js draws 33-37mA with the GPS on. With just However just running Looking at https://www.u-blox.com/sites/default/files/EVK-M8BZOE_UserGuide_%28UBX-17053592%29.pdf
So that could be an option I guess? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-01-12 by HughB I agree. In my code widget I have drafted functions marked NEW/NOT TESTED I have done the code for UBX-CFG-PM2(), not been able to test yet. I read the above comment in the datasheet a while back but did not understand what it meant. I now understand that UBX-CFG-PMS is mean't to be a superset for power management. Hovever PMS seems a bit redundant when it sounds like you have to fill in PM2 as well. One of the power management PDFs shows a chart saying you can get 2ms when using a 10s interval period - the holy grail I guess. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-09 by user125066 @gfwilliams, Thanks for the quick answer a couple of days ago. Sorry about the delay, I have 'been bush' field testing the Bangle.JS If I follow what you are saying :
Is that right? Thanks, Mike. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-09 by @gfwilliams Hi Mike, I think things are a little 'in flux' at the moment - it turns out the GPS Low Power Service widget isn't required and we'll likely be removing it soon as it complicates matters. In a few days time, this will be the situation:
Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-09 by HughB Pretty close to pushing the GPS Setup app out in the next couple of days. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-09 by HughB Bangle.setGPSPower(1, "myappid") - sounds a good idea. But I agree about the power, always my worry too, thats why I have done the tiny GPS widget, I want to know when the the power hungry parts of the hardware are on. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-09 by user125066 Sounds good but I am not using the widget in a static way so I hope I can still dynamically change mode as needed. Will there be an API to allow me to dynamically change the GPS mode? My speedalt app functions like a watch face in that it obeys the screen off timeouts etc. You can flick the screen on for 10 secs for a look with a wrist movement etc. While the screen is on it uses the current widget call to switch to SuperE mode and when the screen goes off it switches to PMOO mode. Worked really well over a two day hike plus 4 hours of driving on a single charge last weekend. ( Actually drops to PMOO mode 15 secs after the screen is turned off allowing a little time to restore the screen if you want to keep viewing it ) Alternatively, perhaps make that behavior one of the baked-in options in your settings app? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-10 by user125066 Hi Gordon, I should have added. No rush. The work that you folk have done on the GPS power management improvements is just fantastic. Best to think it through and get it right so no pressure. Keen to help or test if I can. Cheers Mike |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-10 by @gfwilliams That's a really nice use-case! I think that probably what makes the most sense is to tweak the new GPS Settings app (now merged in!) such that it provides a module, and you can do something like:
I'll do that before we do anything with the widget anyway. I think it's a bit more flexible as it means the widget isn't sitting there using RAM when you're not running a GPS app. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-10 by HughB Do we need the equivalent of a library or will the GPS setup app work as a library if you use require() ? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-10 by user125066 That looks elegant and simple. How about some control over the timing settings as parameters? Something like :
And a way of reading current state ? ( eg. whether on/off, mode and current settings ) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-11 by @gfwilliams We'll have to add a library inside the GPS Setup app, but it's pretty easy to do. I'll look into adding that today. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-11 by @gfwilliams Ok, just added: https://github.com/espruino/BangleApps/tree/master/apps/gpssetup#module |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-11 by HughB Wonderful. I think we have a problem with the calling of the GPSSetup functions through promises. Everything looks like it works BUT in practice it looks like the settings do not take effect. This is a bit of uncertainty principle with this issues when you go looking for it - its not there. What I observed last night.
My only conclusion is that something unknown is going on when we use the Promise / delay() way of sequencing the setup functions. To fully reproduce
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-11 by HughB Hmm, upgraded to gpssetup 0.02 and can't reproduce. Been testing against the window sill. Maybe try a walk later. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-12 by user125066 Have just incorporated this into the speedalt app. Testing now and looking really good. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-02-12 by @gfwilliams That's great - thanks! Odd that it didn't work initially though - maybe some files updated but not others. One thing to be wary of with the GPS setup app is if you just change the settings and then exit with a long-press of BTN3, it won't write the settings. It's only if you go back using the |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-12-31 by HughB
Apologies for posting again. My original post was in New Projects which I realise was the wrong place.
I have question around power management options for the GPS and how to minimise power consumption over frequency of updates.
In GPS-comms.js on github I can see:
Could someone explain what the parameters mean ?
How could I set the GPS to only look for an update every 120 seconds ?
Thanks
Hugh
Beta Was this translation helpful? Give feedback.
All reactions