Open reversebias opened 7 years ago
While waiting for my mitosis parts to arrive, I took a look at the transmiter code and the datasheet of the chip. And I have some ideas how to optimize it:
when I will get my hands on the cpu and when I will have time to setup the toolchain, I will implement the changes myself if nobody will by that time (2-3 months from now).
I looked at the SDK and could not figure out default channel table size (it is <16 because of enforced 5 mhz spacing when generated), it is generated from paired hosts id because it must match on both ends. As per documentation, channel table hopping is used for synchronizaiton, afterwards it runs on selected frequency for the synchronization lifetime which can be canged (nrf_gzll_set_sync_lifetime), don't know the defaults, which would be nice! And regarding frequency, I think that the end of the frequency range tends to be more unused (around 2470-2480Mhz), at least where I am and in US!! I think that the reciever side could gather some statistics on which channels it recieves data most often and then use that information to eliminate bad chanels, inject some additional to try and update channel table on both ends. This is more effort to develop, but could greatly improve radio part, if it turns out to blame. Let's see how the radio part will work out for me, I am very concerned and worried of mitosis performance, because I work in very rf polluted enviroment where wireless devices are all over the place.
Thanks for the comments!
Default channel table is in sdk/components/properitary_rf/gzll/nrf_gzll_constants.h line 115: {4, 25, 42, 63, 77}, which is just 2404, 2425, 2442, 2463, 2477MHz respectively. If you're feeling a little rebellious, the chip supports channels out of the licenced bands too, but of course I wouldn't default that. I agree that dynamic table updating is the ideal way, but the current system works very well even in a heavy polluted environment, I've never noticed any missed events or lockups, just high retransmit attempts which causes high battery drain. Well, the high retransmits works well when the battery is above 20%, anyway.
I really appreciate the attention and suggestions, thanks.
In my case GP batteries went completely dead (0.6v) after about 1 month of sleep mode (jul 31 - sep 5). So yeah, something's going on there.
Yeah, this has progressively got worse for me. It may be that I've had a bad batch of batteries, but I've had a few only last a month too. A battery from the same batch with a 10mA CC load lasted out to 120mAh, but pulsed loads are probably a different thing.
I think that the chip draws much more power after a brown out, so internal resistance causing a dropout can can kill the entire cell. Obviously this is a bad thing.
I'm going to try running for a bit with alkaline cells, see if it's a firmware or a battery issue. Because tracing and summing the current for a transmit show millions of keystrokes possible, with 4uA sleep current, shouldn't kill a battery in weeks.
Have you considered adding a pair of through-holes and another regulator to allow for other battery options? For example, a JST connector/header for a thin lipo, or larger through-holes to fit something like this 18650 holder - that would double as a tenting mechanism
@whostoleallthenames I used an Adafruit JST-PH breakout board and a pair of female headers to connect a 3.7v lithium polymer battery pack to the programming pins in a way that's easily removable. So far, this is working great, seems like no regulator is required. 😄
@datagrok Is that powering the board through the programming pins? Which pins are which?
@whostoleallthenames yes it is! Connect the positive terminal to the one closest to the word "Mitosis." Connect the negative terminal to the one adjacent to that. The other two are data pins only for programming. It's the same arrangement on the left and right board (so my little adapter has to be connected upside-down on one side and right-side up on the other).
@kdayns could you look at https://github.com/joric/mitosis/tree/devel/mitosis-bluetooth it's very alpha but it works, maybe you could help with the battery life there as well. I don't think it's even remotely energy effective at the moment.
I've noticed keyboards send gazell packets in bursts, like 6-7 the same packets for every pressed key. Shouldn't they send only one?
I am running firmware with the following modifications:
I am writing this here because on my rigth side the battery just died in exatly 3 months. I was expecting much longer life because of the tweaks, but as I already told you, I am working in place with lots of wifi devices around, so maybe it is still a good number, I wanted to know the max I can get. I will wait for my left side to die and then I will enable rtc1 and see how it will effect the results, because I am getting pissed lately at the stuck keys. Or maybe I have too low keyboard tx power for my aggressive environment.
Joric, I will check this week how many retransmits per keypress I am getting, but as far as I can remember, you have lower number than I did.
It is hard to know how many keypresses in total was processed by each side for effective comparison, I tried running hid_listed which logged some info, but I think It started to perform not very vell after some hours or days of operation and I dropped the idea. maybe I will debug it when I will collect the retransmit stats.
It would be interesting to wire the antennas directly together to exclude the radio interferrence in battery life, but then we need somebody to comment on how to properly do that.
@kdayns I don't know why you have 40 tx attempts I currently just use nrf_gzll_set_max_tx_attempts(0);
in mitosis-bluetooth and it apparently works (reversebias uses 100), both for gazell client and for host (they're switchable in runtime). Also there's no debouncing anymore I just scan with 25 ms interval (I thought it sucks but figures out it's a good scan rate, many people use it). With all that, it doesn't look like I'm losing or skip keystrokes. Also I'm completely shutting down the board after, like, 4 minutes and it just reboots on keypress, seems fine.
@joric max tx attempts 0 means maximum!
I am also noticing the same thing about multiple retransmissions, but sending(pressing buttons fast) very often helps, the retransmissions go down, this gave me a clue. I checked the documentation on how the devices mainain the synchronization and found out that nrf_gzll_set_sync_lifetime
can change that value which when expired will lead to retransmissions!
When I have time I will try to play with this value, but right now I am getting ~50% packets without retransmissions when typing the other are the same as yours (<10), just collected the stats from 5k strokes.
I tried increasing sync lifetime 2x and collected the stats on ~100k strokes. This change greatly improved packet delivery for me, packets without re-transmissions have increased from 50% to 67%. That is significant, but I bet it also depends on the typing speed as well.
@kdayns, it's claimed that this fork has better battery life:
FYI, there was a bug in the firmware which caused the receiver to constantly search for the boards, thus quickly draining the batteries.
See the fix here: https://github.com/repne/mitosis
After using the fixed firmware, the batteries work just fine. I'm currently 7 months in using the same set of batteries.
If someone could make a pull request out of it and get it merged that'd be cool.
yeah, I don't see the fix too, just different debounce logic. Maybe it is relevant only to the repne's branch. I just want to remind you, the battery life will be proportional to the amount of typing done.
@kdayns, not just debounce, it uses a single RTC timer at 125ms. Plus there's something going on with the receiver as well.
I'am also running single rtc but at 1ms, debounce, send and go to sleep.
I was the one who said he was on 7 months with the same batteries that @joric linked to above. The modifications seriously made a huge difference in battery life.
It seems like he changed up debounce logic, single RTC, antenna at 4 dbm, changes for receiver timeout, (6 ms) and a few other things in the receiver code that I haven't had a chance to sift through yet However, some of it looks like its just cleanup by moving certain things that used to be in the main function into their own separate functions to be called upon.
I'm looking at some of the commentary that Repne made in my Discord channel while he was actively working on the fork, and here are a few things he mentioned:
I've cleaned up the receiver code and made the antenna to work at 4 dbm (it was 0) it will consume more power, but thanks to the many power fixes I've made to the original firmware, it should at least cancel out (but I'm much more optimistic than that) timeout time it's been set to 6 seconds (that's how long you can press a key) it was a random amount before
Thanks, @nhou7 I'll check it up. I'm also considering a possibility of adding bluetooth (nrf5x) support to QMK, instead of adding QMK to the bluetooth firmware (QMK is not really a library, rather a hardware platform), might be easier this way. Upd. added bluetooth support to this firmware, haven't checked battery life https://github.com/joric/bluetosis but it's sure even worse.
I just had a CR2032 battery in one of my keyboard halves die on me, after 2.5 months of use. This is much lower life than I expected, as calculations showed 6-12 months of use.
Possible causes:
If there's none of the above, possible ways to reduce power consumption:
I know it'll take months before anyone has another data point, but does anyone have any ideas?