How to set up serial3 on APM2?

Hi all,

I started to use APM2 from this April.

 At first, I installed Arducopter 2.5.5 to APM2, attached XbeePro 2.4GHz on XBee explorer regulated (WRL-09132:sparkfan), and insall APM planner 1.1.87 to my note pc.

Then I set up them to our original quad ducted-fan helicopter, it flies well, and telemetry succeeds.

 

I read source code of Arducopter, and I found that Serial3 is used for telemetry.

Is it true?

Now, I try to use Serial3 on APM2 as telemetry in my original program, but it does not work.

So I tested "MultiSerialMega" from this page,

http://code.google.com/p/ardupilot-mega/wiki/APM2Wireless

but Serial3 does not work.

 

I checked Xbee explorer led which is connected to APM2.

1. When Arducopter connects to APM planner by Xbee (telemetry), RSSI green led is on.

2. When Arducopter connects to APM planner via usb cable,  RSSI led is off.

3. When MultiSerialMega works on APM2, RSSI led is off, and Serial is OK.

From these, I think that some switching code is required to use Serial3 on APM2.

But I can not found it.

 

Does anyone give me suggestion?

 

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

Join diydrones

Email me when people reply –

Replies

  • hi Musafumi,

    i've also got stuck at the same place, trying to do telemetry with xbee 2.4 ghz on arducopter on serial3.

    just wanted to check if you've sorted out the issue with serial3 on apm2.5 with arducopter ?

    if yes can you give some information.

    thanks

    Kumaresan

  • Musafumi - I believe I have the solution to your problem. It sounds to me like you're looking to connect to a ground station via the GCS 3 you see in the code. GCS3 communicates over Serial 3, but there is no access to it on the board. That's why, when you run the MultiSerialMega code, you don't see anything coming out of the port when you plug into UART2.

     

    First, a modification to MultiSerialMega to show you what I'm talking about.

    • In the function setup, add 'Serial2.begin(YOUR_BAUD_HERE);'
    • In the function loop, add 'Serial2.println("Port 2");' You can add another delay(500) if you wish but it's not necessary

    You should be able to see 'Port 0' coming out of the normal USB port on APM and 'Port 2' coming out of UART2. Make certain this works before proceeding. 

     

    Now for the tricky part, getting the APM to talk to a ground station over UART2.

    • In ArduCopter.ino, find the 3 lines that initialize the fast serial ports. Add the line 'FastSerialPort2(Serial2);'.
    • In system.ino, find the line 'gcs0.init(&Serial)'. After it, add the following 2 lines. 'Serial2.begin(57600, 128, 256);' gcs3.init(&Serial2);'
    • About 10 lines later, find the lines that begin with 'Serial3.begin' and 'gcs3.init' and comment them out.

    You should be able to connect to a computer via UART2 after this. If not, let me know and I'll try to help you debug.

     

    Known issues with this hack:

    • The fact that GCS3 communicates over Serial2 does not follow naming conventions. I'm just too lazy to correct this one in my own code
    • The baud rate for UART2 can not be set by the paramater SERIAL3_BAUD (again, just too lazy to fix this)
    • The attitude message do not appear to be coming through MAVlink immediately after connecting to GCS3. If you wait long enough they'll make it through
    • I haven't flow this yet. It works well on the table, and I'll test it on my next flight. You may want to proceed with caution until it's well tested.

    Devs:

    • Is it possible to modify the MultiSerialMega code so it makes more since on the APM 2?
    • Maybe a word or two describing this solution here could save folks a bit of trouble.

    Best of luck,

    Nate

  • I mean, when load firmware, usb port (serial0 or just serial) is set to 115200, so to use wireless module i need 9600 baud on serial0 port, but i didn't find how set this parameter in Planner software neither in code.

  • Hello Miwa,

    i tested "MultiSerialMega" with both port in 9600, i received "port 0" in both case, first from USB, and then from wireless when power by battery.

    i don't know where change serial baud rate, i have downloaded code from repository.

    Someone know?

  • On Tuseday in Japan, Randy told me that Serial3 is not connected to telemetry for APM2 case.

    APM2, Serial is connected to USB when USB cable is connected to APM2, and it is connected to telemetry when USB cable is not used.

    Now, I made my program which send sensor data on APM2 with Xbee as telemetry transmitter.

    Thank you a lot, Randy.

     

This reply was deleted.

Activity