Interfacing Pixhawk with Arduino

Hi all, I'm currently doing a project on obstacle avoidance using the Maxbotix 1240 sonar and the APM. As the APM has 11 ADC pins, i can easily read the value coming in from the sonars and write code to achieve avoidance. 

However, the problem now is that I have to use a Pixhawk instead of the APM. The first thing i've noticed is that the Pixhawk only has 3 ADC pins, while i need 5. Is it possible to use an external Arduino to read the values from the sonars and pass it to the Pixhawk or is there anyway to overcome this issue? 

http://www.maxbotix.com/Ultrasonic_Sensors/MB1240.htm

Any help would be greatly appreciated, thanks in advance and have an enjoyable day :D

Cheers,

Joshua Lay

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

Join diydrones

Email me when people reply –

Replies

  • Hi Stephen, i need your help for wire and setup a maxbotix 1202 and a 1242 on a arduino mini pro, coz im not able to make it work on my fc pixhawk and pixfalcon. Where i can find the .ino file so i can configure it?

    Hope in a your positive answer.




    Interfacing Pixhawk with Arduino
    Hi all, I'm currently doing a project on obstacle avoidance using the Maxbotix 1240 sonar and the APM. As the APM has 11 ADC pins, i can easily read…
  • You could use an Arduino to read in the 5 analogue readings and send them the the Pixhawk via UART (serial 4/5) or I2C.

    • Hi Stephen, many thanks for your reply. Do you have any examples i could refer to? Because i'm relatively new to this. And what is the difference between sending it through UART and I2C?

      • UART and I2C are different protocols. Both are used by Pixhawk - UART for GPS and telemetry, I2C for magnetometer and airspeed.

        If you're new to this, UART would be easier to understand as it is just sending simple text messages between devices.

        Here's a simple Arduino program for reading an analogue port and sending the result to the UART:

        /*
          ReadAnalogVoltage
          Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
          Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

         This example code is in the public domain.
         */

        // the setup routine runs once when you press reset:
        void setup() {
          // initialize serial communication at 9600 bits per second:
          Serial.begin(9600);
        }

        // the loop routine runs over and over again forever:
        void loop() {
          // read the input on analog pin 0:
          int sensorValue = analogRead(A0);
          // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
          float voltage = sensorValue * (5.0 / 1023.0);
          // print out the value you read:
          Serial.println(voltage);
        }

        • Okay, I'll have a look into it, but isn't this code used to read the values off the serial com? Or is it that if i connect the TX of arduino into the RX of the pixhawk, and i connect the RX of the arduino to the TX of the pixhawk, 

          One last question, how can i be able to read off the value in my pixhawk and use it in my program? 

          • UART = serial port, in this circumstance.

            No, this code isn't used to read values off the serial (UART) port. Quite the opposite - it reads analogue values and prints them to the serial port.

            It might be worth spending some time with some Arduino tutorials, as it sounds like you've not got much experience with programming them.

            Yes, the idea is that TX Arduino -> RX Pixhawk (and vice-versa) to create a communications link.

            There's details on the Pixhawk UARTs at http://dev.ardupilot.com/wiki/learning-ardupilot-uarts-and-the-cons...

            • Kk, Ill look into it. Thank you :D

This reply was deleted.

Activity