ROBOTC.net Blog  

ROBOTC News

Using the VEX LCD Screen and ROBOTC Remote Screen – Part 1

2 comments

The VEX LCD Screen allows you to display 2 rows of 16 characters directly on your Cortex or PIC-based robot. It’s a fantastic tool for displaying messages, sensor values, and variables as your robot performs its tasks. If you’ve ever found yourself in the scenario where you couldn’t use the ROBOTC debugger, whether you couldn’t keep the robot tethered or didn’t have the equipment to use wireless debugging, you can appreciate how helpful it would be to have the robot display the values it’s sensing, or report what mode it’s currently in.

The LCD Screen connects to the Cortex in UART2 using this special Y-Cable. It connects to the RX and TX ports on the PIC using two standard 3-pin wires. No additional configuration in ROBOTC is needed to enable the screen. The LCD Screen also features 3 user-accessible buttons, enabling features like direct user input (without a remove control) and support for storing and choosing from multiple programs. We’ll go into more depth in a later tutorial.

We’ve added a number of new commands in ROBOTC to make using the LCD Screen straightforward. For example, in the sample code below, this one command “displayLCDCenteredString” allows you to choose a  line (0 or 1) and a message (any text in-between the “”) and ROBOTC automatically centers the text on that line. For a full list of available functions, check out the “Display” section of the ROBOTC Function Library, or ROBOTC Help Documentation.

task main()
{
 displayLCDCenteredString(0, "Hello World!");
 wait1Msec(10000);
}

Now let’s say you’re an instructor who would like to teach others how to use the LCD screen, but you’re having a hard time actually showing what’s going on to those in the back of the classroom, or you’d just like to take advantage of the display features, but don’t have access to a physical LCD screen. You’re in luck! In ROBOTC, we’ve added a new debug window called the “VEX Remote Screen” – emulating the exact behavior of the physical LCD screen, even the buttons!

To open the VEX Remote Screen, first download a program to your robot, and then go to the Robot menu, highlight Debug Windows, and select VEX Remote Screen. Now you can display the screen on a projector, and emulate the hardware, even if it isn’t physically attached. By default, ROBOTC will display the name of the program you are running. If your program takes advantage of the screen, like in the program above, this is what you get:

 

 

 

 

 

 

 

In addition to simply displaying a message, ROBOTC contains functions for specifying exactly where the next item should be displayed, displaying numbers, characters, strings of text, and clearing out lines. Check out the sample program below, and what the end result is on the LCD Screen.

#pragma config(Sensor, dgtl7,  touch,               sensorTouch)
#pragma config(Sensor, dgtl8,  sonar,               sensorSONAR_cm)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
 while(true)
 {
 clearLCDLine(0);
 clearLCDLine(1);

 displayLCDPos(0, 0);
 displayNextLCDString("Sonar: ");
 displayLCDPos(0, 7);
 displayNextLCDNumber(SensorValue[sonar], 4);
 displayLCDPos(0, 12);
 displayNextLCDString("cm");

 displayLCDPos(1, 0);
 if(SensorValue[touch] == 1)
 {
 displayNextLCDString("Bumper: Pressed");
 }
 else
 {
 displayNextLCDString("Bumper: Released");
 }

 wait1Msec(200);

 }
}

 

 

 

 

 

 

For more information using the ROBOTC display commands, check out the Display Functions section of the ROBOTC Help Documentation.

Written by Jesse Flot

December 21st, 2010 at 1:35 pm