Using Multiple Ultrasonic Sensors on the LEGO NXT RRS feed

  • Question

  • Hello all, 

    For the project that I am working on, I plan to use 2 or more ultrasonic sensors on a single brick.
    After a little bit of searching on the net, I found that all LEGO ultrasonic sensors works with the sound signal of the same frequency. This results in unwanted interference between 2 or more ultrasonic sensors working in the same environment when one accidentally reads the other's bounce-back signal.

    After looking at the "NxtDeviceSonarSensor.cs" file in "\samples\Platforms\LEGO\NXT\V2\NxtBrick", I found that on line 405-406, there are settings to make the ultrasonic read in a single shot:

                byte[] requestSingleShotReading = { 0x02, 0x41, 0x01 };
                byte[] startContinuousReadings = { 0x02, 0x41, 0x02 };
                byte[] setContinuousReadingInterval = { 0x02, 0x40, 0x010 };

    I was wondering if any one has tried that yet. If I can read in single shots, the interference problem may potentially be solved.

    I would also like to make modifications to the LEGO code (to make changes such as the above), however, I don't know the best way to make a duplicate of the Ultrasonic sensor service. Can anyone give me some tips on that?

    Thank you guys, 

    Thursday, February 18, 2010 3:51 PM


  • I have not tried multiple sensors. However, for your second question, what you need to do is:

    • Copy the source somewhere else but still under the RDS installation point. (I have a "Projects" folder where I put all my stuff).
    • Run DssProjectMigration on the new folder. This will fix up all the paths.
    • Edit the solution and change the Contract Identifiers in all the services, as well as the Assembly name.
    • Now you can compile and you will not conflict with the existing Microsoft services.

    In RDS 2008 R2 we did part of this work for you. We changed all of the Contract IDs to include "user" and put "user." in front of all the Assembly names. So if you compile the LEGO code on R2 you generate new DLLs and new services (because the Contract IDs are different). The bullet points above are for the general case.

    Of course, now that you have created a different version of the LEGO code, you will need to reference the new services in your manifests, or VPL or wherever.


    Thursday, February 18, 2010 11:59 PM