Need Five UARTs

Hello everyone

I am using APM 2.6 which has ATMEGA Aurdino based controller 2650. All the 4 UARTS are used for the various purpose and I need another UART. Just to test the functionality of the SoftwareSerial I have compiled its code as

/*
Software serial multple serial test

Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.

The circuit:

  • RX is digital pin 10 (connect to TX of other device)
  • TX is digital pin 11 (connect to RX of other device)

Note:
Not all pins on the Mega and Mega 2560 support change interrupts,
so only the following can be used for RX:
10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

Not all pins on the Leonardo support change interrupts,
so only the following can be used for RX:
8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

created back in the mists of time
modified 25 May 2012
by Tom Igoe
based on Mikal Hart’s example

This example code is in the public domain.

*/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(3,4); // RX, TX

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);

Serial.println(“Goodnight moon!”);

// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
mySerial.println(“Hello, world?”);
}

void loop() // run over and over
{
mySerial.write(“Hello”);
delay(10);
}

But I don’t know which pins shall I probe on the controller. I want to see the data. I tried to probe in the pin 3 and pin 4 and I cannot see any activity on the scope. Can you guys please help? I am new to Aurduino

Thanks

xeffect: I am using APM 2.6 which has ATMEGA Aurdino based controller 2650. All the 4 UARTS are used for the various purpose and I need another UART. Just to test the functionality of the SoftwareSerial I have compiled its code as

Do you mean it's actually an Arduino Mega2650 (or a clone of it),? Or are you saying it's "something like" an Arduino. Mainly, I am asking if the pins are the same.

If it's a Mega2650 or clone...

This paragraph in the code
    Not all pins on the Mega and Mega 2560 support change interrupts, 
    so only the following can be used for RX: 
    10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

and this statement 
   SoftwareSerial mySerial(3,4); // RX, TX

would seem to be at odds.

Hi Thanks for the reply.

Here is the link of the datasheet (http://www.atmel.com/Images/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_Summary.pdf) and the board I am using (http://store.3drobotics.com/products/apm-2-6-kit-1) or (http://copter.ardupilot.com/wiki/common-apm25-and-26-overview/)

In the decription its says pin 10, 11 or something but pin 10 in datasheet is VCC. I guess they are referring to PCINT10. I am not sure if you know which pins should work please let me know.

Well, the pins are definitely problematic. Here's why...

That code you posted was written for the Arduino. Now they say the APM 2.6 is Arduino compatible, but I don't know if that means pin-for-pin compatible, and in fact I can't seem to find a pinout. I found a link that said it was to a schematic, but it turns out it was to a board layout, with no pins mentioned.

When you see a pin number in Arduino code, it refers to the pin on the Arduino board, not the pin on the chip. So, for example, when it says pin 10 in that code you posted, it actually means pin 10 on one of the headers, which connects to pin 23 on the A ATMEGA2560-16AU chip.

So in order to get the code you posted to compile, you'll have to change the SoftwareSerial pins and actually use an Arduino Mega2650, or use the APM 2.6 after you find out which pins on the board connect to which pins on the chip. It just might be a pin-for-pin compatibe, but you'll need to figure that out, then move the SoftwareSerial Rx and TX to the appopriate pins.

I'll keep looking for more info, but don't let that stop you from looking too.

Hey thanks for the help dude. This page helped me in probing the right pin (http://www.hwkitchen.com/products/arduino-mega-2560-rev3/). The only problem though is that there are only 54 I/O on the board so I don't know which pin like 63,64 on the actual controller are mapped to.

However from the link its clear where pins from 13,12,11,10,50,51,52 and 53 are mapped to

I need some clarification about this thing also

The SoftwareSerial.h works great with the Arudino 1.05-rc2 but with version 1.03 it gives the following error

In file included from Custom.pde:27: C:\ArduPilot-Arduino-1.0.3-windows\ArduPilot-Arduino-1.0.3-windows\libraries\SoftwareSerial/SoftwareSerial.h:48: error: expected class-name before '{' token C:\ArduPilot-Arduino-1.0.3-windows\ArduPilot-Arduino-1.0.3-windows\libraries\SoftwareSerial/SoftwareSerial.h:97: error: 'Print' has not been declared

The problem is that the APM code and libraries do not get compiled with version 1.05-rc2 while the SoftwareSerial.h does.Also SoftwareSerial does not get compile with the Arduino 1.0.3 but the APM code for arducopter do.

Can you please help in this regard??

In file included from Custom.pde:27:

pde files are for pre-1.0 versions of the IDE. Where is this pde file coming from?

What does the SoftwareSerial.h file look like for 1.0.3?

Thanks brother,
I have attached the files. I downloaded the 1.03 version from this website (http://ardupilot.com/downloads/?category=6). There are example projects in there. I guess they are all .pde . If you think this is the problem of .pde. I can make a new project, if you suggest with the new Arduino IDE version. which is 1.0.5-rc2. If I open the PDE version in Arduino IDE version I get errors however same code with 1.0.3 mentioned on the website (http://ardupilot.com/downloads/?category=6) works great.

This is the website from where I downloaded the version 1.0.3 and it does not allow to compile the SoftwareSerial.h file (https://code.google.com/p/ardupilot-mega/downloads/list)

and this is the error I get when I include SoftwareSerial.h

C:\ArduPilot-Arduino-1.0.3\libraries\SoftwareSerial/SoftwareSerial.h:36:20: warning: Stream.h: No such file or directory
Custom.ino:214:5: warning: “/*” within comment
In file included from Custom.ino:27:
C:\ArduPilot-Arduino-1.0.3\libraries\SoftwareSerial/SoftwareSerial.h:48: error: expected class-name before ‘{’ token
C:\ArduPilot-Arduino-1.0.3\libraries\SoftwareSerial/SoftwareSerial.h:97: error: ‘Print’ has not been declared

SoftwareSerial.cpp (13.3 KB)

SoftwareSerial.h (3.48 KB)