How to test a new NXT Sensor?

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

How to test a new NXT Sensor?

Postby esmetaman » Sun Sep 16, 2007 8:11 am

Hi, I have a new NXT Sensor, a Motion sensor from Techno Stuff

I have developed a class to control this hardware.

How to test this sensor?

Code: Select all
package lejos.nxt;

//http://www.techno-stuff.com/Nmotion.htm
//Motion Sensor for NXT
public class MotionSensor implements SensorConstants
{
   ADSensorPort port;
   private int _zero = 1023;
   private int _hundred = 0;

   public MotionSensor(ADSensorPort port)
   {
      this.port = port;
      port.setTypeAndMode(TYPE_LIGHT_ACTIVE,
                            MODE_PCTFULLSCALE);
   }

   public int readValue()
   {
      return port.readRawValue();
   }

}



Code: Select all

import lejos.nxt.*;


public class MotionTest {
   
   public static void main(String[] args) throws Exception {
      MotionSensor msObj = new MotionSensor(SensorPort.S1);
      
      while(!Button.ESCAPE.isPressed()) {
         LCD.clear();
         LCD.drawInt(msObj.readValue(), 0, 0);
         LCD.refresh();
         Thread.sleep(500);
      }
   }   
}

User avatar
esmetaman
Advanced Member
 
Posts: 238
Joined: Wed Sep 13, 2006 12:16 am
Location: Madrid, Spain

Postby lawrie » Sun Sep 16, 2007 6:52 pm

To test it, I would place it near a moving animal (or human being) :)

I am not quite sure what your question is. Did you try the code, and did you get any values returned?

The Techno Stuff web site says program it like an RCX Light sensor, so you could try the RCXLightSensor class, but this is a little confusing as it says it is a passive sensor, but RCX sensors use active power.

You could also try it as a NXT Light sensor without floodlighting (TYPE_LIGHT_INACTIVE).
lawrie
leJOS Team Member
 
Posts: 842
Joined: Mon Feb 05, 2007 1:27 pm

Problems with MotionSensor

Postby esmetaman » Sun Sep 16, 2007 7:30 pm

Hi Lawrie,

very joky!! :D

I updated the class, but I continue with the problem. Sorry I didn't explain well.

Code: Select all
import lejos.nxt.*;

//http://www.techno-stuff.com/Nmotion.htm
//Motion Sensor for NXT
public class MotionSensor implements SensorConstants
{
   ADSensorPort port;
   private int _zero = 1023;
   private int _hundred = 0;

   public MotionSensor(ADSensorPort port)
   {
      this.port = port;
      port.setTypeAndMode(TYPE_LIGHT_INACTIVE,
                            MODE_PCTFULLSCALE);
   }

   public int readValue()
   {
      return port.readRawValue();
   }

}



When I try to compile, I receive the following mensaje:

C:\DATOS\ROBOTICS\NXJ\samples\jab\MotionSensor>nxjc MotionSensor.java
MotionSensor.java:7: lejos.nxt.ADSensorPort is not public in lejos.nxt; c
e accessed from outside package
ADSensorPort port;
^
MotionSensor.java:11: lejos.nxt.ADSensorPort is not public in lejos.nxt;
be accessed from outside package
public MotionSensor(ADSensorPort port)
^
2 errors

C:\DATOS\ROBOTICS\NXJ\samples\jab\MotionSensor>

This is my problem.

lejos.nxt.ADSensorPort is not public in lejos.nxt


How to solve this problem?
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://www.roboticaenlaescuela.es
User avatar
esmetaman
Advanced Member
 
Posts: 238
Joined: Wed Sep 13, 2006 12:16 am
Location: Madrid, Spain

Postby lawrie » Sun Sep 16, 2007 8:13 pm

The best thing to do is to get the latest code from SVN into Eclipse, add MotionSensor to the lejos.nxt package and rebuild classes.jar.

I will put it in the next release if you want.

In the meantime, you can probably test the sensor using either the LightSensor or RCXLightSensor class.
lawrie
leJOS Team Member
 
Posts: 842
Joined: Mon Feb 05, 2007 1:27 pm

Results with LightSensor and RCXLigthSensorLightSensor

Postby esmetaman » Mon Sep 17, 2007 7:04 pm

Hi, Lawrie I tested the sensor with a instance of LightSensor and RCXLigthSensor, but the results are horrible.

How to download SVN?

Thanks.
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://www.roboticaenlaescuela.es
User avatar
esmetaman
Advanced Member
 
Posts: 238
Joined: Wed Sep 13, 2006 12:16 am
Location: Madrid, Spain

Postby bbagnall » Thu Sep 20, 2007 12:56 am

Is the motion sensor I2C? I'd like to know more about the sensor. If you have a link please send it.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

I dont know that info.

Postby esmetaman » Thu Sep 20, 2007 8:26 pm

Url :http://www.techno-stuff.com/Nmotion.htm
Web:http://www.techno-stuff.com/
Email:psevcik@techno-stuff.com

The Motion Sensor detects motion of people and animals..

The sensor is a Passive InfraRed sensor (PIR) for the Lego Mindstorms NXT system. It senses motion of a warm object, like a person or animal. This is the same type of sensor used in motion activated lights, and in some burglar alarms. The sensor detects changes in infrared light. Infrared is like normal light, except you can not see it with you eye. Infrared is also called Radiant Heat. There will be no visible indication when the sensor is operating.

The infrared technology used in this sensor is different than TV remote control technology. This sensor will not detect or interfere withTV remote controls, other Techno-stuff sensors, or with the RCX infrared communications port.
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://www.roboticaenlaescuela.es
User avatar
esmetaman
Advanced Member
 
Posts: 238
Joined: Wed Sep 13, 2006 12:16 am
Location: Madrid, Spain


Return to NXJ Software

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest

more stuff