ROBOTC.net Blog  

ROBOTC News

Archive for December, 2010

Communicating with the Magnetic Field Sensor

without comments

DiMastero, one of the new forum regulars has come up with a very novel way to use the new HiTechnic Magnetic Field Sensor; to relay messages by varying an NXT motor’s magnetic field. One position is set as a binary 0 and the opposite position is a 1.  The user can set the angle of the reference motor to 0-255 degrees (8 bits). The angle is then sent to the sensor using a “communication” motor and read by the sensor.  The NXT then copies the relayed angle to the other motor.  It’s a pretty cool way to use this sensor!

Check out the video below.


YouTube Direct Link 

The code for this project is available at the original article: [LINK].

Written by Xander Soldaat

December 30th, 2010 at 1:53 am

NXT Gyroscope Experiment

without comments

Thanks to DiMastero again for the project submission!

Here we have a Gyroscope using an NXT and programmed with ROBOTC. The wheel will automatically correct itself and keep it level no matter how you move and rotate the platform. Take a look at the video:


YouTube Direct Link 

How it works (From DiMastero)

In order to get some feedback, it’s programmed to show the motor’s speed (increased by ten percent every touch sensor click) and predict/ display the RPM the gyro is turning at, up to a maximum of 2500. The gyro is more or less stable from a motor speed of 20 onwards, but vibrations only stop after about 60. The gyro starts to straighten more quickly after about 80.

Photos

Gyroscope

Gyroscope 2

Gyroscope 3

Written by Vu Nguyen

December 21st, 2010 at 1:50 pm

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

with 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

Using the Cortex and a VICTOR 884 to Control a 12V DC Motor

without comments

As a continuation of our “Using the VEX Cortex and PIC to control cool stuff” series, this week we’re using the VEX Cortex to control a very powerful and very fast 12V DC motor. The standard VEX motors operate on roughly 5V DC, so in order for the Cortex or PIC to control a larger motor, a second power supply must be used. However, the VEX Cortex and PIC both regulate the voltage they provide the motors, so simply hooking up a larger power supply won’t work – and doing so would risk damaging the actual microcontroller.

To solve this problem, we can introduce an intermediary component – a VICTOR 884 Speed Controller. The VICTOR sits between the 12V power supply, VEX microcontroller, and 12V DC motor, isolating the microcontroller from the high voltage. The VICTOR connects to a MOTOR port on the Cortex or PIC using a male-to-male 3-pin wire, and accepts standard ROBOTC motor commands and motor powers. Based on commands from the microcontroller, the VICTOR then passes the appropriate amount of voltage from the power supply to the motor. For detailed instructions and procedures for creating your own setup, follow along with the Relay and PWM Lab from the VEX Curriculum 2.0.

Check out this video, where we use feedback from the potentiometer control the speed of the 12V DC motor.


ROBOTC Code:

#pragma config(Sensor, in1,    potentiometer,       sensorPotentiometer)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
while(true)
{
//If the potentiometer is turned less than half way...
if(SensorValue[potentiometer] < 2048)
motor[port2] = (SensorValue[potentiometer] - 2048)/16;  //...move in reverse.
else  //Else, the potentiometer is turned more than half way, so...
motor[port2] = (SensorValue[potentiometer] - 2048)/16;  //...move forward.
}
}

NOTE: DO NOT TRY THIS YOURSELF WITHOUT QUALIFIED SUPERVISION. Failure to follow correct procedures and setup can result in personal injury and/or damage to the electrical components.

Written by Jesse Flot

December 10th, 2010 at 4:12 pm

Posted in Cortex,PIC,VEX

VEX Claw Attachment

without comments

Building with the VEX Robotics System? Need inspiration? This set of building instructions may be just what you need!

This claw-based design features two curved arms, perfect for grasping small objects, like play-pen balls and wooden blocks. The two arms are driven using a single motor, attached to a worm gear. A bumper sensor is included, to let your robot know when it has a firm grasp on an object.

You can download the building instructions by clicking here.

Need help programming the claw? Check out the tutorial videos in the VEX Cortex Video Trainer.

Written by Jesse Flot

December 2nd, 2010 at 5:31 pm

Posted in VEX