Rodemfr / MicronetToNMEA

A NMEA 0183 converter for Raymarine's wireless instruments ... and much more !
GNU General Public License v3.0
21 stars 8 forks source link

Reduce power consumption by setting CC1101 to low power mode #13

Closed Rodemfr closed 2 years ago

Rodemfr commented 2 years ago

Currently, CC1101 is always listening to the radio even if network is only active less than 10% of the time. A mecanism should be implemented to switch CC1101 to low power during idle phases of network.

Rodemfr commented 2 years ago

I pushed the first version of "low power" version of MicronetToNMEA in "low_power_cc1101" branch. Its works fine on my setup. I use two features to reduce power consumption :

The setup I used to test consumption is :

Results are : CPU@120MHz - No power saving -> ~987mW / ~79ma@12.5V CPU@120MHz - WFI Only -> ~812mW / ~65ma@12.5V CPU@120MHz - WFI & XTAL off -> ~712mW / ~57ma@12.5V CPU@24MHz - No power saving -> ~750mW / ~60ma@12.5V CPU@24MHz - WFI Only -> ~712mW / ~57ma@12.5V CPU@24MHz - XTAL Only -> ~650mW / ~52ma@12.5V CPU@24MHz - WFI & XTAL off -> ~575mW / ~46ma@12.5V

I can not measure power consumption on Teensy 4.0 but this could be a bit worse since WFI can not be used on it. It seems that time counters of Teensy 4.0 are handled in yield() function instead of interrupts like on Teensy 3.5. This makes micros() function fail when using WFI. WFI might disturb the system on Teensy 3.5 too, that's why I will continue testing before merging to master.

Rodemfr commented 2 years ago

@dwarning & @j-lang it would be great if you could test this SW, especially if you can measure Power consumption. If this version works well, I will number it 1.0 !

dwarning commented 2 years ago

@Rodemfr : Which board should I use for testing? I see WFI is disabled for 4.x, is there a power saving for this boards too?

Rodemfr commented 2 years ago

Preferably a teensy 4.x if you can. It will be interesting to compare to Teensy 3.5. Thanks ! WFI instruction disturbs micros() measurements on Teensy 4.x while it doesn't on 3.5. Implementation of systick seems different between the two boards (IRQ for 3.5, yield() loop for 4.x).

Rodemfr commented 2 years ago

By the way, you directly test the "continous-freq_correction" branch which derivates from the low power one. If its OK, I will merge everything in master and contemplate version 1.0 of MicronetToNMEA.

dwarning commented 2 years ago

OK, but how to switch on/off the feature to make the compare? EDIT: Or to compare to master?

dwarning commented 2 years ago

This I got with current measurement inserted in the USB+ line. Compared latest continuous_freq branch with actual master. Maybe the subtracted power from the 3 additional boards are not correct, but they are same for both measurements. Display was checked. So, in my setup the power dissipation is higher for the LP feature.

`<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

  | VCC [V] | Current [mA] | P cnt_frq [mW] |   | Current [mA] | P master [mW] -- | -- | -- | -- | -- | -- | -- USB | 5 | 150 | 750 |   | 132 | 660 UBLOX M8N | 5 | -40 | -200 |   | -40 | -200 CC1101 | 3,3 | -35 | -115,5 |   | -35 | -115,5 LSM303DLHC | 3,3 | -10 | -33 |   | -10 | -33 Teensy 4.1 |   |   | 401,5 |   |   | 311,5

`

Rodemfr commented 2 years ago

Thanks a lot ! Very strange results, not at all what I see with my Teensy 3.5. I need to investigate further. I will redo measurements of the master branch to compare...

Rodemfr commented 2 years ago

I think I understood your readings : I commited WFI to master. So WFI was active in your master test. This explains the drop from 401.5 to 311.5. However, CC1101 does not change its current while it should. This could also be explained by the fact that WFI is disturbing timing measurements on Teensy 4, thus putting CC1101 in an uncontrolled state. Did you check that your display were working during your measurements ?

dwarning commented 2 years ago

Not to misunderstand - only the USB current is measured the module currents are estimated. I can make with some effort separate measurements. As I said, display was well in both setups. I just seeing my pull of the master branch was not actual - it was from 15th July. Sorry - I will repeat this run with your commits from 17th.

dwarning commented 2 years ago

Ok, with really the actual master state the current in USB+ line is about 150mA with peaks to 160mA. Display show all values.

Rodemfr commented 2 years ago

I finally merged everything in master to avoid enabling WFI on Teensy 4.x since it is causing troubles for me. Now, I need to understand why you still have display with WFI on teensy 4 while I haven't.

Thanks anyway for taking the time to test.

dwarning commented 2 years ago

Forgot to say - the only diff to master branch is my BoardConfig.h BoardConfig.h.txt .

dwarning commented 2 years ago

Two measurements with poor man's diff mode, a 2Ohm resistor in the usb power line. Both compiled with actual master code: First the T3.6 with an average 115mA master_t36 Second the T4.1 with an average of 150mA master_t41

j-lang commented 2 years ago

@dwarning & @j-lang it would be great if you could test this SW, especially if you can measure Power consumption. If this version works well, I will number it 1.0 !

Tested current master and noticed it works great. Made a test by activating all GPS messages and the display still shows all values. Added a simple modification to M8Ndriver, added config for "at sea" according to: https://www.optimalsystem.de/os/docs/u-blox-gnss-konfigurationsanleitung.pdf

Rodemfr commented 2 years ago

Thanks j-lang ! I merged your pull requests. Note that I'm almost sure there is a sleeping bug in all SW versions which can make the software crash after some time. So keep an eye of potential display freeze with your setup. I'm currently studying how to imprve my debug capabilities to solve it.

Rodemfr commented 2 years ago

@dwarning : your measurements on USB power perfectly match the values given by my external power supply.