ROBOTC.net Blog  

ROBOTC News

Archive for February 3rd, 2011

Controlling the Brightness of the VEX Flashlight

without comments

VEX FlashlightThe VEX Flashlight is an awesome accessory that will let your robot “lighten up” any situation it’s in.

Cheesy puns aside, the VEX Flashlight contains four bright LED’s – useful for lighting up a dark environment, keeping constant light on an object or line the robot is tracking, or any number of other possible applications.

One of the limitations of the two-wire flashlight, though, is that its brightness cannot be controlled by the standard 3-wire MOTOR ports on the VEX PIC or VEX Cortex. In today’s post, we’ll overcome that limitation using one of the VEX Motor Controllers.

In the picture below, the VEX Flashlight is connected to MOTOR Port 2 on the Cortex using one of the VEX Motor Controllers. Also attached are a light sensor to measure the amount of light provided by the flash light in the ROBOTC Debugger, and a potentiometer to enable us to vary the amount of light.

In the sample program below, we use feedback from the potentiometer to control the brightness of the flashlight. The potentiometer provides values between 0 and 4095 on the Cortex, so we have to scale that down by a factor of 32 to stay within the range of values the Flashlight will accept (0 to 127). Note also, that in the configuration pragma statements, the flashlight is configured as a “reversed” motor; it actually accepts values ranging from 0 to -127. Reversing it allows us to give it more intuitive, positive values.

#pragma config(Sensor, in1,    light,               sensorReflection)
#pragma config(Sensor, in2,    potentiometer,       sensorPotentiometer)
#pragma config(Motor,  port2,           flashlight,    tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
 while(true) //Loop Forever
 {
 //Set the power of the flashlight equal to a scaled value from the potentiometer
 motor[flashlight] = SensorValue[potentiometer]/32;
 //Divide by 32 on the Cortex, since the potentiometer values are 0 - 4095
 //Divide by 8 on the PIC, since the potentiometer values are 0 - 1023
 }

}

Check out this video of the brightness control in action:


YouTube Direct Link VEX Flashlight - Brightness Control

In case you want to try this out, but don’t have a potentiometer, here’s more sample code that just cycles through different brightness values, over and over. You can see that programming the VEX Flashlight works basically the same as programming a motor.

#pragma config(Sensor, in1,    light1,              sensorReflection)
#pragma config(Motor,  port2,           flashlight,    tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
 //Loop Forever
 while(true)
 {
 //Turn off flashlight for 2 seconds
 motor[flashlight] = 0;
 wait1Msec(2000);

 //Turn on flashlight at 1/4 brightness for 2 seconds
 motor[flashlight] = 31;
 wait1Msec(2000);

 //Turn on flashlight at 1/2 brightness for 2 seconds
 motor[flashlight] = 63;
 wait1Msec(2000);

 //Turn on flashlight at 3/4 brightness for 2 seconds
 motor[flashlight] = 96;
 wait1Msec(2000);

 //Turn on flashlight at full brightness for 2 seconds
 motor[flashlight] = 127;
 wait1Msec(2000);
 }
}

Written by Jesse Flot

February 3rd, 2011 at 2:48 pm

Posted in Cortex,PIC,VEX

Tagged with , ,

Programming Robots in Virtual Worlds

with 3 comments

Carnegie Mellon will release a fully working, downloadable “Technical Demonstration” of their new Robot Virtual World (RVW) programming tool to the world on February 9, 2011.

The first world takes students to planet H99 where they will be able to program their robots using feedback from encoders, sonar, and compass sensors. The RVW project is designed to blend computer science lessons, engineering design, and gaming to teach programming and CS-STEM concepts.

Level One World

Students will earn points and access new levels as they learn to program

Students will program LEGO and VEX robots during training, but they will also be able to program virtual world machines like the scientist’s rover or the flying methane sensor. These vehicles will be programmed using the same ROBOTC IDE that students use when they program their LEGO and VEX robots.

We are also integrating opportunities to program LabVIEW front panels into the RVW. The front panels will be developed using

Virtual World Programming and simulator

National Instruments free LabVIEW Web UI Builder software. Data

fed to the virtual instruments will be derived from conditions in the virtual world as well as from the virtual robots.

Planet H99

The first Robot to the Rescue Computer Programming Game is set on Planet H99. The year is 2050 and the Global Federation of World Evolution has a collaborative research project named H99; short for Habitat 99. The goal of H99 is to place a human colony on the planet by 2099.

The planet is being terraformed by a team ofhumans and robots with the majority of the work is being done by the robots. (Terraforming is the process of deliberately modifying the atmosphere of a planet to make it habitable by humans.) The student’s job is to program and manage the robots!

Digital Display

Virtual Worlds screenshot

Pictured above and to the right is the simulator that will display the robot’s behaviorto the student.

They will be able to zoom in and out and control the camera’s angle using this interface.

Pictured at the right is an example of the type of digital display that students will be able todesign and program as they play the game. We envision opportunities to develop displays for the greenhouse, fuel stations, vehicles, the weather, and any other game element that has constantly changing data.

Written by Vu Nguyen

February 3rd, 2011 at 9:33 am

Posted in General News,NXT,VEX