LegoMindstormsRobots.com

Programming the EV3 with C++ using BricxCC & G++

GD Star Rating
loading...

Overview

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

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:

  1. Install the Bricx Command Center (BricxCC) IDE
  2. Install the Sourcery G++ LiteToolchains for the EV3
  3. Setting Up the Environmental Variables
  4. Update the EV3′s Firmware with the BricxCC IDE
  5. 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.

BricxCC IDE Install Step 1

BricxCC IDE Install Step 2

BricxCC IDE Install Step 3

BricxCC IDE Install Step 4

BricxCC IDE Install Step 4b

BricxCC IDE Install Step 4c

BricxCC IDE Install Step 4d

BricxCC IDE Install Step 5

BricxCC IDE Install Step 6

BricxCC IDE Install Step 7

Point your web browser to http://bricxcc.sourceforge.net/test_releases/ and pick the zip with the most recent date in the filename.

   http://bricxcc.sourceforge.net/test_releases/test_release2013NNNN.zip

Extract the ZIP Archive into the existing BricxCC install folder (directory): C:\BricxCC.

Extract BricxCC ZIP Archive Step 1

Extract BricxCC ZIP Archive Step 2

Extract BricxCC ZIP Archive Step 3

Extract BricxCC ZIP Archive Step 4

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.

Extract Linux Tools Step 1

Extract Linux Tools Step 2

Extract Linux Tools Step 3

Download lms_api.zip, and extract it to the C:/BricxCC as follows, via the right-click Properties dialog.

Extract LMS API Step 1

Extract LMS API Step 1

Extract LMS API Step 1

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.

G++ Install Step 1

G++ Install Step 2

G++ Install Step 3

G++ Install Step 4

G++ Install Step 5

G++ Install Step 6

G++ Install Step 7

G++ Install Step 8

G++ Install Step 9

G++ Install Step 10

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
System

Select Advanced System Settings
System

Select Environmental Variables
System

Select Edit “Path”
System

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.

EV3 firmware Update Step 1

EV3 firmware Update Step 2

EV3 firmware Update Step 3

EV3 firmware Update Step 4

EV3 firmware Update Step 5   EV3 firmware Update Step 6

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):

EV3 Screen

EV3 firmware Update Step 4

5. Run your first C++ Program for the EV3

Begin by starting the Bricx Command Center (BricxCC) IDE.

From the File Menu, select New.

BricxCC Program Step 1

Enter or Download the following code into the Bricx Command Center (BricxCC)

BricxCC Program Step 2

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

BricxCC Program Step 3

In the white box that appears, right click and choose add

BricxCC Program Step 4a

Navigate to the “API” folder (C:\BricxCC\API) where you unzipped lms_api.zip to.

BricxCC Program Step 4b

Select the files named ev3_lcd.c, ev3_timer.c, and ev3_command.c. and close the Project Manager

BricxCC Program Step 5

Now we need to open test.prj as below

BricxCC Program Step 6

Edit the test.prj file and add C:\BricxCC\API\ to the front of each line and then save the file.

BricxCC Program Step 7

Now lets compile the program by selecting Compile -> Compile from the menu.

BricxCC Program Step 8

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:

BricxCC Program Step 9

Congratulations on your first C++ program ran successfully on your LEGO® Mindstorms EV3….

 

GD Star Rating
loading...
GD Star Rating
loading...
Programming the EV3 with C++ using BricxCC & G++, 7.7 out of 10 based on 6 ratings

Tags: , , , , , , , , , , , ,

“… you just can't differentiate between a robot and the very best of humans.” ― Isaac Asimov, I, Robot