Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Testing different baudrate

  1. #1
    Junior Member
    Join Date
    Feb 2020
    Posts
    16

    Testing different baudrate

    Is there any way to test the different baud rates (9600,58000,100000,200000,400000,500000) in teensy 3.6 by just writing a simple program in the arduino using USB serial?



    Regards
    Prasanna

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,649
    USB Serial doesn't actually the baud rate setting. Communication always happens at the full USB speed. But USB has a complex protocol with end-to-end flow control, so the actual speed involves protocol overhead and automatic flow control based on the software speed on both sides of the connection.

    On Teensy, we have a Serial.begin(baud) function for compatibility with Arduino. The baud number is ignored. You can use any number. It has no effect. The baud setting is only there for code written for Arduino boards which do have hardware serial connected to a USB-serial chip.

    The baud rate setting on your PC also has no effect on the communication. But that PC setting is available on the Teensy side, with Serial.baud(). Normally this would be used if you intend to make a USB-serial converter. In Arduino, click File > Examples > Teensy > USB_Serial > USBtoSerial for an example of how this is done. Because USB has flow control built in, when code on Teensy only reads the USB serial data at the speed a real serial port can transmit, the flow control prevents the PC from sending more than will fit into the buffers on Teensy. The overall speed adapts based on the software speed, even though that actual USB communication is always at the full USB speed.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,649
    Maybe you'll find this code helpful?

    https://github.com/PaulStoffregen/US...rint_speed.ino

    If you run this on Teensy and other boards, you'll see the actual printing speed. On real serial boards the baud rate setting controls the speed. On native USB boards like Teensy, you will get the same speed regardless of the baud setting. If you test with other boards like Arduino Zero or Leonardo, you'll also see the speed is very different. The efficiency of the software matters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •