Best way to interface UART sensor with RoboRIO?

What’s the best way to get UART sensor data to the RoboRio? As I understand it, the options would be going direct to the UART pins in the MXP port, using a MAX232 chip going to the RS232 port (disabling the serial console), or using a USB TTL converter. Can anyone with firsthand experience in any of the above shed some light on the pros/cons and how to implement, and/or point me to some more documentation?

UART on the MXP port is probably the best, as long as whatever device you’re talking to can receive with 3.3V if it needs to receive anything (The roboRIO is 3.3V logic, but 5V compatible, so if the device outputs 5V that is fine). Its the most reliable interface, that can’t really run into USB addressing issues. You can just use the WPILib SerialPort class to read from it.

You can see an example in my code for my Color Sensor adapter using a Pi Pico.

2 Likes

Great stuff, thanks. A few questions:

Would using UART on the MXP preclude us from using a navX in the MXP? What would be the recommend hardware device for us to interface with the UART pins on this port? I seem to recall only certain boards being approved? Finally, if we wanted to add a second UART device, would this be supported, and how would we need to do it?

The NavX has DIP switches on it that can disable the built in uart interface. You then could just use the UART header on the navx to access the pins.

The rules for only certain approved boards only comes into play if you’re using the PWM outputs on the MXP port. If you’re not, then you can do whatever you want with the MXP port. You could use any board, or even just wire directly into the right pins on the port.

Since UART is single device only, to run a 2nd uart device you’d need to use either a UART to RS232 adapter into the RS232 port, or a USB to UART adapter for that 2nd UART.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.