Speed of uart

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

Speed of uart

Post by rhubarbdog » Fri Mar 22, 2019 8:50 am

What's the fastest i can make uart go?
What's the biggest number i can enter for baudrate?
I try 9600 things work.
I move up to 112500 still ok.
From a raspberry pi header file i find a rate 1125000 things still seem ok.
When i try another number from that header like 16000000 my data transfer still happens, but it now takes a couple of milli seconds, previously it took micro seconds at 1152000.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Speed of uart

Post by dhylands » Fri Mar 22, 2019 2:34 pm

I've used the UART on the pyboard at 1 Mbit (1000000) to talk to bioloid servos.

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: Speed of uart

Post by chuckbook » Fri Mar 22, 2019 4:08 pm

We regulary use STM32 UARTs up to 3Mbaud. I have to admit that we are also using proper 20 Mbaud differential line drivers

rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

Re: Speed of uart

Post by rhubarbdog » Fri Mar 22, 2019 4:30 pm

So i use one of these line drivers between Rx and Tx on my 2 devices and this microchip allows for a higher data throughput

rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

Re: Speed of uart

Post by rhubarbdog » Sun Mar 24, 2019 3:11 am

I'm using 2 pyboards with headers. Connected with 'arduino ' wires. I can only run for 6minutes before i get some data corruption
Will i be better of buying some more pyboards, but soldering wires to them?

incognico
Posts: 19
Joined: Tue Jun 05, 2018 4:51 am

Re: Speed of uart

Post by incognico » Mon Mar 25, 2019 5:19 am

Since you are communicating between two physically-close boards, have you considered SPI?

rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

Re: Speed of uart

Post by rhubarbdog » Mon Mar 25, 2019 7:59 am

I found spi prone to dropping packets. I wrote a little dummy program passing data between SPI(2) and SPI(1) on one pyboard.
What I'm doing the reciever is busy writing data to SD card i have a big buffer on my uart (16kb)

holdenweb
Posts: 9
Joined: Wed Mar 09, 2016 12:40 pm

Re: Speed of uart

Post by holdenweb » Sun May 08, 2022 9:03 am

incognico wrote:
Mon Mar 25, 2019 5:19 am
Since you are communicating between two physically-close boards, have you considered SPI?
I understood MicroPython was unable to use the SPI interface in slave mode, so SPI would be out in that case. Am I out of date?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Speed of uart

Post by pythoncoder » Sun May 08, 2022 9:42 am

SPI slave mode is not supported.

UARTs are reliable at speeds of a few Mbaud but, as with any fast communication, you need to consider electrical issues. The serial protocol requires clean edges. The receiver starts timing on the leading edge of the start pulse, sampling subsequent bits in the middle of the bit period. If edges of the start bit or data bits are slow or of poor quality, bit errors can occur.

The solution is to use short wires and a good ground connection. If long distances have to be covered, special line driver chips exist. These normally use differential signalling and expect shielded twisted-pair cabling with termination resistors.
Peter Hinch
Index to my micropython libraries.

Post Reply