Testing different baudrate

Status
Not open for further replies.

prsu0001

Member
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
 
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.
 
Maybe you'll find this code helpful?

https://github.com/PaulStoffregen/USB-Serial-Print-Speed-Test/blob/master/usb_serial_print_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.
 
Status
Not open for further replies.
Back
Top