Uncategorized

Baud Rate Calculation

Calculated UART Baud Rate Does not Match the Baud Rate Expected by the Receiver

Ask QuestionAsked todayActive todayViewed 71 times31

I am trying to decode a software UART from a microcontroller on my oscilloscope. To do this, I am probing the Tx line with reference to ground, and using the decode feature on my oscilloscope (Siglent SDS 1104X-E). To configure the UART on the oscilloscope side, I have to choose a custom baud rate, as the baud rate of my software UART isn’t fine tuned properly. To do this, I measure the period of a bit in the UART data. Then, using the period I simply divide 1bit by the period to get a value in bps.

For example, in some UART data that I had sent, I measured the length of 1 bit to be 0.2208ms, so

(1 bit) / (0.2208 * 10^(-3) s) ~= 4529 bps

I then set the custom baud rate on my oscilloscope to this value, and press the decode button expecting to see a nicely decoded signal; however, the receiver appears to have received garbage as seen below

UART Decoded With Calculated Baud

What confuses me is that if I dial down the baud rate to around 4200 Baud, the signal is decoded perfectly as seen below

UART data

This value is so far off from the actual baud rate that I calculated from the signal, so what is going on here? The data is accurate and clean, but the baud rate required for decoding it is so far off.

I would also like to note that I don’t believe that this is an issue with the oscilloscope, because when I send the data to my PC through an FTDI breakout, and monitor it with

screen /dev/ttyUSB0 4529

I receive garbage data. The characters received are unknown and result as the unknown ascii character symbol; however what’s different in that scenario is that even if I change around the baud rate for screen, it is still unable to decode the data no matter what I change it to. What’s even weirder with that is that I am receiving the correct number of characters for whatever I send, its just the characters themselves are for some reason unrecognizable, even though the oscilloscope can decode them fine. So I am very perplexed as to what is going on here.

EDIT 1:

I have since gotten the baud rate up to about 4735bps which is within 2% of the standard 4800 bps, and I tried it with the oscilloscope, and it was still unable to decode it. It wasn’t until I manually dropped the reciever baud rate to about 4400bps on the oscilloscope, that it was able to decode the data.

Furthermore, I am convinced that it is not an issue with the oscilloscope, as I used a terminal program (picoterm) and tried reading the data that way. I connected with 4800 baud set, and it was unable to read the data, yielding only the unknown ascii character. I then dropped it to 4400 baud in the program, and it was able to receive the data just fine. So there is something with this stream of data which makes its baudrate less than the baudrate which it is calculated to be…microcontrolleruartcommunicationoscilloscopebit-bangShareCiteEditFollowFlagedited 5 hours agoasked 7 hours agoKalcifer18199 bronze badges New contributor

  • This long comment chain has exceeded what is reasonable for comments. Therefore it is going to be moved to, and should be continued in, chat (link below). — As this moving of comments to chat can only be done once, any further comments posted here which try to clarify and understand the question, might be deleted without notice. Keep it in chat, please! When someone has got enough information from the chat to post a valid answer, then please do that. Any factual updates to the question which are decided during the chat, should be made via an edit to the question. Thanks! – SamGibson 21 mins ago 
  • Comments are not for extended discussion; this conversation has been moved to chat. – SamGibson 20 mins ago

Add a comment

1 Answer

ActiveOldestVotes-3This post is hidden. It was deleted 33 mins ago by SamGibson.

Answer

I usually use my scope, Rigol 1054Z, to display perhaps 10 characters or more of say 0x5a, 0xa5 etc, then zoom in to two or one characters. One character is 10 bits, say, so I can easily calculate the baud rate.

Update 1

If for standard baud rates, all is well, it is only custom baud rates that cause trouble. Perhaps the scope needs more longer time, or say more than 1,000 bytes to do the sync/auto-bauding job.

By the way, are you sure your software created?, bit banging? cpu master clock dividing?, fiddling, custom baud rate of 4k2bd is precise and steady?


References

(1) SDS1000X User Manual – SIGLENT


Appendices

Appendix A – Serial Decode Setup


serial decode

Appendix B – Decoding Test Results


uart speed test

ShareCiteEditUndeleteFlagedited 5 hours agoanswered 7 hours agotlfong012,01211 gold badge77 silver badges1414 bronze badges

  • 7This isn’t an answer to what the question is asking. – Kalcifer 7 hours ago
  • This post has been flagged by several members as “not an answer” and so has been deleted. Requests for clarification should be asked in comments (or, in this case, in the chat which will replace comments). Don’t write an incomplete posting which doesn’t answer the question, hoping to develop it into an answer, like a blog. Instead, I recommend you first wait until you have enough information to write a valid answer. – SamGibson 33 mins ago

Comments disabled on deleted / locked posts / reviews

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.