ROBOTC.net Blog  

ROBOTC News

Archive for the ‘vex’ tag

VEX/Arduino Bot Chases the Light

with 2 comments

Close up of the ‘Scaredy Bot’. Note the two VEX Light sensors side by side that provide the control for the robot’s movement.


YouTube Direct Link 

When someone thinks “robots’, they generally think of cold, calculating, emotionless machines. This couldn’t be further from the truth; all robots, from the complex humanoids to the basic welding arms seen in car plants, have complex and deep emotional personalities.

For instance, take a look at our new “Scaredybot”. Built entirely from VEX parts, an Arduino, and the sweat of our intern Dan West (by the way, great work Dan!), the Scaredybot is so ‘brave’ that it cannot stand being in the dark; given the choice, it will either chase a light source for dear life or spin blindly in place (desperately seeking a respite from the darkness).

On the technical side, the Scaredybot uses two VEX Light Sensors to compare light values on the left and right side of the robot and turns the robot towards whichever side is higher. By constantly moving side by side using swing turns (much like a line-tracking robot), the Scaredybot is able to track the light source as long as its sensors are able to read the light values. When the Scaredybot loses its light source, it spins in place until a light source is found again, at which point it starts to track it again.

Written by John Watson

July 30th, 2012 at 5:19 pm

RC Car to Arduino Robot – First car converted!

with 2 comments

The Arduino is one of the most diverse robotics platforms. It truly opens the world of modern electronics to the students by allowing them to interface with all sorts of relevant, modern technology. We have seen this unfold in our latest project with the Arduino, the RC car hacking project.


YouTube Direct Link 

For this project, we decided a good candidate to start with would be the New Bright RC ‘Interceptor’, a larger scale car that fit a standard-sized Arduino (in this case, an UNO) and a breadboard with lots of room to spare. This surplus of space opens up tons of options for adding sensors in the future. Plus, by tapping into the car’s standard battery we eliminated the need to add a second one. Since we needed to be able to control the RC car’s DC motors with the Arduino, we decided to use the VEX Motor Controller 29 to convert the PWM signals into corresponding voltage levels. This solution was cheap, easy, and effective; a true engineering triple play.

Once the Arduino was implanted into the RC car, it was time to tell the newborn robot to do something. Of course, we did this using our favorite programming software, ROBOTC for Arduino (more on this later).

Close up on the hacked internals of the 'Interceptor'.

It is important to realize that while most robots have a tank style drive system, the RC cars have the same steering system as that found in real-sized cars (Ackermann Steering). This unfortunately eliminates the possibility of making point turns, but it does open the doors to other interesting opportunities such as parallel parking (we plan on showcasing this in a later update).

Besides being incredibly awesome, this project also helps to expand upon the superb flexibility of the Arduino and VEX systems; although not specifically designed for one another, they can easily be used together with little or no modification  to either system.

We could never allow you, the reader, to miss out on the hacking. If you are interested in this or any of our other current projects, we encourage you to take a look at the tutorials on our wiki. At the moment they are works-in-progress, but we are well on the way of having step-by-step guides for hacking a variety of vehicles, with different scales and sizes, and different methods of operation. We ultimately want the tutorials to act as guides to hack any RC vehicle, even if we do not cover it specifically.

Keep an eye on this blog and our wiki for the latest updates. If you have any hacking stories, we’d love to hear about them on our forums. Good luck, and get hacking!

Written by Jacob Palnick

July 6th, 2012 at 1:08 pm

Basic Electronics and Arduino: A Winning Combination

with 2 comments

Electronics is an integral part of innovation, yet many electronic classes across the United States are being closed because of NCLB(1) and ever-shrinking school budgets.  However, more and more schools are instead opening robotics courses. With the Arduino platform we saw an opportunity for educators to integrate basic electronic principles into existing robotics courses using the VEX, LEGO, and BoE  hardware. Fortunately, Arduinos are very inexpensive and can be used not only as a mobile robot controller, but to create lots of other “smart” stuff as well.

Arduino on a NXT platform

The Arduino exposes students to a basic microprocessor concepts, prototyping on a breadboard, and basic electronics concepts through many cool projects.  The Arduino takes the processor ‘out of the box’ and gives students the opportunity to ‘build from scratch’ electronics systems. To augment these features, we’ve developed lessons around LEGO, VEX, and the BoE bot at our ROBOTC wiki and by the end of the summer we will have a set of plans that allow students to turn a RC car fully autonomous.  We have a team of folks dedicated to creating a series of lessons that makes teaching electronics through robots fun and easy, all while using technology that is already in your classroom.

In this regard, we have a very broad range of projects in mind for ROBOTC for Arduino; everything from basic LED control to creating homebrew sensors is covered. The end-goal for this research and development project is to expose students to a broad range of basic electronic concepts from simple circuitry to digital input (on/off switches) to analog inputs (potentiometer) to PWM concepts. As we continue to develop our ROBOTC for Arduino support materials, we need your help.  We are asking you, the ROBOTC community, to recommend projects that you are working on and are willing to share with educators and hobbyists.  Please consider sharing your project ideas and we will be glad to post them on both our blog and wiki. As always, keep an eye on our forum, Facebook, and Twitter pages for the most up-to-date news. Thanks!

Arduino on a BoE-bot platform.

Arduino on a VEX platform.

Written by John Watson

June 29th, 2012 at 2:25 pm

Posted in Arduino,General News

Tagged with , , , , ,

Major Improvements in ROBOTC 3.05 for VEX Cortex

without comments

ROBOTC 3.05 contains a number of enhancements that should be very exciting for VEX Cortex users. This is a free update for all ROBOTC for Cortex and PIC users (yes, even if you were using 2.3x)!

The ROBOTC 3.05 installer now includes the VEX Cortex and Prolific USB-to-Serial drivers. You no longer need to remember to download and install these separately.

We’ve heard your feedback! The new “Automatically Update VEX Cortex” option will detect if your Cortex is out-of-date, and automatically download the latest version of the Master CPU and ROBOTC Firmware files if needed. There’s no need to go through the long process of manually downloading each firmware, or put the VEX Cortex in “bootload” mode! The same functionality has been implemented for the VEXnet Joysticks as well.

Also included is a new version of the Master CPU Firmware from VEX Robotics. This version restores the functionality from the 2.x firmware, which allowed programs to run even when VEXnet was turned on (but not used).

New Standard Models! Standard models for the popular Robotics Academy robots and PLTW Training Testbeds have been added, and can be used to automatically configure all of the motors and sensors, hassle free.

New and improved sample programs! New sample programs for the VEX Mecanum Wheels and Line Tracking Kit have been added. others have been improved.

You now have the ability to give your robot a custom name. This will be a crucial enhancement for competition teams, and should be helpful for classroom settings, too.

Written by Jesse Flot

January 13th, 2012 at 12:15 pm

VEX Mecanum Drive using ROBOTC

with one comment

One cool new product for the VEX Robotics system are the VEX Mecanum Wheels.

Where traditional wheels only allow your robot to move forward, backward, and turn, mecanum wheels allow your robot to  move in all four directions -  forward, backward, left and right, while still maintaining the ability to turn. Your robot is able to accomplish this thanks to their unique design. Each wheel (which must be connected to its own, independent motor) contains rollers offset by 45 degrees from the wheel and the robot’s drive train. Instead of the motors introducing force in just the forward-backward directions, each wheel introduces force at 45 degree angles (45, 135, 225, 315). The force vectors of the different wheels can then be combined and/or cancelled out to create motion in the X and Y axis.

Here’s video of the Mecanum wheels in action (the code running on the robot can be found later in the post):

To give the wheels a test run, we built the robot below. Notice that if you’re looking down on the robot, the spokes or rollers of the wheels should point inward to create an X. If you’re looking at the bottom of the robot, they should point out to create a baseball diamond. There are two sets of two wheels - all four are not identical.

[scrollGallery id=4]

When you decide to incorporate your own mecanum drive system, be sure to follow the X/diamond rule or your robot will not behave as expected. Also know that equal weight distribution and consistent build quality are far more important when working with a mecanum drive. Remember that the robot moves based on adding and/or cancelling out the different force vectors produced by the four individual motors – if one or two motors can’t match the others the entire motion of the robot will be thrown off.

A fairly simple program can be written  to test the mecanum drive system. This program will use the left joystick on the remote control to move the robot forward-backward and right-left. The X axis on the right joystick will control the rotation of the robot.

#pragma config(Motor,  port2,           frontRight,    tmotorNormal, openLoop)
#pragma config(Motor,  port3,           backRight,     tmotorNormal, openLoop)
#pragma config(Motor,  port4,           frontLeft,     tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port5,           backLeft,      tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++
Mecanum Drive - Basic
- This program allows you to remotely control a robot with mecanum wheels.
- The left joystick Y-axis controls the robot's forward and backward movement.
- The left joystick X-axis controls the robot's left and right movement.
- The right joystick X-axis controls the robot's rotation.

[I/O Port]          [Name]              [Type]                [Description]
Motor Port 2        frontRight          VEX Motor             Front Right motor
Motor Port 3        backRight           VEX Motor             Back Right motor
Motor Port 4        frontLeft           VEX Motor             Front Left motor
Motor Port 5        backLeft            VEX Motor             Back Left motor
--------------------------------------------------------------------------------------------------*/

task main()
{
//Loop Forever
while(1 == 1)
{
//Remote Control Commands
motor[frontRight] = vexRT[Ch3] - vexRT[Ch1] - vexRT[Ch4];
motor[backRight] =  vexRT[Ch3] - vexRT[Ch1] + vexRT[Ch4];
motor[frontLeft] = vexRT[Ch3] + vexRT[Ch1] + vexRT[Ch4];
motor[backLeft] =  vexRT[Ch3] + vexRT[Ch1] - vexRT[Ch4];
}
}

The program above, however, isn’t perfect. If the joysticks don’t center perfectly at zero, or if the driver unintentionally moves the joysticks along multiple axis, the movement of the robot will be thrown off. With a few variables and a little bit of logic, we can ignore these erroneous values and provide smoother control of the robot:

#pragma config(Motor,  port2,           frontRight,    tmotorNormal, openLoop)
#pragma config(Motor,  port3,           backRight,     tmotorNormal, openLoop)
#pragma config(Motor,  port4,           frontLeft,     tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port5,           backLeft,      tmotorNormal, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++
Mecanum Drive with Deadzone Thresholds
- This program allows you to remotely control a robot with mecanum wheels.
- The left joystick Y-axis controls the robot's forward and backward movement.
- The left joystick X-axis controls the robot's left and right movement.
- The right joystick X-axis controls the robot's rotation.
- This program incorportes a threshold/deadzone that allows very low Joystick values to be ignored.
This allows the robot to ignore values from the Joysticks when they fail to center at 0,
and provides a margin of error for the driver when they only want the robot to move in one axis.

[I/O Port]          [Name]              [Type]                [Description]
Motor Port 2        frontRight          VEX Motor             Front Right motor
Motor Port 3        backRight           VEX Motor             Back Right motor
Motor Port 4        frontLeft           VEX Motor             Front Left motor
Motor Port 5        backLeft            VEX Motor             Back Left motor
--------------------------------------------------------------------------------------------------*/

task main()
{
//Create "deadzone" variables. Adjust threshold value to increase/decrease deadzone
int X2 = 0, Y1 = 0, X1 = 0, threshold = 15;

//Loop Forever
while(1 == 1)
{
//Create "deadzone" for Y1/Ch3
if(abs(vexRT[Ch3]) > threshold)
Y1 = vexRT[Ch3];
else
Y1 = 0;
//Create "deadzone" for X1/Ch4
if(abs(vexRT[Ch4]) > threshold)
X1 = vexRT[Ch4];
else
X1 = 0;
//Create "deadzone" for X2/Ch1
if(abs(vexRT[Ch1]) > threshold)
X2 = vexRT[Ch1];
else
X2 = 0;

//Remote Control Commands
motor[frontRight] = Y1 - X2 - X1;
motor[backRight] =  Y1 - X2 + X1;
motor[frontLeft] = Y1 + X2 + X1;
motor[backLeft] =  Y1 + X2 - X1;
}
}

Both of the above pieces of sample code will be included in ROBOTC 3.05. The VEX Mecanum wheels, along with all of your hardware needs can be purchased from the Robomatter store.

Written by Jesse Flot

November 22nd, 2011 at 2:36 pm

Programming the VEX Gyro in ROBOTC

with one comment

The new VEX Yaw Rate Gyro is one of the more sophisticated sensors in the VEX Robotics System – but it’s also one of the most useful and powerful. Among other things, the Gyro allows your robot to make very precise, consistent turns.

Other sensors, like the Shaft Encoders, allow you to control your robot’s turns… but indirectly. The Shaft Encoders can measure the rotation of the axles (or shafts) of your robot’s drive train. By monitoring how much the axles spin, you can also monitor and control how much your robot moves forward or turns. (As a side note, some great tutorials on using the Shaft Encoders to do just that can be found in the Movement section of the VEX Cortex Video Trainer.)

The Gyro, on the other hand, actually measures the rotation of your robot. Factors such as wheel slippage and varying surface friction that cause inconsistencies with Shaft Encoder-based turns are far less problematic with the Gyro; your robot will turn until it reaches the target you set – no matter how much the wheels slip or how long it takes!

There are a number of different ways that electronic Gyros work. The VEX Gyro includes a sensing element kept in continuous oscillation which reacts when angular rate is applied, based on the “Coriolis effect”. The Coriolis effect is a deflection of moving objects when they are viewed in a rotating reference frame. In a reference frame with clockwise rotation, the deflection is to the left of the motion of the object; in one with counter-clockwise rotation, the deflection is to the right. This effect is caused by the rotation of the Earth and the inertia of the mass experiencing the effect.

Thus, the Gyro is able to detect whether the robot is turning clockwise or counter-clockwise and provide different sensor values based on how much it’s been rotated. For a more thorough explanation of the Coriolis effect, visit this Wikipedia article. For more technical information on the on the internals of the VEX Gyro, you can check out its datasheet.For this tutorial, we mounted the VEX Gyro on our Swervebot robot model and connected it to Analog port 8 on the Cortex.

ROBOTC includes a number of sample programs for the Gyro. You can open the sample program below by going to File > Open Sample Program > Gyroscope > “Gyro Based Turns – Basic.c”.

A few additional notes about the Gyro and the program:
  • Typically all sensors are configured in ROBOTC using the Motors and Sensors Setup window. This can still be done with the Gyro, but lines 23-28 do so manually. The Gyro is an extremely sensitive sensor – it’s readings are affected by heat, fluctuations in voltage, and how long the sensor has been in use. These factors cause the sensor to accumulate an error, or drift, over time. By setting Analog Port 8 to “sensorNone” on line 24, all of the drift is wiped out from previous runs. The sensor is then reconfigured as a “sensorGyro” on line 27.
  • After the Gyro is configured on line 27, it’s very important that your robot is kept completely still for at least 1.1 seconds. During this time, ROBOTC and the Gyro perform a calibration process. The 2-second wait on line 28 is more than enough time for this process to occur.
  • There is a small amount of variance between each Gyro. ROBOTC has default values used for scaling the readings from the VEX Gyro into useful SensorValues, but you may need to make a slight adjustment for your sensor. The “SensorScale[]” command (commented out on line 31) allows you to do just that. If you find that your robot is turning too far or too little, un-comment line 31 and adjust the “260″ value as needed.
  • As the Gyro is turned, the values it returns are in tenths of degrees, positive and negative. Thus, a SensorValue of 3600 equals 360 degrees, or one full rotation. When the sensor is mounted horizontally, counter-clockwise movements will return values from 0 to -3600; clockwise movements will return values from 0 to 3600. Once the gyro completes one full revolution, the sensor value will “roll-over” to 0 by default (for example: …3597, 3598, 3599, 3600, 0, 1, 2, 3,…). To change the “roll-over” point, un-comment line 33 and change the value of “SensorFullCount” from 3600 to the desired value (7200, 18000, ect)
  • For a much more thorough explanation of the program, check out the tutorial video we produced, here.
#pragma config(Motor, port2, rightMotor, tmotorNormal, openLoop)
 #pragma config(Motor, port3, leftMotor, tmotorNormal, openLoop, reversed)
 //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++
 Gyro Based Turns - Basic
 -This program instructs your robot to turn for the specified number of degrees in "degrees10".
 -For best sensor results, clear out the gyro and manually configure it at the begging of the code.
 -The Gyro is configured by default to provide values from 0 to -3600 for clockwise rotation,
 and 0 to 3600 for counter-clockwise rotation

Robot Model(s): Swervebot

[I/O Port] [Name] [Type] [Description]
 Motor Port 2 rightMotor VEX Motor Right side motor
 Motor Port 3 leftMotor VEX Motor Left side motor
 Analog Port 8 in8 VEX Gyro Top-center mounted,
 away from the Cortex
 --------------------------------------------------------------------------------------------------*/

task main()
 {
 //Completely clear out any previous sensor readings by setting the port to "sensorNone"
 SensorType[in8] = sensorNone;
 wait1Msec(1000);
 //Reconfigure Analog Port 8 as a Gyro sensor and allow time for ROBOTC to calibrate it
 SensorType[in8] = sensorGyro;
 wait1Msec(2000);

//Adjust SensorScale to correct the scaling for your gyro
 //SensorScale[in8] = 260;
 //Adjust SensorFullCount to set the "rollover" point. 3600 sets the rollover point to +/-3600
 //SensorFullCount[in8] = 3600;

//Specify the number of degrees for the robot to turn (1 degree = 10, or 900 = 90 degrees)
 int degrees10 = 900;

//While the absolute value of the gyro is less than the desired rotation...
 while(abs(SensorValue[in8]) < degrees10)
 {
 //...continue turning
 motor[rightMotor] = 25;
 motor[leftMotor] = -25;
 }

//Brief brake to stop some drift
 motor[rightMotor] = -5;
 motor[leftMotor] = 5;
 wait1Msec(250);
 }

Here’s a video of the robot moving, based on the code:

And again, just in case you missed it, a more detailed explanation of the program can be found in this tutorial video:

The VEX Gyro can be purchased from the RoboMatter store.

Written by Jesse Flot

October 13th, 2011 at 5:08 pm

Posted in Cortex,General News,VEX

Tagged with , , ,

New VEX Robot Building Instructions Available!

with one comment

Tired of the same old robot models? Look no further! We’re proud to present a new set of classroom-ready robot building instructions.

First up, we have the new and improved Squarebot 4.0:

Squarebot 4.0 features:

  • 1 VEX Cortex
  • 2 Shaft Encoders
  • 1 Limit Switch
  • 1 Bumper Switch
  • 1 Ambient Light Sensor
  • 1 Ultrasonic Rangefinder
  • 1 Potentiometer
  • 1 VEX LCD Screen
  • 2 Driving Motors
  • 1 Arm Motor

And second, we’ve augmented our popular Swervebot model with an arm!

The Swervebot has a more slender wheelbase and rear caster, making it more suitable for line tracking and fitting in small spaces. It also features:

  • 1 VEX Cortex
  • 2 Shaft Encoders
  • 2 Bumper Switches
  • 3 Line Tracking Sensors
  • 1 Ultrasonic Rangefinder
  • 1 Potentiometer
  • 1 VEX LCD Screen
  • 2 Driving Motors
  • 1 Arm Motor

Note that having all of the sensors isn’t required to take advantage of these great robot models. Build them using the parts that you have – or just use the instructions for your own inspiration.

These models along with many others can always be found at the Robotics Academy site.

Written by Jesse Flot

August 8th, 2011 at 1:54 pm

Controlling the MINDS-i Lunar Rover with a VEX Cortex

with one comment

Article written by Steve Comer

Remote control cars are great for having fun. They can be driven off-road, taken off jumps, and raced among other things. VEX robots are great for learning. They can be used to teach programming, math, problem solving, and other engineering skills. What do you get if you put them together??

Well, I can tell you. You get a rugged 4WD truck that is still tons of fun to drive around outside, but can also be used as a teaching tool.

Follow this link for more photos: http://s1081.photobucket.com/albums/j353/comeste10/VEX%20Rover%20Extras/

I started off with a MINDS-i Lunar Rover kit which is driven by a 7.2V DC motor and steered with a standard hobby servo. I removed the solar panel from the Rover and in its place put a VEX Cortex microcontroller and an LCD screen. On each side, I attached a VEX flashlight from the VEXplorer kit and I mounted an ultrasonic sensor to the front. It just so happens that VEX bolts and nuts fit quite easily into the beams of the MINDS-i rover.

I did all the programming in RobotC. See bottom of the page to view my RobotC code.

In order to control the stock motor and servo with the Cortex, I had to make a few modifications. I soldered the two wires to a 2-pin head which I then connected to the Cortex with a VEX motor controller.

For the servo, I used three single male-to-male jumper cables.

The video demonstrates the rover in autonomous mode where it makes use of the ultrasonic sensor to avoid bumping into walls. Remote control is also demonstrated using the VEXnet controller over Wi-Fi.

This is just a small sampling of the possibilities with this combination type of platform. Don’t let my initial direction limit you. It would be great to see some new combination robots. Get out there and start building!

This is my RobotC Code for the behaviors seen in the video.

AUTONOMOUS MODE:


#pragma config(UART_Usage, UART2, VEX_2x16_LCD)
#pragma config(Sensor, dgtl1,  sonar,               sensorSONAR_inch)
#pragma config(Motor,  port1,           L,             tmotorServoStandard, openLoop)
#pragma config(Motor,  port2,           servo,         tmotorNormal, openLoop)
#pragma config(Motor,  port3,           drive,         tmotorNormal, openLoop)
#pragma config(Motor,  port10,          R,             tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
/////////////////////////////////////////////////////////////////////////
//  Author  : Steven Comer//  Program : Rover drives straight until near an object, it then slows,
//            stops, then backs up and turns.
//  Updated : 8 June 2011 @ 10:20 AM
/////////////////////////////////////////////////////////////////////////
task main()
{

  //pause at start and turn on headlights
  wait1Msec(2000);
  motor[R] = -127;
motor[L] = -127;
while(true)
{
clearLCDLine(0);
    displayNextLCDNumber(SensorValue(sonar), 3);

    //++++++++++++++++++++++++++++++CLEAR++++++++++++++++++++++++++++++++
if( SensorValue(sonar) > 20 || SensorValue(sonar) == -1 )
{
motor[servo] = -2;
motor[drive] = 50;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++APPROACH++++++++++++++++++++++++++++++
else if( SensorValue(sonar) <= 20 && SensorValue(sonar) > 15 )
{
motor[drive] = SensorValue(sonar) + 25; //power decreases
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++STOP AND TURN+++++++++++++++++++++++++++
else if( SensorValue(sonar) <= 15 )
{
//stop
motor[drive] = 0;
wait1Msec(500);
//back and turn
motor[servo] = random[50] + 60;
     //random degree
motor[drive] = -50;  //random power
wait1Msec(1000);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 }
}

REMOTE CONTROL MODE:


#pragma config(UART_Usage, UART2, VEX_2x16_LCD)
#pragma config(Sensor, dgtl1,  sonar,               sensorSONAR_inch)
#pragma config(Motor,  port1,           L,             tmotorServoStandard, openLoop)
#pragma config(Motor,  port2,           servo,         tmotorNormal, openLoop)
#pragma config(Motor,  port3,           drive,         tmotorNormal, openLoop)
#pragma config(Motor,  port10,          R,             tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//
/////////////////////////////////////////////////////////////////////////
//  Author  : Steven Comer
//  Program : Remote control rover with VEXnet controller
//  Notes   : Throttle is Ch 2 (right joystick)
//            Steering is Ch 4 (left joystick)
//            Headlights are Ch 5U/5D and 6U/6D (on/off)
//  Updated : 10 June 2011 @ 12:30 PM
/////////////////////////////////////////////////////////////////////////
task main ()
{
 while(true)
{
//right headlight
if(vexRT[Btn6U] == 1)
motor[R] = -127;
if(vexRT[Btn6D] == 1)
motor[R] = 0;
//left headlight
if(vexRT[Btn5U] == 1)
motor[L] = -127;
if(vexRT[Btn5D] == 1)
motor[L] = 0;
//driving
motor[servo] = vexRT[Ch4];   //steering
motor[drive] = vexRT[Ch2];   //throttle
//LCD screen
displayLCDCenteredString(0,"VEX");
displayLCDCenteredString(1,"ROBOTICS");
}
}

Written by Jesse Flot

June 9th, 2011 at 3:31 pm

Posted in Cool projects,VEX

Tagged with , ,

News Coverage on the Penn Trafford Robotics Team

without comments

The Penn Trafford Robotics Team is getting some well-deserved media attention. In just a few short years they’ve already won several local competitions and competed at a very high level at international competitions like the VEX World Championship. Keep up the great work!

And yes, they use ROBOTC. :)

Written by Jesse Flot

May 9th, 2011 at 4:01 pm

Posted in General News,VEX

Tagged with , , ,

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 , ,