# ROBOTC.net Blog

ROBOTC News

## Binary Calculator

Big thanks to DRV47 for posting this!

Have you ever sat and wondered, “Man.. I would love to be able to have a robot that could read a string of lego bricks that I put in a row and tell me the binary representation for it… and maybe even add or subtrack the numbers. Hmm…”

### WELL YOU’RE IN LUCK!

DRV47  has built this robot for you. The robot uses an NXT and is built using a single NXT 2.0 kit that you can get off the shelf from local stores nowadays.

They programmed in, of course, ROBOTC.

Take a look at the photos below:

The Binary Calculator

LEGO Bricks in a row used to represent binary numbers

Top view of the Binary Calculator

### How it works

First of all, to understand how the robot works, you have to know what binary numbers are.

A binary number is written using only two different digits (0, 1) whereas the decimal system uses ten (0 to 9).

To see how it is written, let’s take an example: 10010110 (which in fact is 150 in decimal).

Every digit represents a power of two. The first digit from the right is multiplied by 2^0, the second is multiplied by 2^1 and so on.

Thus, this number is equals to: 1*2^7 + 0*2^6 + 0*2^5 + 1*2^4 + 0*2^3 + 1*2^2 + 1*2^1 + 0*2^0 = 128 + 16 + 4 + 2 = 150 (this also equals 1 * 10^2 + 5 * 10^1 + 0 * 10^0)

Here, we will use an 8 bit number which uses up to 8 digits. The biggest number will be 255 (11111111 in binary) and the smallest will be 0 (00000000 in binary).

To represent the number and operations (which will be ADD, SUBTRACT, MULTIPLY and DIVIDE), we will use a color code which is as follows:

• RED = 1
• BLUE = 0
• BLUE = SUBTRACT
• YELLOW = MULTIPLY
• WHITE = DIVIDE

The LEGO Color sensor will read the colors and convert them to numbers or operations after the user inputs numbers and operator as follows:

Explanation of bit count and Operations

By default, the Color Sensor will read 0 and if there is no operation it will show “None” and end the program. The NXT screen will show information such as the read number (first in decimal, then in binary) and the total (first in decimal, then in binary). It will also show what it is reading. Please note that the Total can exceed 255 and can be less that 0.

This is a video showing the robot in action:

You can download the LDD file here (.7z) or here (.zip) and the RobotC source-code here. I have broken the robot into several groups within the LDD file, it should be fairly trivial to reassemble it using the pictures.

All comments are welcome and if you wish to contact DRV47, you can send him an e-mail at duvit47@gmail.com.

Written by Vu Nguyen

November 17th, 2010 at 9:58 am

Posted in Cool projects,NXT

## ROBOTC for Arduino – Looking for Alpha Testers!

Hey ROBOTC Community!

We’re currently looking for Alpha Testers to help us work out the kinks in our new ROBOTC for Arduino software.

In order to sign up, we ask if you can spend 5 minutes giving us some information about what kind of Arduinos you have and what your background is. Sometime in the next week, we’ll send out an e-mail to everyone who we’re inviting into our Alpha trials to let them know they made it.

Every person who participates in the Alpha will receive a free copy of ROBOTC for Arduino once it is released.

http://www.surveymonkey.com/s/ROBOTCArduino

Written by Tim Friez

November 15th, 2010 at 5:08 pm

Posted in Arduino,General News

Tagged with ,

## Controlling Pneumatic Actuators in ROBOTC

Pneumatic Actuators translate the force of compressed air into fast and powerful motion. In the VEX Robotics System, all pneumatic actuators create linear (in-and-out) motion, although rotary actuators do exist. The compressed air that powers the actuators is stored in a reservoir tank; differences in air pressure between the actuators and tank cause the actuators to move in and out.

The flow of air between the tank and the actuators (directly related to the differences in air pressure)  is controlled by a small switch, called an electromagnetic solenoid, which connects to the VEX PIC or Cortex using a standard 3-pin wire. It’s a common misconception that, since the solenoid enables motion, its 3-pin wire should plug into one of the MOTOR ports on the microcontroller. Actually, a solenoid is what’s considered a “Digital Output”, and should be plugged into one of the DIGITAL ports on the Cortex, or ANALOG/DIGITAL ports on the PIC.

To configure the solenoid in ROBOTC, go to the Motors and Sensors Setup menu, and select “Digital Out” as the sensor type.

Then, in ROBOTC, when you want to activate the pneumatic actuator controlled by the solenoid, you set its value equal to “1”. To deactivate it, set its value equal to “0”. In the sample code below, the remote control buttons are used to activate and deactivate the pneumatic actuator.

#pragma config(Sensor, dgtl7,  solenoid,            sensorDigitalOut)
//*!!Code automatically generated by ‘ROBOTC’ configuration wizard               !!*//

{
while(true)                   // Loop Forever
{
if(vexRT[Btn6U] == 1)           // If button 6U (upper right shoulder button) is pressed:
{
SensorValue[solenoid] = 1;  // …activate the solenoid.
}
else // If button 6U (upper right shoulder button) is  NOT pressed:
{
SensorValue[solenoid] = 0;  // ..deactivate the solenoid.
}
}
}

For more information on using pneumatic actuators, check out our Pneumatics lesson from the VEX 2.0 Curriculum.

Written by Jesse Flot

November 11th, 2010 at 4:12 pm

## Released: 3rd Party ROBOTC Driver Suite V1.7

A new release of the Driver Suite has been uploaded to Source Forge.
Changes:

• Added Dexter Industries GPS driver + test program
• Added new "driver" with statistical functions
• Changed HTGYROstartCal in HTGYRO-driver.h to do more sampling for calibration data
• HTRCXreadResp in HTRCX-driver.h now clears all of the response buffer
• Made all calls in TMR-driver.h more robust when used in multiple threads.  No guarantee that this works.

Thank you’s:

• Mindsensors for giving me one of their Numeric Keypad sensors
• HiTechnic for giving me an Angle sensor
• Dexter Industries for giving me a GPS sensor

Written by Xander Soldaat

November 11th, 2010 at 9:58 am

Posted in General News

Tagged with ,

## Traversing a Grand Challenge with the VEX Cortex

The Grand Challenge is a staff designed course which is not revealed to participants until the day of the competition. Before the competition, participants are provided with a list of conditions and situations to prepare their robots for.

On the day of the competition, the participant’s programming knowledge and preparation are put to the test as they work to traverse the course in a limited amount of time. The robot that makes the most progress without stalling out or deviating from the course wins!

In this iteration of the Grand Challenge, the Cortex-based robot must:

• Navigate an obstructed path using feedback from the Shaft Encoders and Ultrasonic Rangefinder
• Track an incomplete line up and down a ramp using feedback from the Line Tracking sensors
• (Optional) Pick up the yellow ball and take it to the finish zone for extra points
• Respond to remote-control commands only in the final zone
• Avoid hitting obstacles in it’s path, walls on the field, and falling from the ramp

Check out this cool video of the robot completing the course.

To accomplish it’s task, the Cortex-based robot is equipped with:

• Two driving motors, each with a Shaft Encoder
• An Omni-wheel acting as a rear-caster wheel
• Three Line Tracking Sensors
• An Ultrasonic Rangefinder
• Remote Control over VEXnet

Instructions for building this robot can be found here.

If you’d like ideas for creating your own Grand Challenge, check out this document for some inspiration.

Note: All materials are part of the VEX Cortex Video Trainer. Check it Out!

Written by Jesse Flot

November 3rd, 2010 at 10:40 am

## BEST Competition Programming Templates

Hey all BEST Teams!

We’ve made a new library and sample program to help BEST teams up and running with using ROBOTC with their Cortex systems. This new template makes it really easy to customize your program for your robot without having to worry about loops, conditionals and variables too much. Here’s an example of some of the new functions.

• Use this function to create a “arcade” (1 joystick) drive program. Pass 4 pieces of data to have the function do all the work for driving your robot.
• 1st: MoveChannel – The joystick channel for forward and reverse.
• 2nd: RotateChannel – The channel on the rotate port that controls left and right rotation. This value is mixed with the move channel.
• 3rd:  leftMotor – The motor on the left side of the robot.
• 4th:  rightMotor – The motor on the right side of the robot.
• TankTwoWheelDrive(vexJSLeftV, vexJSRightV, left, right);
• Use this function to create a “tank” (2 joystick) drive program. Pass 4 pieces of data to have the function do all the work for driving your robot.
• 1st: MoveChannel – The joystick channel for “left” motor.
• 2nd: RotateChannel – The joystick channel for “right” motor.
• 3rd:  leftMotor – The motor on the left side of the robot.
• 4th:  rightMotor – The motor on the right side of the robot.
• MotorControlViaDigitalButtons(Btn7D, Btn7U, leftArm, -127,  +127,  0);
• Use this function to control a motor via two digital buttons – Very customizable!
• 1st:  Btn7D – The joystick button that controls speed decrease
• 2nd: Btn7U – The joystick button that controls speed increase
• 3rd: leftArm – The motor that is being controlled
• 4th: -127 – The lowest value for the motor speed
• 5th: +127 – The highest value for the motor speed
• 6th: 0 – How fast to adjust the speed. 0 — fastest. 50 — 1.25 seconds to cover the compete range.

Written by Tim Friez

October 20th, 2010 at 2:37 pm

Posted in Cortex,PIC,VEX

Tagged with , , ,

## ROBOTC for CORTEX & PIC 2.30 Available

The Robotics Academy is happy to announce the release of ROBOTC for Cortex and PIC 2.30. The Robotics Academy has done incredible amounts of testing and modifying to make the user’s experience with Cortex as seamless as possible. Numerous improvements have been made to the communication system from your computer to the Cortex over the direct USB link – Downloads are faster and more reliable. Upgrade your version of ROBOTC today!

For the really curious, here’s the changelog:

Major Fixes:

1. Now uses Master Firmware 2.6 and lots of improvements to significantly improve communication when downloading Firmware/User Programs. Users will have to upgrade Master Firmware and ROBOTC firmware before using Version 2.30.
2. New ROBOTC Live Start Page – Based off of the ROBOTC.net Blog Feed.
3. VEX Cortex firmware now includes “Cortex Default Code” behavior when initially downloaded. Sending a new program to the Cortex will erase this default code. Users can restore default code by reinstalling ROBOTC firmware or loading the program from the “Default Code” sample program folder.

Minor Fixes:

1. No more silent failure when trying to download via serial cable and no response. Also enabled the new “Query1″ command that works with Game Controller and prints useful diagnostic information — it’s where the “silent” failure is caught.
2. When “USB Wired Cable #1″ is selected in “Preferences -> Platform” blanks were being displayed. This has been corrected.
3. Fix VEX PIC “autonomous” variable so that it reports the correct value. This fixes the PIC competition template.
4. Legacy 75 MHz transmitters on VEX Cortex values for Ch 5 and 6 were reversed. This has been fixed.
5. Fix some broken direct references to values rather than use of function call to calculate flash file system size and max number of files in flash.
6. Correct definition of VEX firmware files — they were missing trailing “.BIN”. “Download last firmware file” menu command enhanced to show “NONE” if no firmware file has been previously downloaded and command is disabled. Improve error message when failed to load from disk a firmware file — message is now more explicit.

Written by Vu Nguyen

October 15th, 2010 at 10:17 am

Posted in Cortex,VEX

## ROBOTC for Mindstorms 2.26 BETA Available

### We’ve just released ROBOTC for Mindstorms 2.26 BETA. Download it now!

This version fixes a few issues we’ve found and applies to both the NXT and TETRIX/FTC platforms. If you are using this version for FTC, please install this version.

Changelog:

1. Added Xander’s driver library (version 1.6)
2. Fixed ROBOTC behavior not to automatically disabled TETRIX motors in a low-voltage situation.
3. Fixed incorrect “SizeOf” function.
4. Disabled Bluetooth Debugging information in the “Debug Stream” Window.
5. Fixed issue with “Registering” when doing a manual activation with ROBOTC.

Written by Vu Nguyen

October 4th, 2010 at 5:24 pm

Posted in NXT,Releases

## Introducing the VEX Cortex Video Trainer!

The Robotics Academy Team is proud to present a beta preview of the VEX Cortex Video Trainer. This multimedia-rich curriculum features lessons for the VEX Cortex Microcontroller, which can also be applied to the older VEX PIC Microcontroller 0.5. It includes in-depth programming lessons for ROBOTC, multi-faceted engineering challenges, step-by-step videos, robotics support material, educational resources, and more. Whether you’re just looking for help getting started with the VEX Cortex and ROBOTC, or are planning on integrating it into the classroom, we’re confident that the video trainer will be an invaluable tool for you.

Keep in mind that the video trainer is still in development; your feedback is welcome and appreciated as we continue to add to this exciting product. Please send all questions and feedback to jbflot@cmu.edu

Written by Jesse Flot

September 27th, 2010 at 5:12 pm

Posted in Cortex,General News,VEX

## Rotacaster Minifig Vomit Mobile

Credit goes to the one and only Xander

[Source: http://mightor.wordpress.com/2010/09/22/rotacaster-minifig-vomit-mobile/]

The “Minifig Vomit Mobile” is what my friend Marc-Andre called the omniwheel I took the video of.  I felt that in order for that name to be more accurate, I had to add a minifig to the robot, so here he is, on the left.  Unfortunately, this one has no internal organs, being a skeleton and all, so there is, in fact, no stomach to vomit from.

There seems to be a common misconception that the code for this robot would very complex.  However, that’s not the case;  it’s actually surprisingly simple.  You can download the ROBOTC code right here: [LINK] and take a look for yourself.  I am not sure how you would make it work with NXT-G 2.0, seeing as there is no updated sin/cos blocks that work with floats, but it should be trivial to port to NXC.

Video: