Programming the EV3 with C++ using BricxCC & G++
a WordPress rating system
Bricx Command Center (BricxCC) is a Windows program commonly known as an integrated development environment (IDE) for programming LEGO MINDSTORMS robots from all generations of the MINDSTORMS family, including the third generation EV3. BricxCC runs and fully supports all versions of Windows, including 64-bit Windows 7 and 8, along with server versions of Windows OSes.
BricxCC includes support for programming the LEGO Mindstorms NXT brick using Not eXactly C (NXC), Next Byte Codes (NBC), and a simple on-brick programming language called NPG using the NBC compiler. You can also create RIC graphic icon files using the RICScript programming language. Support in BricxCC for programming the NXT in Java using the leJOS alternate firmware is also coming soon in 2013.
BricxCC supports programming the RCX (all versions), Scout, Cybermaster, and Spybot programmable bricks using Dave Baum’s Not Quite C (NQC) language. And it supports programming the Scout, RCX2, and Spybot using The LEGO Group’s MindScript(tm) and LASM(tm) languages via the Mindstorms 2.5 SDK. It also supports programming RCX bricks in Forth, C, C++, Pascal, and Java using cygwin along with the pbForth, brickOS, and leJOS alternate firmwares.
Now for the Installation Guide
We will be following these steps to set up Bricx Command Center (BricxCC) IDE and the Sourcery G++ Lite Toolchains for ARM GNU/Linux:
- Install the Bricx Command Center (BricxCC) IDE
- Install the Sourcery G++ LiteToolchains for the EV3
- Setting Up the Environmental Variables
- Update the EV3’s Firmware with the BricxCC IDE
- Run your first C++ Program for the EV3
1. Install the Bricx Command Center (BricxCC) IDE
Download Bricx Command Center (BricxCC) with support for EV3. This now includes the ability to download the compiled binaries over USB to /media/card on your EV3. It also includes the ability to control motors, play tones, set/read the brick name, show battery level, and more. Not yet functional: Watch window, clear memory, and message tools. The RGF Image Editor is included in BricxCC now.
Begin the installation of BricxCC IDE by running bricxcc_setup_33810_20130220.exe.
Point your web browser to http://bricxcc.sourceforge.net/test_releases/ and pick the zip with the most recent date in the filename.
Extract the ZIP Archive into the existing BricxCC install folder (directory): C:\BricxCC.
Locate the linux_tools.zip that in the BricxCC Folder, C:\BricxCC\linux_tools and extract the zip as follows, via the right-click Properties dialog.
Download lms_api.zip, and extract it to the C:/BricxCC as follows, via the right-click Properties dialog.
2. Installation of the Sourcery G++ LiteToolchains for the EV3
Download Sourcery G++ Lite from CodeSourcery: arm-2009q1-203-arm-none-linux-gnueabi.exe
Begin the installation of G++ Lite Toolchain for ARM GNU/Linux by running arm-2009q1-203-arm-none-linux-gnueabi.exe.
3. Setting Up the Environmental Variables
Edit your PATH environment variable and add the paths for CodeSourcery Lite’s bin folder to the front of your path.
Go to \Control Panel\System and Security\System
Select Advanced System Settings
Select Environmental Variables
Select Edit “Path”
Add C:\CSLite\bin;C:\BricxCC;C:\BricxCC\linux_tools; at the front of the “Variable Value” line.
4. Update the EV3’s firmware to latest version
Download the latest version of the LMS Firmware from the LEGO Mindstorms Website.
IMPORTANT: Ensure that your EV3 has Fresh or Fully-Charged Batteries before attempting a Firmware Update!
Connect the EV3 Brick to your PC via a USB Cable.
Start up the Bricx Command Center (BricxCC) IDE and select EV3 as the “Brick Type” and “Linux” as the Firmware type.
The whole process of Downloading the Firmware to the EV3 takes around 5 Minutes. At the completion of the download the EV3 will Reset.
On the EV3 Brick’s screen, navigate to the Wrench on the far-right and choose Brick Info. It should look like this (ID will vary brick to brick):
5. Run your first C++ Program for the EV3
Begin by starting the Bricx Command Center (BricxCC) IDE.
From the File Menu, select New.
Enter or Download the following code into the Bricx Command Center (BricxCC)
Now from the File Menu, select Save and use test.c as the program name an save it to C:\Code.
From the View Menu select Project Manager
In the white box that appears, right click and choose add…
Navigate to the “API” folder (C:\BricxCC\API) where you unzipped lms_api.zip to.
Select the files named ev3_lcd.c, ev3_timer.c, and ev3_command.c. and close the Project Manager
Now we need to open test.prj as below
Edit the test.prj file and add C:\BricxCC\API\ to the front of each line and then save the file.
Now lets compile the program by selecting Compile -> Compile from the menu.
If you get an error, press F12 to see the compiler output window.
Common errors: “make: *** No rule to make target `ev3_lcd.o’, needed by `all’. Stop.”
Solution: Go back and check that the test.prj file appears as above.
Now select Compile -> Download and Run. If there are no errors, the EV3 screen should display:
Congratulations on your first C++ program ran successfully on your LEGO® Mindstorms EV3….
a WordPress rating system
a WordPress rating system