ROBOTC.net Blog  

ROBOTC News

Archive for the ‘Arduino’ Category

ROBOTC 3.5: Global Vs. Local Variables and the Debugger

with one comment

This is the first in a series of posts that will explain the new functionality behind the latest ROBOTC update. Beginning with ROBOTC 3.5 with all of the new functionality towards becoming an ANSI-C compliant language has brought some changes that may confuse veteran ROBOTC users. This week we’ll take a look at how global and local variables work in ROBOTC.

In previous ROBOTC releases, the compiler (the engine that converts your code from C-language to machine language) would treat all variables as “Global Variables” and would allocate (assign memory to) every variable when the program was compiled. This method caused issues because it would not allow the compiler to understand re-entrant functions (i.e. functions that could call themselves). This functionality was limiting because it prevent a key computer science concept called “Recursion” which is the ability to have a function call itself repeatedly (but not infinitely). Recursion is very useful when dealing with sorting data or calculating a series of data in different algorithms (one example: calculating a Factorial value – 5! = 5*4*3*2*1)

Example of Recursion: Calculating a Factorial Value

In ROBOTC 3.5, the compiler’s functionality has been extended in order to support recursive functions by supporting the concept of “Call Stack” variables. The idea of the Call Stack is that ROBOTC will now store local variables and return addresses of functions onto a Call Stack – This unlocks the ability to have recursive functions and variables that are truly “local”. With the Call Stack, ROBOTC is able to keep track of multiple calls of the same function and coordinate all of the variables so there’s no accidental overwriting of data or multiple copies of the same variables to keep track of – Everything automatically done by the compiler when the program is run!

A visual look at a “Call Stack” (from Wikipedia)

With the call stack, ROBOTC’s firmware assigns the memory address of local variables when they’re declared in the code (as opposed to compile time as before). Variables are allocated and discarded on the stack as needed – users do not need to modify their code to take advantage of this functionality. Programs do still need to specify a variable’s type and size ahead of time however. (i.e. no dynamically sized arrays)

Three different ways to allocate variables.

There is one big difference when it comes to debugging – users will see the old “Variables” display is now split between “Global” and “Local” variables in the ROBOTC Debugger. Because the ROBOTC IDE doesn’t know where the variable will be stored in the “call stack”, there’s no way to accurately know where the local variables are on the stack at any one time. What this means is that you will not be able to view your local variables during run-time like in previous versions of ROBOTC. This is a limitation of professional IDEs (Visual Studio, Eclipse, AVR Studio) that also support recursion and variable stacks. The new extended ANSI-C functionality brings ROBOTC close to the same level as those development environments including the same limitations when debugging.

Hey where are all of my variables?

The good news is that users have two options for debugging their program’s variables:

  1. Suspend your program by using the “Step” button– When the program execution is suspended, the IDE is able to display all of the current local variables for the current function/task selected. This will not display every local variable in your program, but only the currently executing function/task.

    When the program is suspended, ROBOTC can load the “Call Stack” and display Local Variables accurately.

  2. Use Global Variables– Because Global Variables are allocated at compile time, the ROBOTC IDE knows the memory location of every Global Variable and can keep track of these variables in the “Global Variables” debugger window. All Global Variables will be continuously updated as the program is executed.

    With Global Variables, ROBOTC know the address of the Variable at all times, so it is able to always display the value.

We understand some of the frustration that ROBOTC users are experience with the new ROBOTC 3.5 update with all of the new functionality, and we apologize for any issues. Our overall objective is to make ROBOTC as close to a true ANSI-C programming environment to make sure students and users are learning proper coding techniques.

As we continue to refine our implementation with the latest version of ROBOTC, we still are committed to addressing any reported issues and would love to hear from you if you are having any problems – Please send us a note using our Ticketing system at http://www.robotc.net/support/ or directly at support@robotc.net.

Written by Tim Friez

October 24th, 2012 at 5:18 pm

ROBOTC 3.50 Now Available!

with 4 comments

The ROBOTC Development team is proud to announce that ROBOTC 3.50 for the LEGO Mindstorms, VEX Cortex and PIC, Arduino, and Robot Virtual World platforms is now available! The new ROBOTC 3.50 update is free-of-charge for ALL existing ROBOTC 3.0 license holders. Download today and try out all of the new features and enhancements available in ROBOTC 3.50!

Change log for ROBOTC 3.50 (since version 3.08):

MAJOR UPDATES:

  • Full ANSI-C support to support pointers, recursion, and stacks with an updated compiler and updated robot firmware.
  • New and Updated Debugger Windows:
    • “Local Variables” to monitor variables in the current task or function.
    • (Note: Local variables are only available when your program is suspended)
    • “Global Variables” to monitor variables available to your entire program.
    • “Call Stacks” to monitor function calls in the currently selected task.
  • Updated Documentation and Wiki (www.robotc.net/wiki) – Constantly Updating!
  • Support for Standard C commands – sprintf(), sscanf(), support for character arrays, unsigned variables, etc.
  • Support for the Arduino family of controllers (Uno, Mega, Mega 2560) with future support and expanded functionality for the Arduino Leonardo and Due controllers.
  • Updated Robot Virtual Worlds support to include additional sensors and motors.
  • Improved Robot Virtual Worlds performance to simulate more realistic physics and robot behaviors.
  • Support for the new MATRIX building system with the NXT.

Robot Specific Fixes:

  • NXT I2C sensors were incorrectly initializing clock and data lines as outputs when first configuration. They were correctly left as inputs after first message was sent. Change was to initialize as inputs. Before change, the first I2C message on an empty port will incorrectly appear to succeed.
  • Ignore HiTechnic Textrix Motor Controller spurious encoder counts. I.E. if encoder value read is hex ‘FF80xxxx’ then force a reread. Always accept the re-read value.
  • Eliminate Z-Axis from VEX joystick window as is unused.
  • Arduino boards now support controlling LEDs from PWM pins.
  • Arduino boards now will read zero when connecting analog to ground.

Interface Updates/Fixes:

  • Add “Show Current Program Counter” button to Debugger.
  • Add new template for “New File”. All new programs will start with a task main structure. This template can be modified by the user (it lives in  /Sample Programs/Platform/Templates)
  • Always force “Save As” for all template files. Before the files were being saved in a default directory.
  • Allow any serial port to be used with VEX PIC systems.
  • Allow user entered blank (empty) lines before first “#pragma config(” lines. Currently generates a compiler error.
  • Improve placement of related compiler generated errors to appropriate line numbers.
  • Fix bug where “Motors and Sensors Setup” did not work on empty files.
  • Properly restore floating “Debugger Panes” when Debugger is invoked.
  • Changed Checkmarks to Radio Icons for many menu items. This shows a “dot” instead of a “check mark” in the menu icon field.
  • Created tooltip strings in resource file for all missing commands.
  • Prepare to add two new Debugger panes to display “Breakpoints” and “Bookmarks”. Based on the existing “Compiler Errors” pane architecture. The new panes are displayed but the content is still empty.
  • Better synchronization of breakpoints between “Source File” and “Disassembly Listing”. Previously when breakpoint was added/removed in one window the corresponding change was not properly made in the other window. Now the breakpoint ICONs are always refreshed whenever a window is “Activated” (i.e. made topmost).
  • Add two new menu commands for “increase indent” and “decrease indent”.
  • Tweak “auto close breakpoint hit” message box implementation. Add a check mark to the dialog.
  • Add new “Compile OR Compile+Download” toolbar.
  • Debug “Task Status” window — minor enhancements.
  • FONT name was not being updated in Preferences “Font” tab correctly. Fixed.

Compiler and Command Updates/Fixes:

  • Pointer support. New functions positioning for improvements in the dereference (“*”) and address of (“&”) unary operators.
  • New “#pragma debugWindows(…)” to specify a list of Debugger Windows that should be opened.
  • Add new intrinsic function “DebugStreamClear” to allow programs on robot to clear the debug stream.
  • Support for “Implied Pointers” in functions.
  • Fixed compiler priority for binary and unary versions of ‘&’, ‘*’, ‘+’ and ‘-’ operators.
  • Support for unsigned longs.
  • Add new intrinsic function for “round”.
  • Added support for ‘atan2′.
  • Allow ‘struct’ pointers as valid function return types.
  • Fix issue in ‘struct’ declaration causing a random memory overwrite in ROBOTC IDE.
  • Support pointer variables for ‘++’ and ‘–’.
  • ‘sizeof’ operator now accepts argument types of ‘char’, ‘short’, ‘long’, ‘float’, …
  • Fix bug in evaluating “complicated” / compound constant expressions in “#if”.
  • Add support for ‘%p’ format code in ‘sprintf’.
  • Improve code generation for pointer references to ‘struct’.
  • Added doubly nested ‘->’ operator.
  • Fixed bug in unary ‘-’ VM opcode.
  • Improve code generation for structure element access.
  • Fix implementation of structure element access code generation; i.e. the “.” operator.
  • Partially re-implement “sizeof” operator for proper calculation of ‘pointer’ and ‘reference’ variables.
  • Add “drop down toolbar button” to “Compile and Download” toolbar to select “Download + Compile” or “Compile” only; vs two separate buttons.
  • Add partial support for new download “write to RAM” message. Needed for new “local variables” window.
  • Add support for new “trinary opcodes” (+, – and *) with ‘long’ operands. Previously trinary opcodes were for ‘short’ variables. Trinary opcodes are primarily used for efficient code generation for array and structure element access.
  • Added definition for new “NoOp” command.

Written by Jesse Flot

September 18th, 2012 at 5:46 pm

Announcing ROBOTC 3.5! Beta Version Available Today

with 5 comments

The ROBOTC Development team is proud to announce thatROBOTC 3.5 for the LEGO Mindstorms, VEX Cortex and PIC, Arduino, and Robot Virtual World platforms will be available on September 7th, 2012. The new ROBOTC 3.5 update will be free-of-charge for ALL existing ROBOTC 3.0 license holders. Download a Beta version (3.45) today to get a sneak peak at all of the new features and enhancements available in ROBOTC 3.5!

ROBOTC 3.5 has a number of new features and enhancements:

  • Full ANSI-C support to support pointers, recursion, and stacks with an updated compiler and updated robot firmware.
  • New and Updated Debugger Windows:
    • “Local Variables” to monitor variables in the current task or function.
      (Note: Local variables are only available when your program is suspended)
    • “Global Variables” to monitor variables available to your entire program.
    • “Call Stacks” to monitor function calls in the currently selected task.
  • Updated Documentation and Wiki (www.robotc.net/wiki) – Still in progress!
  • Support for Standard C commands – sprintf(), sscanf(), support for character arrays, unsigned variables, etc.
  • Support for the Arduino family of controllers (Uno, Mega, Mega 2560) with future support and expanded functionality for the Arduino Leonardo and Due controllers.
  • Updated Robot Virtual Worlds support to include additional sensors and motors.
  • Improved Robot Virtual Worlds performance to simulate more realistic physics and robot behaviors.
  • Support for the new MATRIX building system with the NXT.
  • Many general enhancements and bug fixes – more in-depth change log to come with the ROBOTC 3.5 official release.

Please remember that the Beta available today should not be installed across entire school sites–this is a beta version, so install at your own risk!

You can participate in the ROBOTC 3.45 Beta version by downloading a copy here. Please note that the Beta version will uninstall your existing version of ROBOTC; the Beta will use your existing licensing so there is no need to ‘Deactivate’ before installing. If you have any issues/questions with the ROBOTC Beta, please e-mail betasupport [at] robotc [dot] net for assistance and to alert us of any issues to be fixed between now and release day.

Written by Tim Friez

August 24th, 2012 at 11:24 am

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

RC Car to Arduino Robot – Cars have arrived!

without comments

The RC cars for the Arduino guided project to convert an RC car into a robot have arrived.

We tried to select cars with various features, sizes, prices, and body designs in an attempt to get a good sample of the insides of RC cars. In the end we selected the following six RC cars.


Read the rest of this entry »

Written by Jacob Palnick

June 6th, 2012 at 9:03 am

Posted in Arduino

Guided Projects with ROBOTC for Arduino

with 2 comments

Arduino

The Arduino is a powerful and versatile piece of electronics hardware, that can be used for anything from taking sensor readings or making LEDs flash, all the way to making a robot that can be controlled from the internet. With such vast potential, getting started with the Arduino can be a little intimidating to some.

As such the ROBOTC Development Team is pleased to announce the development of a series of guided projects to introduce users to the Arduino. These projects will cover topics such as making a simple mobile robot, making your own sensors, communicating with VEX or NXT robots, and how to make and use advanced sensors. The projects will all lead up to a capstone project where you will be guided through the process of converting an RC car in to a Arduino controlled mobile robot.

If you’re interested in helping out with the development of some of the lessons, feel free to contact us at arduino[at]robotc[dot]net – We’ll be offering free licenses of ROBOTC for Arduino for anyone who contributes lessons around using the Arduino with ROBOTC.

We’ll be posting all of the project materials on our ROBOTC.net Wiki – The outline for each project’s development can be found on the ROBOTC wiki at http://www.robotc.net/wiki/Arduino_Projects.

Written by Jacob Palnick

June 4th, 2012 at 10:17 am

Posted in Arduino

ROBOTC for Arduino Public BETA Released!

with 42 comments

Just in time for summer, the ROBOTC dev-team has released the first Public BETA of “ROBOTC for Arduino”. The Arduino is a cool, low-cost embedded controller board that is great for learning the basics of robotics, electronics and creative engineering.

The new version of ROBOTC has support for all of the popular official Arduino boards – Diecimila, Duemilanove, Uno, MEGA 1280 and MEGA 2560.

All of the ROBOTC features you’ve come to know and love have been brought to the Arduino, including easy motor and sensor control, the powerful ROBOTC debugger, sample program library, and many other features.

ROBOTC for Arduino

ROBOTC for the Arduino will be free for use all summer long, so visit http://www.robotc.net/download/arduino/ and start using the Arduino with ROBOTC!

IF you’re looking to purchase an Arduino, we strongly recommend you check out http://www.sparkfun.com for everything Arduino and cool accessories!

Note: The ROBOTC for Arduino 3.12 build is still compatible with the NXT and Cortex versions of ROBOTC. Your existing installations will be upgraded to 3.12, but you will be able to use the NXT, Cortex, and Arduino all in the same version of ROBOTC.

Main Documentation/Support Page:
http://www.robotc.net/wiki/ARDUINO

Installing Drivers:
http://www.robotc.net/wiki/ARDUINO_Installing_Drivers

Getting Started (Installing Firmware/Samples):
http://www.robotc.net/wiki/Tutorials/Getting_Started#Getting_Started_with_Arduino

Link to ROBOTC.net Forums for Arduino:
http://www.robotc.net/forums/viewforum.php?f=62

Written by Tim Friez

May 11th, 2012 at 4:27 pm

Announcing ROBOTC’s New Support Wiki!

without comments

Over the past few months, the ROBOTC Development team has been updating all of the ROBOTC documentation and moving it to our new ROBOTC Wiki website. This new Wiki will contain a full in-depth function reference for all ROBOTC platforms. The eventual goal is to have the Wiki be the central location for all ROBOTC documentation.

In addition, the Wiki will house documentation and instructions for a number of exciting ROBOTC projects that have been highlighted on the ROBOTC Blog over the past few years and all new projects moving forward.

We need your feedback!

The wiki will be frequently updated as we are always improving ROBOTC , so stop by http://www.robotc.net/wiki/ to take a look! If you have any suggestions or recommendations, feel free to drop us a line at support@robotc.net.

The ROBOTC team is also looking for community volunteers to help make the ROBOTC wiki a central location for all ROBOTC knowledge – if you are interested in helping out, please send us an e-mail to support@robotc.net.

Written by Tim Friez

May 11th, 2012 at 4:27 pm

Posted in Arduino,NXT,VEX