RobotC is a cross-platform C programming language specifically designed to program the acquisition of sensor data and control motors typically seen in educational robotic applications. RobotC can be used to program VEX, NXT (Lego Mindstorms) or Arduino based hardware used in popular robotic applications. RobotC comes with an Integrated Development Environment (IDE) in which code can be written, compiled and send to the appropriate hardware. The IDE also allows for real-time monitoring of (internal) variables, while RobotC itself allows round-robin scheduling of multiple programming tasks.
In our COSMOS Cluster on Engineering Design & Control of Kinetic Sculptures, students use RobotC to program the NXT (Lego MINDSTORM) environment to measure moving objects (typically marbles) and alter the dynamic behavior of their kinetic sculptures via actuators (typically servo motors) included in their design.
Although there are many other programming languages students may be more familiar with, the C language is one of the most fundamental programming languages used in engineering for "bare-metals" programming. RobotC programs developed by students are used to:
Measure sensor data and actuate servo motors.
Development of automatic control algorithms that automatically process sensor data and control servo motors.
Create dynamic movements of their kinetic sculpture.
Compare control equations created in WM2D simulations with C code used in control programs.
Create a User Interface (button and LCD screen) with the NXT environment.
RobotC and the use of the NXT environment provides the ability to the students to directly see their programming skills with a confirmation of the observed dynamic movement of their parts in a kinetic sculpture!
When you are new or just started using RobotC to program your Lego NXT Intelligent Brick in this cluster, please carefully follow these subsequent steps in order to get RobotC started on your computing environment:
Installation Step 1: Install the 4.56 (EXE) version of ROBOTC for LEGO MINDSTORMS on your local computer.
IMPORTANT NOTES:
Keep in mind that you cannot work with a virtual computer environment (e.g. CloudLabs) as programming and downloading code will require a physical USB connection between your local computer and the Lego NXT intelligent brick.
This is a Windows Application and you need a Windows computer to install this.
Any time during installation: do not plug in the Lego NXT Intelligent Brick and do not download any firmware onto the Lego NXT Intelligent Brick! The Lego NXT brick provided to you have already has firmware for the 4.56 EXE version of RobotC. Trying to download firmware onto the LEGO NXT Intelligent Brick may result in a "bricked" (none-functioning) device.
The 4.56 (EXE) version of ROBOTC for LEGO MINDSTORMS can be found at the LEGO tab at RobotC.net, so make sure you click the LEGO tab under the Download heading.
Installation Step 2: after installation of RobotC, click on the Windows Start button and type in "Device Manager" and open the Windows Device Manager. Now power on the Lego NXT Intelligent Brick and plug in the USB connection of the Lego NXT Intelligent Brick. The Windows Device Manager should update and list a "Lego Devices" item with LEGO MINDSTORM NXT listed under it. This means the Lego NXT Intelligent brick is properly recognized by your local computer. If not, you have to manually install the Lego NXT driver.
Getting Started Step 1: Become familiar with (aka please read): How to Program, Download and Run RobotC code.
Getting Started Step 2. Learn some basic Fundamentals on Programming in RobotC.
Getting Started Step 3: See some of our RobotC code examples listed below to get you started.
The examples listed below can be used as a starting point to most of the programming tasks in this Cluster. Download/save the code example files and modify them to serve your needs!
touchsensor.c - detect the press of a TouchSensor (in Version 4.x of RobotC).
movemotor.c - move a NXT LEGO motor back and forth.
motor2touch.c - move a NXT LEGO motor back and forth via a touch sensor.
motor2sonar.c - move a NXT LEGO motor back and forth via a sonar sensor.
motor2light.c - move a NXT LEGO motor back and forth via a light sensor.
motor2pos.c - move a NXT LEGO motor to a specific position using a simple check on the motor encoder position. When running the program, it shows the motor might overshoot its desired position.
motor2pospid.c - move a NXT LEGO motor to a specific position using the built-in PID controller. When running the program, it shows the motor reaches and keeps its desired position.
multitask.c - demonstrates the multitasking programming features of RobotC by moving 2 NXT LEGO motors in two separate tasks
The speed sensor programs listed below demonstrate the capabilities of the Lego NXT when interacting with the special purpose UCSD COSMOS Optical Speed Sensor that digitally measures the velocity of objects (such as balls in a Kinetic Sculpture) when passing through the optical sensor. In order to use the speed sensor programs listed below, you must first download the speedsensor.c include (driver) file and save speedsensor.c in the same folder as your other RobotC program files listed below:
speeddemo.c - initialize the UCSD COSMOS Digital Speed Sensor and subsequently poll the speed measurement from the sensor.
ballcountdemo.c - initialize the UCSD COSMOS Digital Speed Sensor and subsequently keep polling the speed measurement from the UCSD COSMOS Digital Speed Sensor in an infinite loop. Based on the speed measurements, a ball counter is updated (positive or negative). When a certain value is obtained, a servo motor is also moved.