Good afternoon,

I am trying to connect an Analog to Digital Converter (this one), so I'm using the driver of the libraries/AP_ADC folder.

To log the data, I created a function in the class Plane of Arduplane that simply reads from the ADC and send it to the ground control station. But now I don't want it to send it in that method, I want to send it when it sends the rest of the data, so I wanted to create an attribute of the class Plane and store it there.

The problem I am having is that everytime I try to assign something to that attribute and I compile the code and install it on my Pixhawk, it doesn't connect, and the amber light blinks at 4Hz (which according to pixhawk webpage that means that there's no FMU input) and blue light blinks at 2Hz (which means that the heartbeat loop is running).

I declare my variable and functions as follows in the Plane.h file:

adc_report_s *report;
void adc_read ();

When I do it with a variable declared inside the function it works perfect, but as soon as I do something like: report = local_var; it doesn't work. Also if I do: report = new adc_report_s[channel_number] also crashes.

Also another problem I am finding is that I need to log the data into the DataFlash. For that, I created my own struct in the file ArduPlane/Log.cpp with the data I want to save and I call to DataFlash.WriteBlock, as it's done with other type of data in the code. Also I have edited the log_structure to add the following code:

{ LOG_ADC_MSG, sizeof(log_ADC),
      "ADC", "Qffffff",  "TimeUS,ADDR,ALRT,A0,A1,A2,A3" },

Where LOG_ADC_MSG is declared in log_messages at the file define.h, and log_ADC is the struct. I call my method that calls to WriteBlock in a Scheduled task, and I could see that is called, but then in the log I can't see the data. Neither I can't see other data from the end of the log_structure variable

Hope you can help me and thanks in advance.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Activity