dgatf / msrc

Multi Sensor for RC with RP2040 - FrSky D, SmartPort, XBUS, SRXL, IBUS, SBUS, Multiplex Sensor Bus, Jeti Ex Bus, Hitec
GNU General Public License v3.0
168 stars 41 forks source link

Calculate mAh used and update smartport EscC telemetry value #42

Closed MJ666 closed 2 years ago

MJ666 commented 3 years ago

This is still work in progress and untested. Feedback would be appreciated. Please don't merge yet.

MJ666 commented 3 years ago

Rebased to master.

dgatf commented 3 years ago

Does this have an advantage from adding a calculated sensor in opentx?

The consumption can be calculated in opentx from the current by adding a sensor of type Calculated, formula Consumption and sensor EscA

The issue of this PR is that it increases the flash size so it does not fit in the pro mini:

Master branch RAM: [==== ] 44.6% (used 913 bytes from 2048 bytes) Flash: [==========] 96.9% (used 29766 bytes from 30720 bytes)

Calculate consumption RAM: [===== ] 46.1% (used 945 bytes from 2048 bytes) Flash: [==========] 100.4% (used 30830 bytes from 30720 bytes)

It may be added to boards with more flash size though

MJ666 commented 3 years ago

The advantage i see is we not transfer an empty telemetry value. Likely calculate this in the TX will also be fine. I will have some test logs containing information about the differences soon. Actual i have installed an FLVSS lipo sensor and FAS100S current sensor in addition to the MSRC in the Heli to compare. I'm planning to remove the FAS100S later after im satisfied with the current measurements of MSRC. We may make this code as an compile time configuration option for targets with sufficient memory?

emilverwoerd commented 2 years ago

I think it would be nice if this feature is added not all transmitters have the capability to calculate MaH used. However there is also the problem of offset so you should be able to add a percentage which gives the ability to show 95% off the calculated value.

As for memory footprint I think the pro mini is quite old so in the end you get to the problem it doesn't fit all on the board

MJ666 commented 2 years ago

Rebased against actual master. @emilverwoerd you can download from here and test: https://github.com/MJ666/msrc/tree/consumption

In general the code could be enhanced to only get included for boards with more memory. Another option to save memory could be to to allow only to included the ESC, telemetry protocols or sensor drivers which are really used by the the end-user. This likely need some more intrusive code changes.

dgatf commented 2 years ago

In general the code could be enhanced to only get included for boards with more memory. Another option to save memory could be to to allow only to included the ESC, telemetry protocols or sensor drivers which are really used by the the end-user. This likely need some more intrusive code changes.

Yes, for smartport and boards with 32kb or less I'll include only the esc driver defined in config.h. This frees about 10kb, allowing to add other esc protocols and this PR. Working on it

dgatf commented 2 years ago

Well, it seems that I've freed some flash somewhere else, probably with the serial drivers and now the PR fits

Thanks.

derFliegendeHamburger commented 2 years ago

Well, it seems that I've freed some flash somewhere else, probably with the serial drivers and now the PR fits

would that be enough for the debug code? Then that is cool

dgatf commented 2 years ago

Debug code also fits. Now in debug mode some code is disabled for boards with 32kb or less