vini_i
vini_i

Reputation: 335

Choosing USB interface?

For full disclosure I'm an electrical engineer and software is not my strong suit. I want to build myself a CAN analyzer. The hardware is fairly simple, a CAN transceiver tied to a microcontroller. Where I'm struggling is how to interface this to a computer.

My knee-jerk reaction is to use a FTDI chip to convert serial to USB. This is fairly easy to program on the computer side and the data can arrive asynchronously in a streaming fashion. Also, FTDI has drivers for the USB device. The problem is that a serial connection can't sustain CAN speeds and stream the data. At best I would have to buffer the data on the micro and then send it to the computer.

My second thought is that I could set up a USB stack on the microcontroller. This would eliminate the physical bottleneck of the serial link. Theoretically, this accomplishes everything above. Where I falter is not knowing the practical limitations of such a link. USB 2.0 should be able to sustain CAN speeds without a problem but all of the serial terminals that I've worked with only go up to 115200. Is this a practical limit or could that speed be pushed faster if I talk to the driver directly?

Is there a USB link that is as easy to use as a virtual comm port but can natively sustain CAN speeds?

Upvotes: 0

Views: 209

Answers (1)

ralf htp
ralf htp

Reputation: 9422

if you implement a Virtual COM on the microcontroller the 115200 baud/bps rate can be exceeded

CAN has a maximal bit rate of 1Mbps ( https://www.orionbms.com/manuals/utility/acc_canbus_baud.html )

the unit of standard UART baud rates is in bps ( bits per second) and simulataneously baud because it is assumed that 1 symbol has 1 bit ( https://electronics.stackexchange.com/questions/9264/what-standard-uart-rates-are-there , https://learn.sparkfun.com/tutorials/serial-communication/rules-of-serial )

FTDI USB to UART chips have a maximal baud rate of 3MBaud ( 3Mbps ) ( http://www.ftdichip.com/Support/Knowledgebase/index.html?whatbaudratesarechievabl.htm ), so it is possible with FTDI chips to exceed the 115200 and also the 1Mbps of CAN

when using an USB stack that implements a Virtual COM on the microcontroller's USB interface ( CDC-ACM device class ) the baud rate can be increased higher cf Virtual COM port or using raw endpoints?

the LUFA stack ( http://www.fourwalledcubicle.com/LUFA.php ) has an implementation of a Virtual COM port ( CDC-ACM (Virtual Serial) Class Driver ) for Atmel MCU

in general too high data rates on UART / serial ( includes FTDI chips ) can be problematic because of transmission errors ...

also see http://www.wormwood.net/avrbaudcalc.php for the relation of clock rate and UART transmission rate

Upvotes: 2

Related Questions