Getting started

Getting started with LEGO Mindstorms programming with LMS.

First, lets explain things. LMS is the VM scripting language that is powering the programs that run on the EV3 Brick as installed by the manufacturer. The programs that run on the Brick, such as Brick Program or Port View, are written in LMS.

So to run programs written in LMS you don’t need to install a new firmware to your machine.

LMS files that have been assembled turn into RBF files. Robot Byte code File.

RBF files can be transferred to the Brick using the memory browser in LabVIEW. With the memory browser you can also transfer graphics and sound to the Brick, and files from the Brick to your PC if you for example generate a Log file that you wish to read.

To create an LMS file you simply use your favourite text editor. To create an RBF file from an LMS file you need to use an assembler. Luckily enough LEGO have made their assembler free to download from GitHub. You can download the full repository from here: https://github.com/mindboards/ev3sources/archive/master.zip

After downloading that you need to copy bytecodes.c and bytecodes.h from the folder lms2012/lms2012/source/ into the folder lms2012/lmssrc/adk/lmsasm/

Now you have all the files you need to compile in the folder lms2012/lmssrc/adk/lmsasm/ and you should be able to start the assembler.

To try the assembler you can create a simple Hello World app. Paste this into a file called helloworld.lms (one word, so no hyphens or fancy characters in the filename. Except for the extension of course)

vmthread MAIN
{
    UI_DRAW(FILLWINDOW,0x00,0,0)               // Clear screen
    UI_DRAW(TEXT,FG_COLOR,10,50,'hello world') // Write "hello world" at 10,50 (X,Y)
    UI_DRAW(UPDATE)                            // Show the stuff
    UI_BUTTON(WAIT_FOR_PRESS)                  // Wait for button press
}

When you have your first Hello World LMS script you can run the compiler like so:

java -jar assembler.jar helloworld

(You cannot have the extension as parameter to the assembler)

That will generate a helloworld.rbf file that you can transfer to the Brick using the memory browser in LabVIEW.

When then RBF file have been transferred you simply use the controls on the Brick to open the file browser, navigate to where you put your RBF file and press the Open button on the Brick and your Hello World program will start.

It is as simple as that!

Leave a Reply