We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35
Programming the EV3 with C++ using BricxCC...
by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/
Programming the EV3 with C++ usin g BricxCC & G++ 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 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 page 1 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 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 Baums Not Quite C (NQC) language. And it supports programming the Scout, RCX2, and Spybot using The LEGO Groups 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. page 2 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 3 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 4 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 5 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 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. page 6 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 7 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 8 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-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. page 9 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 10 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ Download lms_api.zip, and extract it to the C:/BricxCC as follows, via the right-click Properties dialog. page 11 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 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 page 12 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ arm-2009q1-203-arm-none-linux-gnueabi.exe. page 13 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 14 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 15 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 16 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 17 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 18 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 19 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 20 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 21 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 3. Setting Up the Environmental Variables Edit your PATH environment variable and add the paths for CodeSourcery Lites bin folder to the front of your path. Go to \Control Panel\System and Security\System page 22 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ Select Advanced System Settings page 23 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 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. page 24 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ Start up the Bricx Command Center (BricxCC) IDE and select EV3 as the Brick Type and Linux as the Firmware type. page 25 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ page 26 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/
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 Bricks screen, navigate to the Wrench on the far-right and choose Brick Info. It should look like this (ID will vary brick to brick): page 27 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 5. Run your first C++ Program for the EV3 Begin by starting the Bricx Command Center (BricxCC) IDE. From the File Menu, select New. page 28 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ Enter or Download the following code into the Bricx Command Center (BricxCC) page 29 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-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 page 30 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 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 page 31 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 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. page 32 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ 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: page 33 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ Congratulations on your first C++ program ran successfully on your LEGO Mindstorms EV3.
page 34 / 35 Programming the EV3 with C++ using BricxCC... by Ray J. McNamara - http://www.rjmcnamara.com/lego-mindstorms-ev3/programming-ev3-c-bricxcc/ Powered by TCPDF (www.tcpdf.org) page 35 / 35