RS-485 at 76.8 Kbaud

nagra

Member
Hi,

I need to interface with RS-485 equipment running at 76.8 Kbaud.
I'm thinking of using a Teensy LC (they're cheap and I need quite a few, and they have good ADC resolution).

Is there any issue running a serial link at that rate?
I would assume any rate (i.e. even odd ones) are ok as long as it's below the max rate but I wanted to check since 76800 is not listed here:
https://www.pjrc.com/teensy/td_uart.html

Thanks!
JL
 
Might not work so well. On Teensy LC the baud rates are integer divide of 1.5 MHz (48 MHz PLL divide by 2, then divide by 16 in the UART). For 115200 the divider would be 13.02. For 57600 the divider would be 26.04. Both are very close to integers, so error is small.

But for 76800, the divider would be 1.5e6 / 76800 = 19.53. Not good. It will have to round up to 20, for an actual baud rate of 75000. That's 2.34% error.

I believe Serial1 can be modified to use a different divider than 16 (Serial2 and Serial3 are fixed at 16), but the HardwareSerial class in Teensy's core library doesn't support anything but 16 on Teensy LC. You'd have to dive into that code and edit how it configures the hardware. Maybe possible, but not easy.
 
Thanks Paul!

Would you recommend the 3.x series?
I see they have "High Resolution Baud Rates", is that what it takes?
 
Yeah... I saw the note, I need 18 of these *sigh*... and I want 12+ bits resolution on the ADC which the 4.* models don't have.
 
Hey Paul,

So.... I decided to give the 4.x series a try and the ADC was fine so I got a bunch of 4.1 boards.
Now I feel stupid: I didn't notice these don't have the "High Res Baud" that's available on the 3.x series.

Does the same logic apply? ("divide by 2, then divide by 16 in the UART" and hope to get an integer value)

Since I don't need 600MHz, is it possible to change the clock speed to something that would make the UART run at 76800 baud?

Thanks,
JL
 
T4.x has a base UART_CLOCK of 24 MHz. The begin() function has an algorithm to set two different divisors to get as close as possible to the desired baud rate, and the result in your case is 76923 baud. The error is only 0.16%, much better than with T3.x, so I think it will work. Give it a try.

If you're curious about the algorith, see lines 108-127 of cores\Teensy4\HardwareSerial.cpp
 
Good to hear, thanks Joe!
The data I'm reading makes no sense right now... vendor of the device I'm connected to confirmed the baud and 8-N-1 format so I'm not sure what I'm missing.
Ordered a logic analyzer to see what's going on.
 
Good to hear, thanks Joe!
The data I'm reading makes no sense right now... vendor of the device I'm connected to confirmed the baud and 8-N-1 format so I'm not sure what I'm missing.
Ordered a logic analyzer to see what's going on.

With RS-485, you must have the right polarity, and the labeling can be confusing, so swapping RX+ and RX- on the 485 side may be worth a try.
 
NO
FUCKING
WAY!!!

That did it.... I didn't even try to check the polarity as I expected it didn't care.
Thanks!!!
 
Back
Top