Is there a way to set the APM2 to use the UART2 output for telemetry without having to recompile the software manually?

Views: 8801

Reply to This

Replies to This Discussion

Tom, I don't think so.  What you have to do depends on your objective here.  The wiki explains how to route serial3 to UART2.  This tales a mod to APM_config.h and subsequent compilation.

#define TELEMETRY_UART2 ENABLED  // solder bridge changed to enable UART2;

Other related topics are discussed here Serial2-UART2

What I want to do is have the Telemetry come out UART2 to the transceiver at the same time I have the APM plugged in to the USB port. I don't want to have to keep on unplugging the transceiver when I want to plug the APM to a PC.

The question here is why? Further, clarification of the intentions. You surely do not intend to control via both UARTs? In other words, let's say you want to update parameters via the USB, but are driving for some reason a ground station or OSD device through the other connection. Fine, they are receive only. You can do that, all you are doing is splitting the TX out of the APM to multiple receiving devices. The fact is, the directions are telling you to use the automuxed port (UART0/2). The idea is that that physical port on the board has a buffer/mux chip in between the real UART0 coming out of the Mega2560 and those pins and the USB that auto switches. The trick here is there is another UART0 real physical hardwired port on the board along the long edge and it's silkscreened on the bottom. when you use that for your extra port, it is active when USB is active. Thus, if you connect to the RX pin of that, then you likely will have trouble using the USB, but if you used the TX only, then all of your devices can work in harmony.


By your statements, it's unclear what the problem is. By default, you can plug in USB while using the UART pins (0/2) in the directions off the automux and it defaults to USB when plugged in. You lose all data out when that happens on the UART pins. If that's the problem, then switch to the real UART0 and you would be able to get telemetry (AKA Mavlink) out of the UART, but not able to have the Receive pin connected because obviously, two devices trying to transmit at the same time =collision. Switching to UART 2 does not sound like any kind of solution to your intitial question as that likely disables USB altogether. Natively, the code only talks through a single UART for all Mavlink. I have seen discussions of spliting Mavlink TX and RX across 2 UARTs when using the joystick and dedicated RF links (Xbee or other) in order to reduce the latency due to the high bandwidth of joystick control (sans RC radio system) but that is a unique case and still required custom compiling of the firmware. 

My question is can I plug in the USB cable and do firmware updates, PID changes, etc... to the APM without unplugging the Telemetry transceiver from the UART0/2 port?

Yes, it says that in the directions. 

IMPORTANT: On APM 2, you cannot use the Xbee while your APM board is connected to the USB port. That's because the Xbee and USB share the same serial port, with some clever multiplexing to detect if the USB cable is plugged in and switching output to the USB if so. Although that has the huge win of freeing up a serial port for some other use (want to connect an Android phone, anyone?), it does mean that you need to disconnect the board from the USB cable and power it some other way when testing wireless telemetry on your bench.

What it is saying is the power and logical data connections. Many people try to test the Xbee or 3DR radios by powering VIA USB on a workbench and because the mux chip defaults to USB for signal when it sees it plugged in, the Xbee or 3DR radio cannot connect. It's not saying unplug the radio, just trying to clarify the function of what the mux defaults to. Because so many people have problems with the telemetry radios they put the statements in the directions.

With or without cutting the jumper and resoldering it to UART2?

With or without having to recompile the software to make UART2 work if I do cut the jumpers?

Yes, I do that all the time.  I didn't even know it was an issue that I might have to unplug the telemetry, it seems to be a non-issue.

OK, makes more sense to me.

If I do no cutting of the board and I plug in the USB cable, the Telemetry stops working.

To get both the USB port and the Telemetry to work at the same time, the jumpers have to be cut and changed to UART2 and the software will have to be changed and recompiled by hand.


To get both the USB port and the Telemetry to work at the same time, the jumpers have to be cut and changed to UART2 and the software will have to be changed and recompiled by hand.

No, again, follow what I said. You cannot ever have 2 devices trying to send Mavlink to the APM. You can receive mavlink on multiple devices. Changing to UART2 gains you nothing. You would always control via one or the other but not both at the same time.

If you want to ensure you can recieve mavlink to a remote device via the UART when USB is plugged in, then use the hardwired UART 0 on the long edge of the board and do not connect the RX line.

Again, what's not clear here is what you have attached to the UART and more importantly, the remote link. The firmware has one path for control. Imagine the logic of try to determine which input is the Master? Mavlink is simply the protocol being used. Obviously multiple devices can listen, but only one can send.

 In other words, you cannot control it across the USB (update PIDs, settings, flash firmware etc..) and also try to control it across the UART (groundstation or another PC). You can listen to mavlink, groundstation or PC can receive data from the UART while a second PC is controlling via USB. That's using UART0 the hardwired port with the RX pin not connected so as to not cause a collision on with the USB.

Again, there are 2 places UART0 is available on the APM2.0. One is on the automux port and the other is before the automux. The point of the automux is to prevent collision, but you can use the hardwired UART0 and still be able to have a remote device recieve data, just not TX. If you connect the TX pin, then likely you'll have trouble connecting via USB (only when using the direct UART0 hardwired on the long edge of the board).

The usage scenario we are having trouble understanding is your intent behind wanting both connected at the same time. As stated, you can do this, but only when the one side is receive only. I've given you the option behind that (use the other UART0 pins).

If you connect the TX pin, then likely you'll have trouble connecting via USB (only when using the direct UART0 hardwired on the long edge of the board).

Sorry, meant to say connect the RX pin at the APM. The pin labels are what the pin does at that device. In general, you connect the TX pin of one device to the RX pin of the other device. Sometimes, they are mislabeled (simple silkscreen mistakes) but the APM is correctly labeled and the 3DR radios and most Xbee carriers are labeled correctly.

It's just the common sense idea that you can only listen to one person at a time. If 2 people try to talk to you at once, you hear nothing but garble. There is no easy way to just have one direction on the USB, and by your question, you want bi-directional anyway on the USB. What we are trying to state is that then you can only have a remote device listen on the UART while controlling via USB (USB bi-directional). You can if you really want to custom compile firmware so it listens on one port and transmits on the other, but without a lot more logic involved, there is not a way to be bi-directional on both UARTs at the same time. Hopefuly, you understand that natively, the mega 2560 is only hasUART connections. The USB is going though the 8u2 (or is it a 32u2?) to convert USB to UART. Thus really, what you have been asking all along is to have 2 bi-directional UARTs into the APM (mega2560)and the current firmware would not support control on both at the same time. There are both phsycial and logical reasons why that doesn't work.


Thanks guys for helping out. Some times I don't explaign things well.

I was thinking of having 2 separate Mavlink sessions but that won't work.

One to a PC and one to a ground station.

What about using UART2 for only ouput?  I could see this being useful for payloads that want position data from the APM, while still having a fully functional telemetry link to the ground.  Is this possible?

Reply to Discussion


© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service