linux:legomindstorms
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
linux:legomindstorms [2013/12/30 16:42] – rlunaro | linux:legomindstorms [2014/01/07 23:40] – 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??? ===== | ||
- | |||
- | Yes, my computer doesn' | ||
- | {{ : | + | Of course, there are other options, but I won't discuss here. |
+ | ===== RS232 Communication in the XXI Century ===== | ||
+ | Modern computers doesn' | ||
- | **The problem is** that this cable comes with a fantastic driver.... for Windows and Mac. | ||
- | INSERT HERE PICTURE OF THE DRIVER DISC | + | [[http:// |
- | So, the working of this solution depends greatly with the hability or good work of the Ubuntu and Linux engineers. | + | ==== Checking that it works under Linux ==== |
- | ===== 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 your RS232 adapter to the black box and make sure this is on, and with the batteries connected. The " |
- | **First**, connect the unit to the PC and make sure it's on. The " | + | {{ :linux: |
- | INSERT PICTURE OF THE BLACK UNIT HERE. | + | **Optionally**, |
- | **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. | + | Now run the following code: |
- | + | ||
- | **Next**, | + | |
<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** | ||
- | I've run this command: | + | {{ :linux: |
- | <code shell> | ||
- | $ nqc -S/ | ||
- | No firmware installed on RCX | ||
- | </ | ||
- | So I'm afraid further investigation is needed. | + | **Other commands to test proper running** |
- | **Last | + | You can try other commands that doesn't require to have a program like this: |
- | + | ||
- | I've attached | + | |
- | + | ||
- | PICTURE HERE OF THE RCX WITH THE MOTOR. | + | |
- | + | ||
- | And this is my first program: | + | |
- | + | ||
- | <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> | <code shell> | ||
- | $ nqc -S/ | + | $ nqc -S/ |
No firmware installed on RCX | No firmware installed on RCX | ||
- | |||
</ | </ | ||
- | So, I definitely think that the RCX is completely blank, and I have to install some sort of firmware | + | ==== Install |
- | ====Where | + | The next step is installing |
- | Check out the box of mindstorm: it should be a CD: | ||
- | INSERT PICTURE OF THE CD HERE | ||
- | Possible cases you might find here: | + | ===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: | ||
- The firmware file is in the cd and you can extract directly without hassle. It should be a file like '' | - The firmware file is in the cd and you can extract directly without hassle. It should be a file like '' | ||
Line 136: | 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 149: | Line 122: | ||
You should see a message in the RCX about the progress of the download: | You should see a message in the RCX about the progress of the download: | ||
- | INSERT PICTURE HERE | + | {{ : |
- | 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 169: | 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 187: | 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: '' | ||
+ | |||
+ | The fixed command is this: | ||
+ | |||
+ | < | ||
+ | gcc -Wall -std=gnu99 -fPIC main_jlibnxt.c -I/ | ||
+ | </ | ||
+ | |||
+ | |||
linux/legomindstorms.txt · Last modified: 2022/12/02 22:02 by 127.0.0.1