Quantcast
Channel: tjakubowski
Viewing all articles
Browse latest Browse all 13

USB to Serial Converter

$
0
0

I recently bought two USB to Serial converters. This little devices are based on the CP2102 chip from Silicon Labs.

I am now using Linux as my development environment, so I did not have to install any drivers. I just plugged the device in and it worked. There was only one thing with device permissions. In order to use is I had to be root. To avoid this situation I created a file with udev rule to set proper permissions next time the device will be plugged in, so then I could use it as a normal user:

File: /etc/udev/rules.d/50-usb-serial.rules

SUBSYSTEMS=="usb",ATTRS{idVendor}=="10c4",ATTRS{idProduct}=="ea60",MODE:="0666"

Now, using the screen program I can open this serial port as a normal user.

The serial port is under /dev/ttyUSB0, we can see it from /var/log/syslog, when plugging in the device:

kernel: [35849.009413] usb 2-1.3.4: cp210x converter now attached to ttyUSB0

To test the converter just loop the RX to TX and open the serial port with the command:

screen /dev/ttyUSB0 115200

The two arguments to the screen command are: serial port device and baud rate (speed of transmission). When the loop is closed (TX is connected to RX), then every character sent will be immediately received, so when a key on the keyboard is pressed a corresponding character symbol should appear on the console. When the loop isn’t closed, only the transmit diode on the device blinks, but no characters appear on the console.

The USB to Serial converter is a simple device but very useful in embedded programming. Until now I could only blink with LEDs when I was programming my miniSUMO robot. Now I can sent at least one character, so I can trace what is the state of the robot. Also I have two radio receiver/transmitter, one for PC and one for the robot, but I couldn’t configure then properly, I always received garbage. With help of a SUB2Serial converter I can now attach both communications devices to the PC and try to figure it out how they should be configured. Without this I had to flash a new binary file to the miniSUMO robot whenever I wanted to test new configuration.



Viewing all articles
Browse latest Browse all 13

Trending Articles