Page 1 of 1

Speed of uart

Posted: Fri Mar 22, 2019 8:50 am
by rhubarbdog
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.

Re: Speed of uart

Posted: Fri Mar 22, 2019 2:34 pm
by dhylands
I've used the UART on the pyboard at 1 Mbit (1000000) to talk to bioloid servos.

Re: Speed of uart

Posted: Fri Mar 22, 2019 4:08 pm
by chuckbook
We regulary use STM32 UARTs up to 3Mbaud. I have to admit that we are also using proper 20 Mbaud differential line drivers

Re: Speed of uart

Posted: Fri Mar 22, 2019 4:30 pm
by rhubarbdog
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

Re: Speed of uart

Posted: Sun Mar 24, 2019 3:11 am
by rhubarbdog
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?

Re: Speed of uart

Posted: Mon Mar 25, 2019 5:19 am
by incognico
Since you are communicating between two physically-close boards, have you considered SPI?

Re: Speed of uart

Posted: Mon Mar 25, 2019 7:59 am
by rhubarbdog
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)

Re: Speed of uart

Posted: Sun May 08, 2022 9:03 am
by holdenweb
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?

Re: Speed of uart

Posted: Sun May 08, 2022 9:42 am
by pythoncoder
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.