Pixhawk custom sensor integration

Hi everyone,

i am trying to integrate a wind sensor into Pixhawks hard- and software. All the work is done within my masters thesis.

Since now things worked good and I build a 5kg octokopter controlled by the pixhawk running arducopter on it. I already mounted the sensor on the copter and connected it to the serial 5 port. The sensor outputs the data as an RS232 signal which is converted via MAX3232 to 5V TTL level. So all the physical work is done and I have to do the software integration now. I spent a lot of work on changing the sf0x driver (also connected via serial port if you use it) from the pixhawk code base to my needs without success. What I wanted to do is reading the sensor data through the serial port and log it on the sd card. If it is possible I want to use the arducopter code base to be still able to connect to mission planner.

The message from the sensor looks like this:

<STX><ID>,11.111,22.222,33.333,44.444<ETX>CC<CR><LF>

Is there anybody who has done something similar and can share some code or help me ???

I´m really looking forward to hearing fom you!

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

Join diydrones

Email me when people reply –

Replies

                • I´m in big trouble !!!

                  Hi everyone, I added and changed the code like James told above. If I start the pixhawk there are only some bytes coming into the serial port. But these are not the bytes beeing sent from the sensor. There are only some random characters and special signs arriving in the console. (I´m using putty connected to the usb port of pixhawk at 38400 baud to display the console; I prited out "numc" and "data" from the UserCode.pde) But I´m sure that the sensor is configured at 19200 baud and sending data at 10Hz.

                  I also tried the code posted above with an arduino and it worked very well without modification. So everthing is hooked up correctly and the sensor is working. TX and RX are correctly connected and the baudrate is the same on both ends. 

                  Moreover I tried to send a copy of the sensor data string from the arduino to the pixhawk port which gave the same corrupted input in pixhawk.

                  It is like the data is not arriving the right way in the buffer or something like that. 

                  So I think there is a problem with the serial 4 (I also tried telemetry 2) -port on pixhawk. Is there a trick to unlock this ports for serial input ???

                  Do I have to change the initialisation of this ports somewhere else in the code ???

                  Is my code interfering with mavlink and do I have to disable/ enable mavlink on the used port?

                  I REALLY dont know how to get things done because I know the code is able to work on an arduino and handling time of my master thesis is going out.

                  I guess there are also other people out there having the same problem as I read in some threads, but nobody posted a solution.

                  If someone could help here I think this thread would be the first step by step instruction for a pixhawk custom sensor integration and reading serial data into it.  

                  James how did you managed this problem?

                  Thanks in advance !!!

                  Greets Marvin

                  • Hi Marvin,

                    (I´m using putty connected to the usb port of pixhawk at 38400 baud to display the console; I prited out "numc" and "data" from the UserCode.pde)

                    The USB port is used for telemetry/mavlink data so if you connect directly to it using Putty you will see that heartbeat packets. Even if you are connected at the same baud rate configured for this port, the data is binary so will appear essentially as random chars...

                    For the purpose of debugging you can use Putty to telnet to port 2300 while Mission Planner is running and connected to the Pixhawk. This will display anything written to the console without all the other mavlink data.

                    All the serial ports on the Pixhawk are configured for specific use by default. If you want to re-purpose one you will need to find where it is initialised and comment it out (ie uartE for the 2nd GPS port)

                    Cheers,

                    James

                  • Thank you Chris!

                    I´m using ArduCopter 3.2.

                    I found in ArduCopter   >  system.pde (l.106 - 110)

                    and in ArduCopter   >  ArduCopter.pde the same (l. 15468 - 15472)

                    #if GPS2_ENABLE
                        if (hal.uartE != NULL) {
                            hal.uartE->begin(38400, 256, 16);
                        }
                    #endif

                    I´ll change this to my baudrate of 19200 so it will work if I enable GPS2.

                    Do you think these modifications on ArduCopter are enough or do I have to change something on PX4 flight stack too?

                  • Marvin,

                    What version of the Arducopter code are you using? In 3.2, both serial 4 and 5 have already been assigned other purposes, a 3rd telemetry port and a 2nd gps. You'll have to search through the code and repurpose whichever serial port you were planning to use.

                    -Chris

                • Thank you very much James!

                  It´s quite a long time ago since I joint this thread but now I´ll work further on my drone.

                  I´m really sorry but at the moment I´m not allowed to tell any details about the sensor.

                  Maybe you would like to have a look at my other thread?

                  Uploading and Compiling ArduCopter V3.2 with Eclipse

                  Greets Marvin

    • Hi James,

      that sounds good and is exactly what I want to do. Yes you are right it is quite difficult to find the best place for mounting the sensor. I did some cfd simulations on this and I can tell you that on the upper side of the copter there is the best place to position the sensor.

      Moreover you have to calculate the influence of the motion produced by the attitude control all the time.

      Thank you so far. Hope you get things done soon because I'm curious to have a look at your code.

This reply was deleted.

Activity