Advanced Microcontroller Questions

I have a couple questions about the microcontroller. Lately I have heard the terms “rs-232”, RX and TX, serial port, and TTL. What are all of these ports? Are they just advanced ways to connect to the microcontrollers? And what would they be used for? Thanks if you know anything about these.

-Ben

This is all in the topic of ‘SPI’ a.k.a. Serial Protocol Interface

a serial port are those old ports on old computer hardly anyone uses anymore :smiley:

rs-232 is another communication protocol similar to SPI and is basically a fancy name for a serial port

TTL is Transistor to Transistor logic, it is a logic method that SPI uses

RX just means receive and TX means transmit

a lot of peripherals use SPI and the pins on the Vex micrcontroller reading TX and RX is an advanced way of communication with these peripherals

Well, I will try to explain them the best that I can.

“RS-232” refers to a specific communications standard used when devices communicate with each other over a serial port. It typically uses positive and negitive voltages.

“RX” and “TX” in this case, refer to the top two connection ports on the Vex Microcontroller above the Analog/Digital ports. These are used for serial communications. “RX” receives the incoming data and “TX” transmits the outgoing data.

A “Serial Port” refer to a type of communications port used by devices to communicate with each other. A “Serial Port” uses just two lines - one to transmit data and one to receive data. The digital information is sent in a series of 0’s and 1’s.

The VEX MIcrocontroller has two serial ports - one on the back next to the RC receiver inputs that is used for programming and the one I mentioned above the Analog/Digital ports (TX and RX ports) which can be used for accessories like the upcoming LCD screen due out this fall.

“TTL” refers to a family of logic chips that are used to build electronic circuits that run on +5 Volts. A low level logic signal is usually less than 1 Volt and a high level signal is usually around 4 Volts ( I think ).

I hope this information will help answer your questions and if I got anything wrong, hopefully somone will correct me

Thanks for the answers.

Does any one actually use the Rx and Tx Ports on top of the microcontroller. I have never seen these in use for any robots. Does any one have any pictures or applications of these ports in use? I think I read somewhere that robots could “talk” to each other through these ports. Has any one accomplished this either? It is going to be cool when the LCD screen comes out!

i attempted to make a connection between the Vex microcontroller and the Parallax BS2px microcontroller but I walked into the problem of BAUD rates. The baud rates of the Vex 115200 (i think close) and the BS2px 19600 were different thereofore I could not establish a connection btw the two controllers.

Technic-R-C

P.S. Happy Fourth Of July

I use the serial ports all the time, and I’ve been working on a robot that uses two Vex controllers that talk to each other. There are also serial devices like a compass that use the serial port. There is a prior poster that says serial isn’t used much any more, but you would be surprised at the number of systems that still use serial for external devices.

You can change the baud rates on the Vex to match the BS2. The default baud rate is 115200. Technic-R-C tell us your programming environment (Easy-C, MPLab, etc) and we can tell you how to get the BS2 to talk to your Vex

Great, I was misinformed about this topic. However now I would appreciate if you gave me the code for changing the baud rate in EasyC. Just plain C code will work great.

Thanks

Technic-R-C

Thanks for clearing up what some of these ports are used for. Now I have a very random question and I don’t want to start a new thread. I want to store data from a ultrasonic sensor and I have read that you can use an array? Can someone explain these more and how they work? Or does any one else know a simpler way of storing variables?

Thanks

-Ben

Yes you can. I believe I started this topic a couple of months, maybe years ago. (don’t have much time to find the post) Here is some more information about arrays that should help you get started.

Technic-R-C

Sorry for the delay in getting back to you.

EasyC has a central library of routines that it uses. The library is distributed as the WPILibray. If you look at the documentation you will find a series of routines that you need to use with the serial port:

unsigned char ReadSerialPortOne(void);
unsigned char ReadSerialPortTwo(void);
void WriteSerialPortOne(unsigned char byte);
void WriteSerialPortTwo(unsigned char byte);
void OpenSerialPortOne(unsigned baudRate);
void OpenSerialPortTwo(unsigned baudRate);

OpenSerialPortOne and OpenSerialPortTwo want the baud rate:
#define BAUD_4800 0x0081
#define BAUD_9600 0x0040
#define BAUD_14400 0x01AD
#define BAUD_19200 0x0181
#define BAUD_28800 0x0156
#define BAUD_38400 0x0140
#define BAUD_57600 0x012A
#define BAUD_115200 0x0115

Sample code:

OpenSerialPortOne(BAUD_19200); // Set to 19200 baud
while (1) {
WriteSerialPortOne(‘F’);
WriteSerialPortOne(‘o’);
WriteSerialPortOne(‘s’);
WriteSerialPortOne(‘t’);
WriteSerialPortOne(‘e’);
WriteSerialPortOne(‘r’);
}

Will write the string ‘Foster’ over and over to the first serial port at 19200.

I have a GPS that puts data out at 9600 baud, so to see what the strings look like on the console I do:

char GPS;
OpenSerialPortTwo(BAUD_9600); // Set to 9600 baud
while (1) {
GPS = GetSerialPortTwo();
WriteSerialPortOne(GPS);
}

Let us know how you make out.
Foster

Thank you Foster,

I will try this code as soon as I can and get back to you. Where is the link to this documenation you spoke off?

Technic-R-C

The WPILib home page has the links you need, this is the one to the documentation