I'm trying to add 2 analog sensors to my APM2.5 system, both are 5v potentiometers.

This is the essential code that I have added to the system:

static int read_alpha(void)
  int alpha;
  alpha = analogRead(7); //initially on 6, switch to 7
  return alpha;

I am calling this at 10Hz inside the medium loop, although would prefer to read it at 50 Hz. Unfortunately it looks as if I am not reading data properly, something is going on with the hardware or software that I do not fully understand. Attached are plots showing the logged data at 10 Hz with weird drops back to a static value.

Any help is greatly appreciated.

Views: 2454

Reply to This

Replies to This Discussion

Ok I will bite. Where are you adding the sensor inputs to?

Are you using the current and voltage inputs? Other pins?

Is there a schematic of this added circuitry -- though it only sounds like you added potentiometers.

I think we need more information to discuss this. It almost sounds like you are using the APM as a data-logger front end.


Doug, thank you for your assistance.

That is exactly what I am trying to do, just log data with this particular configuration. I would do everything on-board but the dataflash space isn't sufficient.

I found a few things, for starters the analog pinouts aren't quite correct, they are spelled out here: http://arduino.cc/forum/index.php/topic,13779.0.html#8

I am using the A0, pin 54, for airspeed. I am using A6 and A7 for alpha/beta respectively, and not using any other a/d features, although some may be enabled in the APM v2.68 software. As far as circuit schematic, we are effectively only connecting a 5v potentiometer to A6 and A7. GND runs to the pot ground, 5V+ from the center pin goes into the pot, and the pot output runs into the signal pin on the Ardupilot. Does that make sense?

I also did testing using very basic example code, and had similar results. Its clear that I am not sampling the pins correctly. In the below plots, I am doing a simple loopback test (+5v goes to signal) on A6 and leaving the other pins floating. You can see the 5v is pulling A7 higher as well.

Are you planning to add this functionality to an aircraft?

If not, I am not certain that the programming of all the subsections of the APM may be compatible to your goal.

True that it is an Arduino. More to the point is that it has been specialized in purpose and the support chips have firmware that has been written to the purpose.

Are you familiar with the Eagle files for APM?



I am trying to do the same thing, is there any guide for using external analog device , with the HAL cover?


I´m trying to exactly the same? Any suggestion?

  Thanks! :-)

Reply to Discussion



Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service