This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

about serial communication baud rate

If we set different baud rates in an master-slave system,can the system work correctly?!thank you!

Parents Reply Children
  • I had something else in mind.
    What kind of serial communication?
    SPI, RS-232, 10BASE-T, USB, IrDA, SATA and so on. It's kind of a vital piece of information.

  • Hi,i used a RS485 in a master-slave system,if some slaves uses a different baud rate from master,can they communicate with the master correctly?Thank you!

  • Hi,i used a RS485 in a master-slave system,if some slaves uses a different baud rate from master,can they communicate with the master correctly?

    In theory, it is possible for the master to auto-detect slave's baud rate and adjust its own accordingly, provided the protocol permits this. But it's probably much easier to get the slaves to use the correct baud rate to begin with.
    So the short answer is 'no.'

  • If the master auto-detects the baudrate, then the master and the slave isn't using different baudrates.

    The problem is that a master will not know which slave until it has auto-detected the baudrate, which makes life interesting if the system has multiple slaves with different baudrates.

    Asynchronous transfers requires that the baudrate error is very, very small, since the receiver is counting time to decide when to sample the individual bits.

  • Ok,here is my understanding:
    Whatever it is a master or a slave,if it is a transmitter,and then it's baud rate is used to transmit the data,it is the most original usage and meaning.If it is a receiver,then it's baud rate is used to sample the data in the bus,just a counter!
    Ok,if all of these is right,why can't the slave set a different baud rate from the master,if it gurantees the rate of sampling is quick enough to detect the data on the bus which it is transmited by the master? Thanks!

  • Because the receiver only detects the first flank of the start bit of a byte.

    Then the receiver counts fixed time based on the configured baudrate, to decide where to sample the bits in the byte.

    Only when the receiver has an almost perfect baudrate will it manage to sample the bits at the correct position, reproducing the transmitted byte.

    Connect two PC together, and set them to different baudrate and try to communicate. Notice the strange characters you will see on the receiver side? It does detect transitions and decides that it sees start bits. Then it will either sample too slow (continue way past the stop bit(s)) or too fast, being done way before the stop bit(s).

    It is only when performing an auto-detect that the receiver (hardware or software) tries to perform either higpseed sampling of the bits, or measure the times between multiple flanks, to figure out the baudrate. That is also why protocols that has autobaud support normally starts with some specific bytes to make sure that the sent bytes has a good pattern for auto-detect.

    The uart does a check for existence of a stop bit after having counted through all data bits and an optional parity bit. But if there is no stop bit found, the uart will not know if this was caused by an incorrect baudrate or if it detected a false start bit. All you know is that if you get a lot of parity errors or framing errors (missing stop bit), the probability is high that you have the wrong baudrate. It could also be the result of a too long cable and bad signal integrity.

  • Addendum - the slave is not an oscilloscope that runs at an extremely high sampling rate to sample a nice-looking curve.

    The normal design is that the receiver runs at 16 times the baudrate. It then takes 3 samples in the middle of each bit window and does a majority vote to decide if it's a one or a zero. If the baudrate is slightly off, this sampling window will drift so the receiver may sample during the transition between two bits. Or it may perform two sets of reads while the transmitter is still on the same bit, in case the receiver has too low baudrate.

    Remember that the data transmitted may not toggle the data on every bit windw - you may have one start bit followed by four data bits of same polarity as the start bit. Then four data bits with the same polarity as the stop bit(s). If you didn't know the baudrate but just looked at the scope image - exactly what would you think about that square wave? How would a receiver compensate to make sense of it?

    The baudrate is a "common secret" that the transmitter and receiver must agree on to get the communicatin working. It is possible to transmit test patterns and have the receiver autodetect. But you will have to write code for the autodetect unless you have a processor with hw autodetect. And you do need the test pattern - if you autodetect on live data, then one or more bytes will have been lost before the autodetect is done.

    A modem can autodetect on the "AT" characters.

    How will slaves autodetect when you have one master and multiple slaves and different slaves have different baudrate? Whenever you switch to talk to another slave, the baudrate may change - so the slave must either hope that the master returns later with the same baudrate, or it will have to retrain continuously - remember that the slave must be able to pick up protocol data to figure out the message address so it knows if it should care about the message or not.

    Now, exactly why are you pushing this concept, in the first place?