Arduino Due pins for SoftwareSerial

Due has 4 hardware serial ports. Do you really need more then 4 ports? If you really need it search this forum there were threads regarding this topic.

I will be using five Reaction Wheel,and need 10 pairs of Tx & Rx,apart from ports needed to communicate with PC.

Hi there bikas,

I have just published a post in the Arduino DUE libraries thread about a software serial library I have developed. You have the post here:

http://forum.arduino.cc/index.php?topic=144446.msg2335415#msg2335415

The library is called soft_uart. With it, you can have up to nine software serial objects associated to the timer/counter module channels available on the Arduino DUE's ATSAM3X8E micro-controller. As RX and TX pin for each object you might use the I/O pins you want.

I hope it can be useful.

antodom

1 Like

@antodom thanks for your input.I will use your library and keep you informed about its performance.
thanks

@antodom i tried to use the example in your software serial library but it throws up an error

"request for member 'begin' in 'serial_tc4',which is of non-class type 'int'

The error starts from serial_tc4.begin .

Hi there @bikas,

Please, can you provide more information?. The example should compile and run correctly, it seems that serial_tc4 is not correctly interpreted as an arduino_due::soft_uart::serial class.

A few of a priori hypotheses that maybe can cause the error ...

  • Flag gnu++11. Take into account that flag -std=gnu++11 is necessary for compiling. Add -std=gnu++11 to the platform.txt file, concretely to compiler.cpp.flags (more detailed instructions in README.nd).

  • Maybe library soft_uart has been not added correctly to the Arduino IDE (??).

  • Have you changed the example's code in some sense?, if that is the case, can you provide the code?.

@antodom..

Have you changed the example's code in some sense?, if that is the case, can you provide the code?

i did not changed the example code.

Maybe library soft_uart has been not added correctly to the Arduino IDE (??)

i can see the library in my sketch,when i import i get

#include <fifo.h>
#include <soft_uart.h>

i think the error was because of compiler which i did not set to -std=gnu++11
Did you meant to say adding compiler.cpp.flags -std=gnu++11 in the platform.txt file?

i see another option with compiler.cpp.flags

compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD

Also i see no arduino/hardware/sam folder,i expected the platform.txt file to be on that folder.So i instead added compiler.cpp.flags -std=gnu++11 in arduino/hardware/avr/platform.txt and getting the same error.

i am attaching the error report

thanks,
bikash

soft_uart_ErrorReport.txt (29.3 KB)

Hi again @bikas,

File "arduino/hardware/avr/platform.txt" is not the corresponding one for the Arduino DUE, it is the platform file for AVR platforms (Arduino UNO, etc.).

According to my experience the root directory for the Arduino DUE platform on Linux is "$HOME/.arduino15" (I´m using Arduino IDE 1.6.5), and in windows "C:\Users<your-user-name>\AppData\Roaming".

In fact, if you have a look to the error file you have included, in your computer the directory is "c:\users\bikash\appdata\roaming\arduino15\packages\arduino\hardware\sam\1.6.4 (or 1.6.3)". There, you should find the platform.txt corresponding tothe DUE.

The problem you have is that the -std=gnu++11 flag is missing:

Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Due (Programming Port)"

In file included from c:\users\bikash\appdata\roaming\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\cstdint:35:0,
from C:\Users\bikash\Documents\Arduino\libraries\soft_uart/soft_uart.h:40,
from soft_uart_serial_test.ino:39:
c:\users\bikash\appdata\roaming\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\bits\c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
...

As I mentioned previously, just add that flag to the DUE's platform file:

compiler.cpp.flags=-c -g -Os -std=gnu++11 {compiler.warning_flags} -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD

Best.

@antodom,
Many thanks for your help,right now i am testing my device at 115200bps.Next week i will put my results here. Hopeful of getting positive results with your library.

regards,
bikash

@antodom,

So i tested the library,and following are the results,

1). Serial Protocol 8E1
-works upto 57600 baud rate.
2). Serial Protocol 8E2
-works upto 57600 baud rate.
3). Serial Protocol 8N1
-works upto 38400 baud rate.
4). Serial Protocol 8N2
-works upto 57600 baud rate.

Since my system serial communication protocol requires 8N1 @115200 baud rate so i am unable to use your library.

bikas

Hi again @bikas,

With the example provided with soft_uart you can get up to 115200 without errors using the WInterrupts.c file I modifiied which is available on this post:

http://forum.arduino.cc/index.php?topic=144446.msg2336042#msg2336042

And using 8E2 (or 8O2). The example is a very simple one, with no other things running, just serial communications. So, surely, you will not get to that baud rate in a more complex application.

One question, do you need 8N1 115200 bps imperiously for your application?. Is it not possible to change the baud rate of the devices you have to communicate with?.

@antodom,
Unfortunately the device i am using http://www.astrofein.com/2728/dwnld/admin/Datenblatt_RW90.pdf
communicates in 8N1 115200 bps,its the only protocol they mentioned in their datasheet.I checked with lower baud rate and it does not respond.
bikas

The data sheet you linked to says RS485, which is a multi drop (bus) system so you only need one serial port.

It says nothing about the baud rate or the number of start/stop bit etc so where did you get that info from?

Mark

@holmes4
i have the full datasheet from the manufacturer which i did not posted here since i am not sure if its violating their terms.There it gave full details about baud rate and start/stop bit.
bikas

Hi @antodom.

I am working with Arduino Due and ESP8266 WiFi Shield which forces me to use pins 8 and 9 as software serial pins and I need a library like soft_uart.

I download and extract soft_uart.git in C:\Program Files (x86)\Arduino\libraries. Arduino IDE recognises the library and I have tested the first example (basic_test). I can see properly the communication in the serial monitor.

But when I try to compile the second one (soft_uart_serial_test) I get a problem in the line:

void receive_tc(serial_tc_t& serial_tc,unsigned long timeout)

The error is: variable or field 'receive_tc' declared void

I am working now with Arduino IDE 1.6.11 buit I also got that error in a previous one 1.6.9 I think.

May you help me?

Thank you in advance.

Just another prototype generator failure...

template<typename serial_tc_t>
void receive_tc(serial_tc_t& serial_tc,unsigned long timeout)
{ ...

Generated prototype:

void receive_tc(serial_tc_t& serial_tc,unsigned long timeout);

No mention of of the template or serial_tc_t there --> error.

Works OK if they are on the same line:

template<typename serial_tc_t> void receive_tc(serial_tc_t& serial_tc,unsigned long timeout)
{ ...

tiopac:
Hi @antodom.

I am working with Arduino Due and ESP8266 WiFi Shield which forces me to use pins 8 and 9 as software serial pins and I need a library like soft_uart.

I download and extract soft_uart.git in C:\Program Files (x86)\Arduino\libraries. Arduino IDE recognises the library and I have tested the first example (basic_test). I can see properly the communication in the serial monitor.

But when I try to compile the second one (soft_uart_serial_test) I get a problem in the line:

void receive_tc(serial_tc_t& serial_tc,unsigned long timeout)

The error is: variable or field 'receive_tc' declared void

I am working now with Arduino IDE 1.6.11 buit I also got that error in a previous one 1.6.9 I think.

May you help me?

Thank you in advance.

SoftwareSerial library was created as a serial crutch given Arduino UNO scarcity of serial ports. Due contains four (4) serial ports, thus, no need for crutches.
Due's core is SAM which is different from UNO's AVR. That means to tweak the code like oqibidipo just showed.

Notice that most of the time three of Due's serials are exposed when stacked with UNO's shileds. The picture below shows an easy and simple solution that fix your problem.

Of course, you have to replace the SS lines from code with the correspondent SerialX.xxx

-p

Hi there @tiopac and @oqibidipo,

This compiler error appears when you have a C++ template function definition in an .ino file. When the IDE collects function profiles from all .ino files, it does not differentiate template functions. I had the same problem with the examples of other of my libraries: tc_lib.

Well, the problem is already fixed in all examples, so @tiopac, just update soft_uart and test again. It should work. Just tell me if everything was ok.

I hope it helps.

Thank you for the quick responses :slight_smile:

I had already tried your solution @Palliser, and it worked. But I don't want to have additional external wires.

Thank you @oqibidipo and @antodom. I have downloaded the updated examples and now they work properly.