Archive for November, 2012

Wiki Guide: How to Play Sounds Through a VEX Cortex Speaker

without comments

Back in April, we did an unboxing for the VEX Cortex Speaker which we blogged about, here.

Since then we have had many requests for an updated guide on how to play custom audio files through the Cortex Speakers. Today, the wait is finally over. We have updated our wiki pages to include an in-depth guide on how to convert a sound file into a Cortex-usable format using the open source program, Audacity [link].

Once the file is formatted and downloaded to the Cortex properly, the ‘PlaySoundFile(“filename.wav”)’ command is used to access the audio file and play it through the speaker port (example shown below).

task main()

//Play a Sound File (need to use the File Management to Upload First)


If you are interested in the Cortex Speaker and what can be played through it, check out the VEX forum post about playing Nyan Cat through the VEX Cortex speaker. As an added holiday bonus, how about the 12 Days of Christmas?

We are continually updating and improving all of our support material; if there is anything you think would make ROBOTC more accessible, don’t hesitate to comment below!

Written by John Watson

November 21st, 2012 at 1:01 pm

New Versions of RVW Curriculum and Competition Tables

with one comment

The Robot Virtual World team has a fresh round of updates available for you. We’ve listened to your feedback and have made some changes to our Curriculum Companion, Sack Attack, and Ring It Up virtual worlds. Read on for more details!

What’s new in the Curriculum Companion 2.2.4:

  • Adjusted the NXT – Obstacle Course table to more closely meet the level specifications
  • Adjusted the VEX – Robo Slalom 2 table to give more room between the lines and obstacles
  • Adjusted the Camera 2 View of the VEX – Minefield Retrieval Challenge

What’s new in VEX Sack Attack 1.5.1:

  • Resolved a bug where motor values were being overwritten

What’s new in Ring It Up 1.5.1:

  • Resolved a bug where motor values were being overwritten
  • Adjusted robot models to drive straighter
  • Adjusted sensor and encoder behavior
  • Improved the gripper-ring interaction behavior

Thanks again for the feedback, and keep it coming. You can post it to the Robot Virtual Worlds section of the ROBOTC Forums.

Written by Jesse Flot

November 19th, 2012 at 4:54 pm

FTC Ring It Up and VEX Sack Attack v1.50 Now Available!

with 2 comments

Following up from an earlier post, new versions of the FTC Ring It Up and VEX Sack Attack Virtual Worlds are now available!

In version 1.50 of Ring It Up, all arm, wrist, and gripper motors now include encoders, allowing you to get feedback and implement precise control over the robots. We’ve also swapped the Compass Sensor for the Gyroscope, which was highly requested by FTC teams. New Sample code  for the encoders and gyroscope is installed with the world.


In version 1.50 of Sack Attack, we’ve added encoders to the arm motors on all of the robots, and a potentiometer to the scooper motor on Scooperbot, giving you very precise control. All robot models have also had the Compass sensor replaced with a Gyroscope, better aligning them with the real world VEX system. As with the Ring It Up world, Sample code for all of the new functionality is included.

We genuinely appreciate all of the feedback and comments we’ve received about these worlds, and we hope that these changes show that we’re listening. Keep the feedback coming!

Adding support for all of the new inputs required a significant update of our back end, so these versions require ROBOTC 3.54 or later to be installed. Happy programming!

Written by Jesse Flot

November 5th, 2012 at 1:33 pm

Posted in NXT,Releases,VEX

Tagged with , , , ,

ROBOTC 3.54 Update Now Available!

with one comment

The ROBOTC development team is happy to announce the release of ROBOTC 3.54. This new version adds a number of new features and numerous bug fixes from user reports. Existing ROBOTC 3.xx users can download a free update from inside of the ROBOTC software (Help – Check for Updates) or from the website.

In addition to ROBOTC 3.54, the ROBOTC Development team is excited to announce support for PID with the VEX Cortex system (using motors with integrated motor encoders). The new VEX PID functionality will be available in a public BETA to be released in the very near future.

The latest update to ROBOTC also includes a number of new features for Robot Virtual Worlds. The new update includes new support many more motors, encoders and sensors. Look for an update for your favorite virtual worlds in the near future to take advantage of this great new functionality.

A summary of the major changes are below:


  • Support for MATRIX Robotics “Move to Encoder” in NXT firmware using the nMotorEncoderTarget functionality.
  • Fix TETRIX motor control. “Move to encoder position” functionality was not working correctly.
  • New functionality for I2C test program to optionally create message log traces for I2C ‘write’ and ‘read’.
  • TETRIX user defined servo names were not being properly setup by compiler. Fixed.
  • nxtDisplayRicFile intrinsic was broken. Auto downloading of files from PC was disabled. Both are fixed.
  • Xander’s 3rd Party Sensor Drivers (from are now updated and compatible with ROBOTC 3.54. The new driver are included in the NXT Sample Program’s directory.

VEX Cortex/PIC:

  • Fix bug related to ‘char *’ and ‘string’. It was introduced with fix for “playSoundFile” not working. “playSoundFile” is now working for the Cortex.

General ROBOTC:

  • Support for “Classic Mode” – This mode will disable the “variable stack” and treat all variable as “Global Variables” like ROBOTC used to before version 3.50. This setting is under “view – preferences”.
  • Enhance directories for “Sound” files. There are now three possible choices — “common files” directory, “platform specific” directory and “user specified” directory. Implemented separate “Preferences” tab for “sounds”.
  • Add new “Motors and Sensors Property Page” to configure size of “datalog” and “debug stream” buffers. Applicable to super user level only.
  • Clear highlighted execution line when “Debugger” closes. Previously the line of current execution was left highlighted.
  • Add support for “mouse wheel” with “Debug Stream Window”.
  • Add command to “compile all source files in specified directory. Add separate pane to retain the new “multi-file compilation” errors. The normal error window is erased on next compile and you’ll likely want the multi-file results to hang around.
  • Support for multiple user defined directories for compiler include files. Split “Detailed Preferences” into multiple property sheets when not menu basic and multiple tabs to display.
  • Instead of hiding command for invalid debugger pane during Emulator/Virtual Worlds, the command is shown – When opened a message box will display indicating that window is not supported under emulator/virtual worlds.

ROBOTC Compiler and Other Fixes:

  • Incorrect calculation of expression type of form <condition> ? true : false. Expression type was incorrectly calculated as a “integer type” rather than a “boolean type”. Fixed.
  • Fix type in calculating binary expression numeric type.
  • Fix incorrect calculation of expression types involving float constants. They were being set to “integer” type.
  • Changed a few intrinsic procedure parameters from ‘int’ to ‘short’.
  • Incorrect calculation of compile time constant code was resulting in unnecessary code generation for a complex, but constant value, expression.
  • “Terminate expression parsing priority” comparison was effectively  “>=” instead of “>”.  Priority was being screwed up so that expressions “A + B – C” was generating code for “A – (B + C)”
  • A few cases of “compile time constant” expressions values were not detected by compiler resulting in run-time code calculation for constant expressions. Specifically “0 / XX” is always zero regardless of ‘XX’ value. Also, constant expression of form AA = <numeric one> – <numeric two>” was generating code for run-time calculation even though could be calculated at compile time. Fixed.
  • VM opcode uses 16-bit unsigned constant. But compiler was checking if 16-bit SIGNED value was in range.
  • Incorrect compiler error message about array index out of bounds is possible when index is expression like “<constantVar> + numeric constant>”. The code for checking array bound range was only looking at “<constantVar>” and not including the <numeric constant>”. This is fixed.
  • Fixed an error that did not mark precompiled headers as invalid if the precompiled source file had any errors from the previous compile attempt.
  • Created separate Sample Program Root folders when in Virtual Worlds mode.
  • Benign. Better support for type checking “void” and “void *” expressions to eliminate incorrect compiler warnings.
  • Fix code generation for ‘string’ types. There were issues with “const string” variables having improper memory allocated. Improve code generation for assignment of “&” (address of) operator to avoid an unnecessary temporary.
  • Eliminate legacy code that re-ordered syntax tress to optimize code generation for numeric. This was not “standard C” compliant because it re-ordered the order of how expressions were evaluated. Code generation is nearly as optimal except something like “X = 5 + y +6″ will separately generate instructions to add ‘5’ and ‘6’ rather than a single add of ’11’
  • Better implementation of “type checking on string expressions”. Old implementation was occasionally generating incorrect compiler errors.
  • Add support (in emulator only) for invalid pointer calculation in “get address of parameter” opcodes. It performs a range check to ensure calculated values are in range. This is not a complete check for invalid pointers but will catch many occurrences of unassigned pointers.
  • Code generation for “large constants” (i.e. doesn’t fit in two bytes) was broken. Fixed.
  • Incorrect calculation of “assign “&’ value to variable”. Bug recently introduced with string fixes.
  • Improve code generation for ‘char string constants’.
  • Add error message when no parameter is specified for nMotorEncoder/Motor/SensorValue/etc.
  • Fix a few small issues in Licensing System for oft-used cases.
  • Add compiler error message when no “main task” is defined.
  • Add compiler error message that “&” is snot supported as part of a ‘cast’ qualifier. This is a C++ feature and not found in ANSI C.
  • Fix bug in code generation for “goto XXX;” statement. Compiler optimization may not emit the unconditional branch and code generation was not handling the case of  a NULL pointer that resulted.
  • Fix code generation problem with large constants (i.e. >16 bits) assigned to long variable. Compiler was incorrectly trying to generate code for optimized short forms (i.e. 16-bits or smaller parm index).
  • “Events” no long work. Delete the sample program that illustrates them.
  • Incorrect calculation of operator parsing priority for “&” (address of unary op) which should be ‘3’. Instead it was using the priority for ‘&’ (bit and) which is priority ’10’.
  • Fix incorrect code generation when assigning ‘float’ expressions to ‘int’ (char, short or long) variables.
  • Fix compiler code generation for expressions using pointer subtraction — “<pointer> – <pointer”. also fix “<pointer> – <number>”
  • Fixing an issue when a license is in the “clock rolled back” state and needs to be reset using a 30-day reset key – previously was not updating the “clock rolled back” state.
  • Compiler does not handle ‘const string kConfigName = “FTCConfig.txt”;’ properly. Changed to ‘string kConfigName = “FTCConfig.txt”;’.
  • Fix recent bug where “*” in declaration of type “typedef OBJ *POBJ” was being discarded. Extend typedef parsing to support declaration like “typedef unsigned char ubyte, *PUbyte”; i.e. change single declaration to a comma separated list.
  • Debugger window for NXT Remote Screen in emulator was not properly recognizing the remote buttons. The message sent to emulator should have been a mask of buttons and instead was a index of a single button. Fixed.
  • NULL char in middle of char string constant — e.g. “abc\0def” — resulted in incorrect storage by compiler into constant pool. Only the chars up to the NULL were being stored. Fixed.
  • Char arrays whose array dimensions were initialized with empty bounds were incorrectly assigned one byte too large. The trailing NULL on the end of the char string constant was being included in the array dimension.
  • Token scanner was not properly handling ‘\ddd’ special chars where ‘d’ is octal digit. This is now fixed and the standardized format for hex digits of ‘\xhh’ is also accepted.
  • Complete implementation of new registry toggle to optionally automatically close start page on first user compiler. Also added as a command to the menu “View -> Preferences -> Close Start Page on First Compile”.
  • Compiler was not parsing postfix “++” and “–” properly when they followed an expression. It worked fine on expressions with simple variables — “structVar.NN++” or “pStructVar->NN++” but didn’t work for more complicated expressions like “((TStruct *) &strucVar)->NN++”. It now handles the complicated expressions.
  • Fix incorrect calculation of “useless expressions” for binary opcodes. Compiler detects ‘useless’ expressions and does not generate code for these. It was incorrectly flagging binary “+”, “-“, … operations as useless which is incorrect if one of the parameters has side effects like being a procedure call or an expression like “++” or an expression containing a “=” operator.
  • Compiler crash when “++” or “==” were to expressions that didn’t immediately resolve to a symbol. e.g. “++((&g_obj)->n2);”.
  • Fix code generation for expression like “(&OBJ)->n1″. Was throwing compiler error and generating incorrect code.
  • Clear Debugger “Local Variables” pane when user program is finished or executing (vs suspended). When executing, don’t know which local variables (on stack) are valid.
  • Expanded declaration support for statements like “int A, * B, *C, D;” where A and D are “int” and B and C are “int *”
  • Signed / Unsigned type fixes for pointer variables. Allow “const string” procedure parameters to be matched by char constants (e.g. “ABC”).
  • Fix issue with compiler indicating reference variables are only “read” but not “written”.
  • Compiler was incorrectly assigning the ‘signed’ type of pointer variables to “unsigned” (i.e. the signed value of a pointer) rather than the desired type. Formatting routine for this was also broken.
  • Ignore “find best procedure fit” parameter array checking when “void *”. “Void *” will match any pointer regardless of arrays.
  • Improved calculation of expression result types for binary opcodes.
  • Intermediate expressions were always converted to ‘signed’. Now if both operands (e.g. A + B” are unsigned then the expression result is also unsigned.
  • Calculating best fit procedure was not checking array bounds of parameters for matching indices when the parameter was a pointer variable and an array variable. Fixed.
  • “cast” operator now preserves signed type of typedefs that it references. Previously this information was lost.
  • ‘signed’ and ‘unsigned’ now work properly when used in a “cast”.
  • ‘char strings’ when used as arguments to ‘sprintf’ were broken. Fixed.
  • Eliminate some overly aggressive warning messages about mixed expressions of numeric and ‘enums’. Standard C does not perform this level of checking and allows much more liberal mixed mode without warnings/errors.
  • Better support for arrays. Allow variable to be declared with arrays that is based on a typedef that also specifies arrays. Previously arrays could only be declared in one “item”. Array bounds were not checked for integrity (i.e. the bounds match) when validating procedure parameters and calculating best fit procedure when multiple procedure overloads.
  • Improved generation of “&” (address of) code.
  • Improved type checking to allow equivalent but differently declared operand types to match. Previously had to be exact match.
  • Generate compiler error for ‘&’ operator applied to a “property” (motor, servo, encoder, sensor) variable.
  • Generate compiler error for ‘&’ operator applied to a numeric constant.
  • Fix code generation for expressions like “char *ptr2 = buffer;” where ‘buffer’ is a implied pointer (e.g. a array of char). Previously code generation was assigning the contents of the first element of the array to “ptr2″ rather than the address of “buffer”.
  • If the previous line triggered an “indent” — like a “if (xxx)” or “else” statement then next line was auto indented and when “{” is entered want to “undent” the auto indent. Add check for this case.
  • Minor bug in calculation constant expression with unary ‘-‘ with a constant numeric parm. Fixed.
  • Code optimization for conditional branches with trinary opcodes where the trinary condition is a compile time constant.

Written by Tim Friez

November 3rd, 2012 at 2:15 pm