Adding MAVLINK support

ersky9x is a port of er9x for use on the sky9x board.
gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: RE: Re: Adding MAVLINK support

Post by gyrex » Sun Oct 30, 2016 10:56 am

MikeB wrote:It is set to 57600.

Mike.
Thanks Mike, is there any way to change this setting in the code?

Sent from my LG-H815 using Tapatalk

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Sun Oct 30, 2016 11:22 am

ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: RE: Re: Adding MAVLINK support

Post by gyrex » Sun Oct 30, 2016 12:58 pm

Thanks yet again Mike :)

Sent from my LG-H815 using Tapatalk

elkayem
Posts: 17
Joined: Sat Sep 24, 2016 7:45 pm
Country: -

Re: Adding MAVLINK support

Post by elkayem » Thu Nov 03, 2016 3:47 pm

On the topic of baud settings, I thought I would add this special note for anyone considering using the 3.3V Arduino Pro Mini instead of the 5V version. I didn't see any reference to the 3.3V version elsewhere on this thread, so I gather most are using 5V. I needed to use the 3.3V version because I am using a Beaglebone Black for my flight computer, which is not tolerant to 5V.

Anyway... the 3.3V version runs at 8 MHz instead of 16 MHz so also requires a small modification to the code. See viewtopic.php?f=95&t=9226 for a lengthy discussion on this topic. This is a very simple change to the code: Change UCSR0A = 2 (was 0) in the function initUart (in file APM_Mavlink_to_FrSky.ino). This change is for the most current commit in Mike's repository (Sept 28), though I did need to go back two commits to get it to work due to some changes in RSSI. It is possible that Mike may decide to make this function work for both 3.3V and 5V versions (wouldn't be hard to make initUart a funciton of F_CPU) but for now this is an easy and simple workaround.

Hopefully someone finds this useful. I must admit that adding the MAVLINK support for my radio has been a terrific upgrade, and shows me all the telemetry I want to see on one screen. Incidentally, I'm flying ArduCopter 3.4-rc4, so it is compatible with the latest builds.

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Thu Nov 03, 2016 5:06 pm

I need to commit the change, I've done it in the source code.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!


Geofrancis
Posts: 27
Joined: Sat Jul 02, 2016 10:44 am
Country: -

Re: Adding MAVLINK support

Post by Geofrancis » Wed Nov 09, 2016 3:11 am

elkayem wrote:On the topic of baud settings, I thought I would add this special note for anyone considering using the 3.3V Arduino Pro Mini instead of the 5V version. I didn't see any reference to the 3.3V version elsewhere on this thread, so I gather most are using 5V. I needed to use the 3.3V version because I am using a Beaglebone Black for my flight computer, which is not tolerant to 5V.

Anyway... the 3.3V version runs at 8 MHz instead of 16 MHz so also requires a small modification to the code. See viewtopic.php?f=95&t=9226 for a lengthy discussion on this topic. This is a very simple change to the code: Change UCSR0A = 2 (was 0) in the function initUart (in file APM_Mavlink_to_FrSky.ino). This change is for the most current commit in Mike's repository (Sept 28), though I did need to go back two commits to get it to work due to some changes in RSSI. It is possible that Mike may decide to make this function work for both 3.3V and 5V versions (wouldn't be hard to make initUart a funciton of F_CPU) but for now this is an easy and simple workaround.

Hopefully someone finds this useful. I must admit that adding the MAVLINK support for my radio has been a terrific upgrade, and shows me all the telemetry I want to see on one screen. Incidentally, I'm flying ArduCopter 3.4-rc4, so it is compatible with the latest builds.

i dont have any problems running 16mhz at 3.3v.

benzo99
Posts: 12
Joined: Sat Nov 05, 2016 10:39 am
Country: -

Re: Adding MAVLINK support

Post by benzo99 » Thu Nov 10, 2016 9:51 pm

I have a 9XR Pro, and an X8R receiver and DIY multi-protocol module on their way. I'm planning to put this in an APM-equipped Cheerson CX-20 running AC 3.2.1.

Until I read this thread I had planned to use the a Tennsy 3.2 with the code from this project to do MAVlink -> FrSky telemetry conversion. I already have Teensy 3.2 wired and programmed for this.

After reading this thread, it seems like this will work using the FrSky telemetry setting on the Tx, but I'll only get the telemetry values that are mapped to FrSky IDs by that project.

It looks like I have another option, which is to use Mike's MAVlink to FrSky code on an Arduino or Teensy, and use the ArduC telemetry setting, and it sounds like I'll get more options because Mike has put a lot of effort into mapping the data.

Do I have this right? I'm wondering what I should do. One thing I'm missing here are instructions for wiring Mike's solution up on a Teensy.

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Thu Nov 10, 2016 10:26 pm

My project is only for an Arduino (Pro Mini). I don't have a Teensy so never considered porting the code to that.

This post: viewtopic.php?f=7&t=8396#p110656 details the connections.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

benzo99
Posts: 12
Joined: Sat Nov 05, 2016 10:39 am
Country: -

Re: Adding MAVLINK support

Post by benzo99 » Thu Nov 10, 2016 10:52 pm

OK. For the price of the Arduino Pro Mini your code seems worth trying :) As I've already got the Teensy I can try both and compare. Am I right in assuming I'll most likely get richer data from your code? Do you power the Arduino from the Sport on the Rx or the APM? I'm assuming it doesn't really matter.

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Thu Nov 10, 2016 11:15 pm

I power from the Rx.
The Teensy code doesn't seem to be being updated, so it is likely my code may have more in it, and I can easily update it if required.
Note that I don't actually fly anything using this.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

elkayem
Posts: 17
Joined: Sat Sep 24, 2016 7:45 pm
Country: -

Re: Adding MAVLINK support

Post by elkayem » Sun Nov 13, 2016 1:31 am

Geofrancis wrote:i dont have any problems running 16mhz at 3.3v.
Base on the technical specs for the Arduino Pro Mini, the 3.3V version has an 8 MHz external resonator.

Clock Speed: 8 MHz (3.3V versions) or 16 MHz (5V versions)

User avatar
jhsa
Posts: 16433
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Adding MAVLINK support

Post by jhsa » Sun Nov 13, 2016 1:46 am

The fact is, the arduino seems to run extremely well 16Mhz powered only by 3.3V
I have several arduinos working like that..
Some of them as DIY Frsky receivers, one as a multiprotocol RF module, and some other little projects..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

benzo99
Posts: 12
Joined: Sat Nov 05, 2016 10:39 am
Country: -

Re: Adding MAVLINK support

Post by benzo99 » Mon Nov 14, 2016 4:50 pm

Received my Arduino Pro Mini today. Got it programmed and wired, ready to go when I get my receiver. Thought a few pics might be useful for the next person. I used a standard servo connector for the S-Port side, and a 5-pin micro JST for the APM side (wired for the telemetry port on my CX-20 FC). Hopefully I have it right ;)

Wiring:
S-Port Signal (Orange) -> IO5
S-Port 5V (Red) -> VCC
S-Port GND (Brown) -> GND

APM TX (Green) -> RXI
APM RX (Yellow) -> TXO
APM GND (Black) -> GND (not strictly required)

IO2 -> GND (enable S-Port Mode)
IMG_20161114_162220.jpg
Once it's tested I'll be enclosing it in 18mm clear heat-shrink tubing.

benzo99
Posts: 12
Joined: Sat Nov 05, 2016 10:39 am
Country: -

Re: Adding MAVLINK support

Post by benzo99 » Fri Nov 18, 2016 2:09 pm

So I got everything hooked up, but I'm not getting any data on the telemetry screens. The LED on the Arduino blinks slowly - does this mean anything?

I'm pretty certain that the wiring is correct (APM TX->Arduino RX, etc.), but I'm less certain that the configuration of the APM in Mission Planner is totally correct (SR0 and SR1) settings.

Setup is APM -> Arduino converter -> X8R -> multi-protocol Tx module -> 9XR Pro.

9XR Pro is running R219x3 and multi-protocol module is running a build from two days ago. The X8R is in D16 'Mode 4'.

What can I do to troubleshoot this?

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Fri Nov 18, 2016 2:51 pm

The X8R should be sending RSSI and receiver voltage even if the APM is not working.
Do you see these? Make sure on the telemetry menu you have A1 set to 13.2V so it reads something other than 0.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

benzo99
Posts: 12
Joined: Sat Nov 05, 2016 10:39 am
Country: -

Re: Adding MAVLINK support

Post by benzo99 » Fri Nov 18, 2016 3:52 pm

MikeB wrote:The X8R should be sending RSSI and receiver voltage even if the APM is not working.
Do you see these? Make sure on the telemetry menu you have A1 set to 13.2V so it reads something other than 0.

Mike.
I don't see RSSI or receiver voltage - all zeroes. I guess this points the finger towards either the X8R or the multi-protocol module. The module firmware was compiled with serial enabled and all four telemetry protocols enabled.

Any idea for next steps? I guess I'll go over to RC groups and see if they have any ideas.

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Fri Nov 18, 2016 4:16 pm

You need to match the telemetry signal polarity of the 'PRO and the Multi module.
Either flash the Multi module with "INVERT_TELEMETRY" set, of set "Invert COM1" on in the radio. With the 'PRO, the latter is best as the 'PRO includes a programmable hardware inverter on the COM1 input.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

benzo99
Posts: 12
Joined: Sat Nov 05, 2016 10:39 am
Country: -

Re: Adding MAVLINK support

Post by benzo99 » Fri Nov 18, 2016 4:35 pm

MikeB wrote:You need to match the telemetry signal polarity of the 'PRO and the Multi module.
Either flash the Multi module with "INVERT_TELEMETRY" set, of set "Invert COM1" on in the radio. With the 'PRO, the latter is best as the 'PRO includes a programmable hardware inverter on the COM1 input.

Mike.
Bingo - "Invert COM1" did the trick and I get RSSI and A1 voltage now. I've not got the Arduino hooked up at the minute, so can't confirm that I'm getting all the data yet. Will get to that later on tonight.

Thanks again, Mike.

benzo99
Posts: 12
Joined: Sat Nov 05, 2016 10:39 am
Country: -

Re: Adding MAVLINK support

Post by benzo99 » Fri Nov 18, 2016 9:59 pm

benzo99 wrote:
MikeB wrote:You need to match the telemetry signal polarity of the 'PRO and the Multi module.
Either flash the Multi module with "INVERT_TELEMETRY" set, of set "Invert COM1" on in the radio. With the 'PRO, the latter is best as the 'PRO includes a programmable hardware inverter on the COM1 input.

Mike.
Bingo - "Invert COM1" did the trick and I get RSSI and A1 voltage now. I've not got the Arduino hooked up at the minute, so can't confirm that I'm getting all the data yet. Will get to that later on tonight.

Thanks again, Mike.
Got the Arduino in the loop and it all works - full telemetry data on the 9XR Pro - very happy. Just need some decent weather to get the thing in the air now :)

gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: Adding MAVLINK support

Post by gyrex » Sat Nov 26, 2016 11:21 pm

I'm having some issues getting telemetry back to my radio with this project and was wondering if someone could please help? I've successfully compiled and uploaded the sketch to my pro mini. I'm using a Pixhawk -> Arduino Pro Mini -> D4R receiver. My wiring is as follows:

Pixhawk Telemetry pin assignments

Image

Pixhawk Telemetry Pin # -> Arduino pins

1 -> VCC
2 -> RX
3 -> TX
4 -> BLK
5 -> GRN
6 -> GND

D4R Telemetry -> Arduino pins

GND -> GND (black)
RX -> 5 (green)

Is this right? When I poll the receiver for available sensors, I get a bunch of the sensors returned but there's values being sent.

Here's a photo of my wiring

Image

I changed the Pixhawk SERIAL1_PROTOCOL to Value 3 (FrSky D-PORT) - do I need to do this?

Image

Here's a video of what I'm seeing on my radio:

https://youtu.be/72Fi4P74wSs
Last edited by gyrex on Sun Nov 27, 2016 4:26 am, edited 1 time in total.

gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: Adding MAVLINK support

Post by gyrex » Sun Nov 27, 2016 4:25 am

Update: I changed the SERIAL1_PROTOCOL back to 1 (Mavlink) and now I'm getting some data but the values are jumping around like crazy, is this normal? I've taken a video of what I'm seeing... Any ideas?

https://www.youtube.com/watch?v=4L5L3BeVt4w
Last edited by gyrex on Sun Nov 27, 2016 2:55 pm, edited 2 times in total.

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Sun Nov 27, 2016 10:31 am

If the Pixhawk is sending "FrSky D", then this goes directly to the D4R.
If sending Mavlink, then you need both Tx and Rx from the Pixhawk connected to the Arduino. Note that Tx from the Pixhawk goes to Rx on the Arduino and Rx fromthe Pixhawk goes to Tx on the Arduino. You don't need to connect CTS and RTS and doing so may cause problems.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: Adding MAVLINK support

Post by gyrex » Sun Nov 27, 2016 12:17 pm

Thanks Mike. These were my original connections from the Pixhawk to the Arduino:

Pixhawk Telemetry Pin # -> Arduino pins

1 (5V) -> VCC
2 (TX) -> RX
3 (RX) -> TX
4 (CTS) -> BLK
5 (RTS) -> GRN
6 (GND) -> GND

Per your suggestion, I'll disconnect CTS & RTS and I'll report back.

OK, I disconnected CTS and RTS and my values are still jumping around like crazy... Any other ideas Mike?

gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: Adding MAVLINK support

Post by gyrex » Sun Nov 27, 2016 2:19 pm

I just erased the arduino and reloaded the sketch and completely rewired the D4R & Arduino. This is my wiring now:

Pixhawk Telemetry Pin # -> Arduino pins

1 (5V) -> VCC
2 (TX) -> RX
3 (RX) -> TX
4 (CTS) -> Not connected
5 (RTS) -> Not connected
6 (GND) -> GND

D4R Telemetry -> Arduino pins

RX -> 5 (green)
(removed GND)

Still getting the same problem. Pixhawk is configured to output Mavlink data to TELEM1 which the D4R is plugged into.

Here's a pic of my wiring:

Image

Here's a video of the telemetry output:

https://www.youtube.com/watch?v=cpjyVp-SEb8

gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: Adding MAVLINK support

Post by gyrex » Sun Nov 27, 2016 3:05 pm

So I hooked up my X8R in SBUS mode using the same Arduino Pro Mini board and I seem to be getting better results. Here's my wiring:

Pixhawk Telemetry Pin # -> Arduino pins

1 (5V) -> VCC
2 (TX) -> RX
3 (RX) -> TX
4 (CTS) -> Not connected
5 (RTS) -> Not connected
6 (GND) -> GND

S.PORT -> Arduino pins (Pin 2 connected to GND)
Signal -> 5
GND -> GND

Here's a photo:

Image

Here's a video of the telemetry output (much more stable):

https://youtu.be/7n-B0EtFVk0


I really need to use PPM (hence using the D4R), is there anything you can suggest to get D-port working properly on the D4R?
Last edited by gyrex on Sun Nov 27, 2016 4:11 pm, edited 1 time in total.

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Sun Nov 27, 2016 3:09 pm

Most looks to be working correctly. Tmp1 and Tmp2 are not temperatures but contain encoded data. er9x/ersky9x have code in to handle these coded values. With openTx you may have to create some calculated sensors I believe.
The main problem I can see is VFAS, which should be the flight battery voltage.
Tmp1 is the mavtype * 256 + apmMode.
Tmp2 is (number of satellites) * 10 + gpsStatus.

You need some help with openTx for setting this up (or switch to ersky9x!).

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: Adding MAVLINK support

Post by gyrex » Sun Nov 27, 2016 4:10 pm

Thanks for your response Mike :)

There appears to be a problem with Alt and VFAS over D-Port. Any ideas on how to fix this? Is this an OpenTx issue? They both seem to work fine over S-Port (I don't know what's wrong with my youtube videos - they're stuck on processing)...

Edit: The X8R S.Port video has uploaded now. The only issue I can see on there is RSSI but I need to install a filter on the RSSI cable.

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Sun Nov 27, 2016 4:57 pm

Could be the Arduino code, or could be openTx. Both these values are sent in two parts, the value before the decimal point and the value after.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
MikeB
9x Developer
Posts: 14262
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset

Re: Adding MAVLINK support

Post by MikeB » Sun Nov 27, 2016 8:36 pm

I can't see anything wrong with the Arduino code, and this has been working with er9x/ersky9x so I'm wondering if openTx is having a problem with 'D' telemetry data. Either that, or the Pixhawk is not sending correct values.
The Arduino is sending the data in the same order as a real FASV sensor.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

gyrex
Posts: 20
Joined: Sun Oct 23, 2016 11:10 am
Country: -

Re: Adding MAVLINK support

Post by gyrex » Sun Nov 27, 2016 10:43 pm

Thanks for checking the code Mike. I'm using the same arduino board and same pixhawk flight controller but a different receiver (D4R vs X8R) and achieving different results. Maybe it's OpenTX? I'll try loading ersky9x on the Taranis with the D4R receiver and see what results I get and I'll let you know. I really appreciate your help :)

Post Reply

Return to “ersky9x”

Who is online

Users browsing this forum: No registered users and 4 guests