New IRLink driver for LeJOS NXJ.

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc.

Moderators: imaqine, 99jonathan, roger

szimonek
New User
Posts: 3
Joined: Fri Mar 06, 2015 1:41 pm

New IRLink driver for LeJOS NXJ.

Postby szimonek » Fri Mar 06, 2015 2:14 pm

Hi,

Few years ago, I bought two HiTechnic's IRLink sensors. I mainly wanted to use them in two way commnication between NXT and RCX, but there was no support for that in LeJOS NXJ driver. So I finally managed to rewrite driver which exists in 0.9.1 release (SVN version is identical).

Original driver have two functions implemented:
1. Steering Power Function in Combo Direct Mode
2. Emulation of RCX Remote Control

My driver contains:
1. Steering Power Funtion is all 4 modes (described in v1.2 of PF documentation):
- Extended Mode
- Combo Direct Mode (code rebuilded to be universal)
- Single Output Mode
- Combo PWM Mode
2. Emulation of RCX Remote Control (code unchanged)
3. Steering of RCX connected motors:
- Start-Stop-Float (method motorStartStop)
- directions (method motorDirection)
- rotation speed (as much as firmware allows, method motorPower)
4. Setting types and modes of sensors connected to RCX (methods setSensorType, setSensorMode and setSensorModeWithSlope)
5. Playing predefined system sounds (method playSystemSound)
6. Setting IR transmitter range (method setTXRange with derivates: setShortRange and setLongRange)
7. Keeping RCX alive (metoda sendAlive)
8. Reading RCX battery level (method getBatteryLevel)
9. Reading source values (for correct source-value pairs, method pollSourceValue)
10. Reading values from sensors. Returned as boolean, integer or double (method pollFromSensor with derivates: getSensorIntValue, getSensorBooleanValue and getSensorDoubleValue)
11. Reading RAW sensors values (methods getSensorUnprocessedRawValue and getSensorUnprocessedBooleanValue)
12. Playing notes (method playTone)

General Note: Driver has many constants defined for PF and RCX modes. All implemented functionalities was tested. My test setup is presented here: http://blog.hsh.one.pl/?p=124
PF Note: Single Pin PF modes described in v1.0 and v.1.1 of PF documentation, were removed in v.1.2 so I did not implemented them.
R/C Trains Note: I didn't have any R/C Train set, so I didn't implemented this mode, but it is possible. I discovered that R/C Trains mode is almost identical to PF Extended Mode.
RCX Note: To use this driver, RCX must be flashed with original LEGO firmware. Because single read of sensor value lasts near 150ms, then constant pooling all three connected sensors, allows to achieve 2 reads per second. Combining other commands (i.e. motors), gives us resolution od one read per second or less. This limitation is the result of IR transmission speed. All methods with one exception, are using a common communication loop, that keeps toogle bit in sync, verifies RCX answer and repeats commands if necessary. Exception is playTone method, because note length is more important that value returned from RCX.

Important SVN Code Note: It is not possible to build working firmware for NXT from code in SVN repository. I have download arm build tools, and managed to build firmware, but it crashes the brick. This is how I defined The Brick Axiom: "The brick has turned into a brick".

You can download my LeJOS NXJ IRLink driver at: http://blog.hsh.one.pl/?p=210

--
Best regards
Szymon

User avatar
gloomyandy
leJOS Team Member
Posts: 6022
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: New IRLink driver for LeJOS NXJ.

Postby gloomyandy » Fri Mar 06, 2015 5:41 pm

I am not aware of any problems with building the firmware. Are you sure that you have used the correct tools and applied the patches as specified by the shell script in SVN?

szimonek
New User
Posts: 3
Joined: Fri Mar 06, 2015 1:41 pm

Re: New IRLink driver for LeJOS NXJ.

Postby szimonek » Sat Mar 07, 2015 7:01 pm

Hi,

There is no problem with building the firmware. Build is working and produces lejos_nxt_rom.bin file, but when I have uploaded this file to the brick (using nxjflash.bat from 0.9.1 release) it crashed the brick and I was forced to hard reset the brick. Maybe I'm doing something wrong, it was my first time with uploading firmware build by myself. i can send you a photo with error displayed on the brick screen, I just need to flash it again.

Is there a possibility to replace IRLink driver in the SVN repository with my version?

--
Best regards
Szymon

User avatar
gloomyandy
leJOS Team Member
Posts: 6022
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: New IRLink driver for LeJOS NXJ.

Postby gloomyandy » Sat Mar 07, 2015 7:56 pm

A display of the screen probably won't help. What will is knowing exactly what tool chain you have used to build the firmware with. So did you use the script that we provide to create the tool chain? Where there any problems when you did this? Did you have to make any changes to the build process?

szimonek
New User
Posts: 3
Joined: Fri Mar 06, 2015 1:41 pm

Re: New IRLink driver for LeJOS NXJ.

Postby szimonek » Mon Mar 16, 2015 10:49 pm

Hi,

I'm sorry for the late answer, but I was unable to do it earlier. Entire procedure which I took was:
1. Download SVN code trunk. It was lejos-code-7022-trunk then.
2. Enter nxtvm subdirectory
3. Run build_arm_toolchain.sh. I did run it 3 times before it succeded, because of some missing packages (i.e. texinfo) in my Linux box (CentOS 6.6)
4. When succeded the file lejos_nxt_rom.bin was build (among others). It has size 58400.
5. I have replaced lejos_nxt_rom.bin from 0.9.1 release (size 55888) with that build from SVN code (size 58400), and used nxjflash tool to upload this image to NXT brick.
6. Image was uploaded but it crashed when brick tried to load it. The only possible action was to use hard reset button, and flash brick with original 0.9.1 image (size 55888).

What I did wrong?

--
Best regards
Szymon

MindS1
New User
Posts: 4
Joined: Mon Nov 24, 2014 4:14 am

Re: New IRLink driver for LeJOS NXJ.

Postby MindS1 » Mon Nov 16, 2015 3:19 pm

Hello, just wanted to stop by and say thanks so much for making this! Clearly you've put a lot of time into getting this working. It's disappointing that the developers haven't included your driver with the official build of LeJOS, as the existing IR-Link support is very limited, and the Mindsensors NR-Link has been out of production for years.


Return to “NXJ Hardware”

Who is online

Users browsing this forum: No registered users and 1 guest