juranga
Posts: 183
Joined: Fri Nov 06, 2015 11:39 am
Location: Basque Country

RPi3 UART Problems

Wed Apr 06, 2016 8:27 am

Hi everybody,

I have been reading about the issue with the UART in the new Raspberry Pi 3. The point is that I need the maximum performance of the UART communication because I am reading a sensor that sends data each 5 millisecond.

I read about different ways to resolve this issues but I want to know with which method I could obtain the best performance.

1. As I did, just using ttyS0 instead of ttyAMA0 and adding core_freq=250 in /boot/config.txt
2. Using Device Tree Overlay

Right now, I am using the latest release of Debian and I only disable the serial console at boot time and it seems it is working okay (using /dev/ttyS0).


Many thanks for your help!

mastermushi
Posts: 37
Joined: Thu Apr 07, 2016 8:47 am

Re: RPi3 UART Problems

Sat Apr 09, 2016 3:20 pm

RPI3 UART is not good.
I recommend you to use ATMEL MEGA 328@20Mhz as the "data buffer" which receives high speed UART message and sends messages to Raspberry via SPI interface

juranga
Posts: 183
Joined: Fri Nov 06, 2015 11:39 am
Location: Basque Country

Re: RPi3 UART Problems

Mon Apr 11, 2016 7:40 am

mastermushi wrote:RPI3 UART is not good.
I recommend you to use ATMEL MEGA 328@20Mhz as the "data buffer" which receives high speed UART message and sends messages to Raspberry via SPI interface
Many thanks for your answer mastermushi!

So, would you say that RPI3's UART is no good enough to use in my application?

As I said, I want to use it in order to read sensor data each 5 milliseconds (24 bytes each data). Should I use another hardware to read it?

mastermushi
Posts: 37
Joined: Thu Apr 07, 2016 8:47 am

Re: RPi3 UART Problems

Mon Apr 11, 2016 8:22 am

I think I might be missing some point in your architecture.
Do you refer to
PLAN A: Sensor (UART) -> RPI3 - > LAN/Internet
PLAN B: Sensor (24bit SPI/I2C/1Wire) -> RPI3 (UART) -> PC or Other
PLAN C: please specify your own

Anyways, UART is slow. Use SPI or any other interface capable to send 2 words in less than 2ms (please keep in mind that sending data to interface registers, processing and OS services take time too)

juranga
Posts: 183
Joined: Fri Nov 06, 2015 11:39 am
Location: Basque Country

Re: RPi3 UART Problems

Mon Apr 11, 2016 9:02 am

This would be my projects architecture:

Input:
  • GPS: It sends data each 200ms (3 NMEA structures) and I read it by USB
    IMU: It sends data each 5ms (24 bytes) and I read it using UART
Output
  • I have to process all this data and finally send the results using Ethernet protocol

So, Is not it going to be a good idea to use RPi3??

many thanks for your help!

mastermushi
Posts: 37
Joined: Thu Apr 07, 2016 8:47 am

Re: RPi3 UART Problems

Mon Apr 11, 2016 9:13 am

Sad to say, but with RPI3 and Raspbian OS "Jessie" you wont be able to works stable.
I recommend you to use RPI2 and the latest available release of Raspbian OS "Wheesy".

Fastest stable UART at RPI3 was 38400. This is not enough for your project by all means.

Solution with RPI2 looks like:
viewtopic.php?f=44&t=73673

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 10317
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: RPi3 UART Problems

Mon Apr 11, 2016 10:00 am

Why the recommendation to stick with wheezy? Jessie will work quite happily on a Pi2.

You can switch back to the same uart config as Pi2, but it will compromise Bluetooth performance - not apparently a need in your application. Sorry, can't remember the runes off the top of my head.

Other options would include using a USB uart.

You don't say how intensive your processing is, but it doesn't sound like you need the extra grunt of the 3. Does it actually need more than a Pi1? Save a couple of quid and a bit of power.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
RaTTuS
Posts: 10709
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: RPi3 UART Problems

Mon Apr 11, 2016 10:10 am

I got the serial [that is on A , PI0 and a B] to run at 1mbps
viewtopic.php?f=44&t=51633
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
karrika
Posts: 1312
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: RPi3 UART Problems

Mon Apr 11, 2016 10:40 am

juranga wrote: Input:
  • GPS: It sends data each 200ms (3 NMEA structures) and I read it by USB
    IMU: It sends data each 5ms (24 bytes) and I read it using UART
Output
  • I have to process all this data and finally send the results using Ethernet protocol
24 bytes with start and stop bits produce 240 bits/0.005sec = 48000 bps

This is a non-standard baudrate. But I see no problem in reading 5kbytes per second and relaying it out over Ethernet. Probably in IEC61162 450 protocol ;)

I would go for a vanilla RPi2 and Jessie. The UART works well for me at 250000 bps for DMX traffic.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27943
Joined: Sat Jul 30, 2011 7:41 pm

Re: RPi3 UART Problems

Mon Apr 11, 2016 10:46 am

mastermushi wrote:Sad to say, but with RPI3 and Raspbian OS "Jessie" you wont be able to works stable.
I recommend you to use RPI2 and the latest available release of Raspbian OS "Wheesy".

Fastest stable UART at RPI3 was 38400. This is not enough for your project by all means.

Solution with RPI2 looks like:
viewtopic.php?f=44&t=73673
I don't this this post is correct. Jessie is stable, and you should be able to get much higher reliable baud rates. See other posts above where people have done so.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

juranga
Posts: 183
Joined: Fri Nov 06, 2015 11:39 am
Location: Basque Country

Re: RPi3 UART Problems

Mon Apr 11, 2016 11:16 am

I am quite new programming Raspberry Pis so I do not know which is it's the real power.

The point is that after reading two sensors, I will have to process all the data, use one or two kalman filters, save variables in a .txt file, and send the information using Ethernet in real time.

The first part is working properly, it reads both sensors and saves all the information in a file. When I was working with Rpi Model 2 B+ (one core) did not work as fast as I wanted and after buying the RPi 2 Model B (quad core) the performance improved. I divided the program in two threads, one to save the data in the .txt file and the other to read both sensors and do the algorithms.

It worked really good but taking into account that I would have to add one or two kalman filters, Ethernet protocol to send data and maybe another sensor, I decided to transfer all the project to RPi3. But reading your opinions I am not sure if it has been a good idea...

mastermushi
Posts: 37
Joined: Thu Apr 07, 2016 8:47 am

Re: RPi3 UART Problems

Mon Apr 11, 2016 11:45 am

As fellas said - use USB UART then!

https://www.exar.com/product/interface/ ... /xr21b1411

RPI 3 has issues only at internal UART1 device. If you use external chip then no troubles....

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27943
Joined: Sat Jul 30, 2011 7:41 pm

Re: RPi3 UART Problems

Mon Apr 11, 2016 3:05 pm

mastermushi wrote:As fellas said - use USB UART then!

https://www.exar.com/product/interface/ ... /xr21b1411

RPI 3 has issues only at internal UART1 device. If you use external chip then no troubles....
The Pi has two UARTs, you can reassign them using device tree to get it to work exactly like the Pi2. On the Pi3, the 'better' uart was assigned to the BT module. You just need to reverse that to get the Pi2 behaviour.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

juranga
Posts: 183
Joined: Fri Nov 06, 2015 11:39 am
Location: Basque Country

Re: RPi3 UART Problems

Tue Apr 12, 2016 6:31 am

jamesh wrote:
mastermushi wrote:As fellas said - use USB UART then!

https://www.exar.com/product/interface/ ... /xr21b1411

RPI 3 has issues only at internal UART1 device. If you use external chip then no troubles....
The Pi has two UARTs, you can reassign them using device tree to get it to work exactly like the Pi2. On the Pi3, the 'better' uart was assigned to the BT module. You just need to reverse that to get the Pi2 behaviour.
Many thank jamesh!

So, it look likes the best way is to use RPi3 (because of it's power) and change the UART configuration.

Is there any guide which explains how to install or use this device tree? Because I read about this last week but I did not find any guide so I finally decided to use ttyS0 (the worst uart). I found the link to download the device tree but I do not know how to install and use it.


juranga
Posts: 183
Joined: Fri Nov 06, 2015 11:39 am
Location: Basque Country

Re: RPi3 UART Problems

Wed Apr 13, 2016 8:17 am

I think that I have followed all the steps correctly but I can not read anything in the serial port...

Which serial port is supposed to work after doing this configuration? /dev/ttyAMA0? /dev/ttyS0? /dev/ttyS1? I have tried with all of them but I did not succeed.

I get "Could not open /dev/ttyAMA0" in cutecom...

What am I doing wrong?

EDITED: I finally used another device tree: pi3-disable-bt-overlay.dtb because I did not achieve with the other layer. Is it okay using it? It seems that AMA0 is working properly!

Return to “Interfacing (DSI, CSI, I2C, etc.)”