linux:legomindstorms
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
linux:legomindstorms [2013/12/30 16:56] – rlunaro | linux:legomindstorms [2014/01/07 23:46] – rlunaro | ||
---|---|---|---|
Line 6: | Line 6: | ||
{{ : | {{ : | ||
+ | |||
+ | I suppose that if you come to this page you are somewhat familiar with Lego Mindstorms, however, I will describe some of the main elements of the kit: | ||
+ | |||
+ | * The RCX is the " | ||
+ | * A device that you can connect to the computer via an RS232. I call in this document "the black box" because of this color. | ||
+ | * Motors, sensors, etc. The usual robot stuff. | ||
===== Options to have it work under Linux ===== | ===== Options to have it work under Linux ===== | ||
Line 13: | Line 19: | ||
- Use of [[http:// | - Use of [[http:// | ||
- Use of [[http:// | - Use of [[http:// | ||
- | - Use a VirtualBox Windows Machine and run the original software. This option has the advantage that the less problematic. Specially with the RS232, as you will see soon. | ||
- | - Use of Not Quite C, but in a Windows virtual machine. | ||
- | - Use of Lejos, but in a Windows virtual machine. | ||
- | ===== What??? No RS232??? ===== | + | Of course, there are other options, but I won't discuss here. |
- | Yes, my computer doesn' | + | ===== RS232 Communication in the XXI Century ===== |
- | [[http:// | + | Modern computers doesn' |
+ | [[http:// | ||
- | **The problem is** that this cable comes with a fantastic driver.... for Windows and Mac. | + | ==== Checking |
- | + | ||
- | {{ : | + | |
- | + | ||
- | So, the working of this solution depends greatly with the hability or good work of the Ubuntu and Linux engineers. | + | |
- | ===== Before Everything ===== | + | One step is to check that it works properly under linux. Here are the basic steps: |
- | Don't plug the USB-RS232 | + | Don't plug the USB-RS232 |
<code shell> | <code shell> | ||
Line 49: | Line 49: | ||
</ | </ | ||
- | This **'' | + | This **'' |
- | ===== First Attempt: | + | ===== Not Quite C ===== |
This is my first attempt and my first try to make the USB-RS232 adaptor to work. I know that Java doesn' | This is my first attempt and my first try to make the USB-RS232 adaptor to work. I know that Java doesn' | ||
- | __You can find documentation about NQC here: [[http:// | + | ==== Documentation ==== |
+ | |||
+ | NQC is a programming language by itself, don't take it slightly. | ||
==== Hands on ==== | ==== Hands on ==== | ||
- | You can install | + | You can install |
<code shell> | <code shell> | ||
- | > sudo apt-get install nqc | + | $ sudo apt-get install nqc |
</ | </ | ||
- | You can make a hello world to make sure that the USB-RS232 is working properly. | + | My first step will be to reach the RS232 adapter correctly and reach the black box. So, connect |
- | + | ||
- | **First**, connect | + | |
{{ : | {{ : | ||
- | **Next**, turn on the RCX and point it to the black unit, so both can see each other. Remember that the connection is via infrared. | + | **Optionally**, you can turn on the RCX and point it to the black unit, so both can see each other. Remember that the connection is via infrared. |
- | **Next**, | + | Now run the following code: |
<code shell> | <code shell> | ||
Line 80: | Line 80: | ||
</ | </ | ||
- | When running it, I've observed no error messages and no '' | + | When running it, I've observed no error messages and no '' |
+ | |||
+ | |||
+ | {{ : | ||
**Other commands to test proper running** | **Other commands to test proper running** | ||
- | I've run this command: | + | You can try other commands that doesn't require to have a program like this: |
<code shell> | <code shell> | ||
Line 91: | Line 95: | ||
</ | </ | ||
- | So I'm afraid further investigation is needed. | + | ==== Install the firmware in the RCX (the yellow box) ==== |
- | **Last try** | + | The next step is installing the firmware in the RCX. There are various firmwares out there, but for NQC we need the official firmware from LEGO. |
- | I've attached a motor to the " | ||
- | {{ : | ||
- | And this is my first program: | + | ===Where is the firmware??? |
- | + | ||
- | <code nqc> | + | |
- | task main() | + | |
- | { | + | |
- | OnFwd( OUT_C ); | + | |
- | Wait( 400 ); | + | |
- | OnRev( OUT_C ); | + | |
- | Wait( 400 ); | + | |
- | Off( OUT_C ); | + | |
- | + | ||
- | } | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | When I try to run it, I get the following error: | + | |
- | + | ||
- | <code shell> | + | |
- | $ nqc -S/ | + | |
- | No firmware installed on RCX | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | So, I definitely think that the RCX is completely blank, and I have to install some sort of firmware to have it properly working. | + | |
- | + | ||
- | ====Where is the firmware???==== | + | |
Check out the box of mindstorm: it should be a CD which contains the firmware. To get the firmware from the CD, you should face the following scenarios: | Check out the box of mindstorm: it should be a CD which contains the firmware. To get the firmware from the CD, you should face the following scenarios: | ||
Line 132: | Line 109: | ||
- The firmware file is not in the cd, but it is in one of the *cab files. In that case, you can find instruction in this page: | - The firmware file is not in the cd, but it is in one of the *cab files. In that case, you can find instruction in this page: | ||
- | ==== Downloading the firmware | + | === Downloading the firmware === |
- | In the argot, placing | + | Placing |
Run the following command: | Run the following command: | ||
Line 147: | Line 124: | ||
{{ : | {{ : | ||
- | and a green diode lighting in the black box: | + | and a green diode lighting in the black box (it's not easy to see it): |
- | INSERT PICTURE HERE | + | {{ : |
After the process is finished, the LCD screen of the RCX should show a 0000 message, and a sound is reproduced: | After the process is finished, the LCD screen of the RCX should show a 0000 message, and a sound is reproduced: | ||
- | INSERT PICTURE HERE | + | {{ : |
The installation of the firmware will be there until the batteries are removed. | The installation of the firmware will be there until the batteries are removed. | ||
Line 165: | Line 142: | ||
Will have the effect that in the RCX the program number 2 is selected: | Will have the effect that in the RCX the program number 2 is selected: | ||
- | INSERT PICTURE HERE | + | {{ : |
- | ==== Executing the program ==== | + | ==== My first program ==== |
+ | |||
+ | |||
+ | I've attached a motor to the " | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | And this is my first program: | ||
+ | |||
+ | <code c> | ||
+ | task main() | ||
+ | { | ||
+ | OnFwd( OUT_C ); | ||
+ | Wait( 400 ); | ||
+ | OnRev( OUT_C ); | ||
+ | Wait( 400 ); | ||
+ | Off( OUT_C ); | ||
+ | |||
+ | } | ||
+ | |||
+ | </ | ||
To run and download the program into the RCX, you should do the following: | To run and download the program into the RCX, you should do the following: | ||
Line 183: | Line 181: | ||
===== Second Attempt: LEJOS ===== | ===== Second Attempt: LEJOS ===== | ||
+ | |||
+ | ==== Install ant ==== | ||
+ | |||
+ | You should have '' | ||
+ | |||
+ | <code shell> | ||
+ | $ sudo apt-get install ant | ||
+ | </ | ||
+ | |||
+ | And should have '' | ||
+ | |||
+ | <code shell> | ||
+ | sudo apt-get install libusb-dev | ||
+ | </ | ||
+ | |||
+ | After doing that, make sure that the usb.h file is available in your destination system. | ||
+ | |||
+ | |||
+ | ==== Hands on ==== | ||
[[http:// | [[http:// | ||
The web page has a [[http:// | The web page has a [[http:// | ||
+ | |||
+ | When I've checked out the web page, the download link didn't work. But you can go directly to the [[http:// | ||
+ | |||
+ | When you download and uncompress the file '' | ||
+ | |||
+ | Then start by setting the environment variable NXJ_HOME: | ||
+ | |||
+ | <code shell> | ||
+ | $ cd LEJOS_NXJ_DIRECTORY | ||
+ | $ NXJ_HOME=$(pwd) | ||
+ | $ export NXJ_HOME | ||
+ | </ | ||
+ | |||
+ | Then go to the '' | ||
+ | |||
+ | In my case, this command failed. The problem was in the '' | ||
+ | |||
+ | <code shell> | ||
+ | gcc -Wall -std=gnu99 -fPIC main_jlibnxt.c | ||
+ | </ | ||
+ | |||
+ | |||
+ | And it fails with this error: | ||
+ | |||
+ | < | ||
+ | main_jlibnxt.c: | ||
+ | </ | ||
+ | |||
+ | **Solution: | ||
+ | |||
+ | - Locate the usb.h file in your filesystem: '' | ||
+ | |||
+ | I've fixed the solution executing the '' | ||
+ | |||
+ | <code shell> | ||
+ | $ cd NXJ_HOME/ | ||
+ | $ ant | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
linux/legomindstorms.txt · Last modified: 2022/12/02 22:02 by 127.0.0.1