ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Analog input pin logging and MAVLink transmission

Open messmc9 opened this issue 12 years ago • 20 comments

It would be nice to have additional analog inputs available on APM which can be enable for arbitrary sensors. i.e. I would like to run by FPV battery through a voltage divider and display its voltage in the HUD in addition to my main flight battery and on my gas plane I want to display the receiver battery voltage as well as a fuel level sensor.

I would like to see parameters for each analog pin that allow enable/disable and input range (0-5V, 0-3.3V, etc).

messmc9 avatar Mar 05 '14 01:03 messmc9

+1 to this. I would like to be able to display motor temperature on my MinimOSD. I've hooked up an LM32 temperature sensor, intending to plug it in to one of the APM2.6 analog inputs. Currently the only option to get it read and sent via MavLink, is to pretend its a Sonar analog input. It is possible to do that in Arduplane, but to get it working I need to enable sonar and I'm not sure of the consequences of doing that when the code thinks the temperature data actually is a sonar height data., so having some uncommitted analog pins available and which can be sent via mavlink would be great.

kwikius avatar Jun 19 '14 10:06 kwikius

@hiro2233

hiro2233 avatar Sep 08 '16 10:09 hiro2233

I'm interested in taking this up. Here's what I propose:

A new mavlink message ANALOG_VALUE with two fields: uint8_t id float voltage

jaxxzer avatar Apr 24 '18 19:04 jaxxzer

Need to figure out a way of how to enable/disable reading and reporting of these values.

Maybe something like a parameter-per-instance so on the pixhawk it would look like: ANALOG_1_ENABLE (3v3 #1) ANALOG_2_ENABLE (3v3 #2) ANALOG_3_ENABLE (6v6)

Set to non-zero value to start reading/transmitting/logging the analog value.

jaxxzer avatar Apr 24 '18 19:04 jaxxzer

I can start on this as soon as there is some opinion on the direction I should take.

jaxxzer avatar Apr 25 '18 15:04 jaxxzer

If we simply report an adc voltage value, then users can easily play with or obtain useful data for any sensor that has an analog output. Developers can use the same functionality to do quickly evaluate new sensors to determine if their performance warrants dedicated support and explicit integration.

jaxxzer avatar Apr 26 '18 14:04 jaxxzer

Any analog inputs @ArduPilot/ardupilot-maintainers?

jaxxzer avatar Apr 27 '18 04:04 jaxxzer

@jaxxzer I would say to label it as DevCallTopic, more chances of input there.

OXINARF avatar Apr 27 '18 09:04 OXINARF

@OXINARF ok, I was trying to have a PR together by that time.

jaxxzer avatar Apr 27 '18 14:04 jaxxzer

Use existing AP_ADC message

This bit of code is of interest.

Will add to sub data stream by default for now.

jaxxzer avatar Apr 30 '18 23:04 jaxxzer

how far along is this? I was looking at using one of the ADC pins to log and monitor a sensor on a plane, currently im using it via a frsky receivers ADC port but i would prefer it through mission planner.

geofrancis avatar May 29 '18 18:05 geofrancis

Stalled out till we have a new ADC interface in the HAL. That could take quite some time.

https://github.com/ArduPilot/ardupilot/issues/8527

jaxxzer avatar May 29 '18 18:05 jaxxzer

looks like im going to have to bodge batt2 input to get the readings,

geofrancis avatar May 30 '18 08:05 geofrancis

Hello! Any update on this topic? I would love to see it fully implemented!

ghost avatar Jun 21 '21 07:06 ghost

I suspect the best way to handle this is using a lua script. We have a simple example here.

rmackay9 avatar Jun 21 '21 08:06 rmackay9

And then should I add a MavLink message to map this reading? I was also considering this solution https://discuss.ardupilot.org/t/pixhawk-adc-and-mavlink/35883 But it's sure that an integrated analog monitor as suggested in this thread could be very interesting for many applications!

ghost avatar Jun 21 '21 08:06 ghost

@alessandrogenoni, I'm not sure of what would be the best way to send this info... I would re-use some other message that AP doesn't normally use or maybe there is a way to send a custom field. I'm sure I saw a message that allowed sending a string and a value but I can't immediately find it again.

rmackay9 avatar Jun 21 '21 08:06 rmackay9

@rmackay9 thank you very much for the info. Just to understand, is this request currently being worked on? (still marked as open). Another option to achieve a similar results would be to allow the implementation of new MavLink messages through LUA scripts (https://discuss.ardupilot.org/t/lua-script-send-mavlink-command-to-fc/64965). Is any of this feasible? I'm in the need for an analog sensor logging and mavlink transmission for an external sensor and I'm currently not skilled enough to go and change the source code without risking major issues and general malfunctioning of my vehicle, so an integrated way as suggested by @jaxxzer or anything similar would be excellent. Thank you all

ghost avatar Jun 21 '21 09:06 ghost

@alessandrogenoni,

I don't think that anyone is working on this at the moment and I don't think there is actually an easy way to know if any particular item is being actively worked on.

Lua scripts can't create new mavlink messages I'm afraid because both sides need to know the format of the message in advance. MAVlink is not what we'd call a "self describing protocol".

I wish I had better news but you know.. there are just so many enhancement requests..

rmackay9 avatar Jun 21 '21 13:06 rmackay9

We now have analog inputs in scripting and the ability to send named value floats, these can be disaplayed with the correct name by both Mission planner and MAVProxy.

Analog input example here: https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_Scripting/examples/analog_input_and_GPIO.lua

Sensor reporting back using named floats here: https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_Scripting/examples/SN-GCJA5-particle-sensor.lua

IamPete1 avatar Aug 14 '21 22:08 IamPete1