Hi everyone,
Does anyone have experience with configuring their own sensors onto the Pixhawk (I have an IRIS)? I purchased a gas sensor that I'd like to wire to it, does anyone know of any good resources to help me get started? I've downloaded the PX4 development environment from the Pixhawk developers website and have gone through some of the "getting started" instructions on there, I have been able to install the firmware through Eclipse as opposed to the Mission Planner. I also purchased 3-position and 5-position connectors for the analog inputs.
I was also wondering if there is a way to view the telemetry log data on Mission Planner during flight? If I did add this sensor, would data be saved through the telemetry logs or dataflash logs?
I appreciate whatever help I can get, thank you!
Kate
Replies
Hi Aaron, I am working in a project very similar to what you have done.
I have al ready connect some sensors via i2c to the pixhawk, but I can´t make the changes in the mavlink, can you show us how to make it ?
Aaron Curtis said:
Hi,
Glad I found this post. I have had some success in connecting an Odroid XU4 to a Pixhawk using the UART-USB connection to the telemetry. The sad thing is that the connection is intermittent (might be an issue with my connection setup). however, it does read the gas sensor (I tried an CO2 sensor) connected to the ADC pin on the odroid and display the voltage readings.. the parts per million(concentration levels can be easily obtained from the voltage given). I can send details of how to connect to anyone interested.
What I am in need of is to trace a plume based on the concentration levels and have a drone navigate that to locate the source of the plume.. any ideas would be most welcome..
Good post folks.. Keep up the good work
Cheers
Prasanna
Thanks for the encouragement, Eric. Will do!!
It would be great if someone who knows what they are doing could write a set of instructions (including a flow chart) to show how to read an additional ADC pin and send the data to Mavlink and to log the data.
Anyone ?
Hi Katie, I have flown with CO2, SO2, and H2S sensors on an APM. I hooked them up via I2C and then added a new dataflash 'GAS' log message and later also a mavlink message. Would be interested to hear more about your application, and happy to show you the code I used. It's in a local branch but if you remind me I'll push it to github. You can see the discussion I started here.
Aaron,
Glad to see someone else who's accomplished configuring gas sensors to the APM. I have an H2S gas sensor (link here) that I need to configure to the Pixhawk. How did you test/calibrate the sensors? Definitely interested in hearing about your experiments.
Thanks!
I had a bit of a play on the Pixhawk and managed to view live data from the ADC pins (13 in example) via telemetry. I simply read the adc pin and assigned the value to sonar_alt. I also altered the mavlink code to transmit sonar_alt even when it is disabled in the parameters. I could view the value live in MP as sonarrange and it is also available as mavlink_rangefinder_t.distance in the tlog. I note that the same message records the sonarvoltage parameter as well so you could potentially pass two separate readings by overriding this message.
GCS_Mavlink.pde (starting at line 486 in current master):
#if CONFIG_SONAR == ENABLED
static void NOINLINE send_rangefinder(mavlink_channel_t chan)
{
// exit immediately if sonar is disabled
if (!g.sonar_enabled) {
// return; commented out this line to force message to be sent
}
mavlink_msg_rangefinder_send(chan, sonar_alt * 0.01f, 0); // you can scale the parameters as you need. The 3rd param is supposed to be sonar voltage (not used in this code and is 0) and could potentially be another variable
}
#endif
UserCode.pde:
AP_HAL::AnalogSource *test_adc;
#ifdef USERHOOK_INIT
void userhook_init()
{
test_adc = hal.analogin->channel(13);
}
#endif
#ifdef USERHOOK_MEDIUMLOOP
void userhook_MediumLoop()
{
// put your 10Hz code here
sonar_alt=test_adc->voltage_latest();
}
#endif
Don't forget to uncomment USERHOOK_INIT and USERHOOK_MEDIUMLOOP in APM_Config.h
James,
Does the above work? Even though you have commented out the return so that the message gets sent, if Sonar is not enabled, the whole section of code in GCS_Mavlink.pde will not run because of the #if CONFIG_SONAR == ENABLED.
If you enable sonar, then you will also enable the sonar behaviors. I would have thought that you would have been better off leaving Sonar disabled and modifying the code to be;
// #if CONFIG_SONAR == ENABLED
static void NOINLINE send_rangefinder(mavlink_channel_t chan)
{
// exit immediately if sonar is disabled
// if (!g.sonar_enabled) {
// return; commented out this line to force message to be sent
// }
mavlink_msg_rangefinder_send(chan, sonar_alt * 0.01f, 0);
}
// #endif
-
1
-
2
-
3
-
4
of 4 Next