Question(look for all attached sensors)

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

Question(look for all attached sensors)

Postby slejos » Wed Aug 24, 2011 3:36 pm

Hi
I have a questions is it possible to look for all attached sensors and draw the result on the display?
Because I want to put the sensors in random sockets and dont want to only use the specific socket for one sensor.
Please tell me if its possible and how??

I searched for 2 days in the lejos API and didnt found a method that will help me to realize this.

Thanks in advance

slejos
slejos
New User
 
Posts: 7
Joined: Wed Aug 24, 2011 3:28 pm

Re: Question(look for all attached sensors)

Postby gloomyandy » Wed Aug 24, 2011 6:37 pm

Hi,
Unfortunately in general there is no way to determine what sensor is attached to an NXT sensor port. If you search the forum you should find a number of threads discussing sensor detection which will explain the issues with doing this...

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

Re: Question(look for all attached sensors)

Postby slejos » Thu Aug 25, 2011 6:39 am

thanks for the information.
Is there any way to do this. It can be a solution which is not that good but if it works

slejos
slejos
New User
 
Posts: 7
Joined: Wed Aug 24, 2011 3:28 pm

Re: Question(look for all attached sensors)

Postby TechnoX » Sat Aug 27, 2011 7:01 pm

If the sensors are communicating with I2C you can search for all addresses and identify which sensor is which. But then you need to have unique addresses on each sensor (or some other register that differ your sensors).
And then you just scan all the addresses at all ports and compare the values with an lookup-table for your sensors ;)

But why cant you just have the sensor connected to the same port all the time? :s
TechnoX
Novice
 
Posts: 52
Joined: Tue May 03, 2011 5:57 pm
Location: Sweden

Re: Question(look for all attached sensors)

Postby burti » Sun Aug 28, 2011 10:13 pm

slejos wrote:I have a questions is it possible to look for all attached sensors and draw the result on the display?
Because I want to put the sensors in random sockets and dont want to only use the specific socket for one sensor.
Please tell me if its possible and how??

Hi Slejos.
I have to disappoint you: you are not the first one who had that idea with lejos. I already had the same idea (and someone else maybe much earlier).

I once tried to program a flexible software architecture which indeed was first doing a kind of "power on self test"
as it is always happening when you start your computer before it boots the operating system.
The power on self test targeted at detecting all devices which were plugged in and serving dynamic access on them.
My experience was: It is very hard or impossible to find out which sensor or motor is plugged in to which port.
Some sensors like those ones manufactured by hitechnic give you at least some sensor metainformation like the type of the sensor, others like those ones by lego do not at all.
As each sensor or motor serves a purpose and several ones of each can be plugged in at the same time (e.g. two motors and two distance sensors),
the information about sensors/motors plugged in can be quite useless. E.g. you detect two motors und you know one is the right one and the other one is the left one.
If you don't have a compass sensor which allows you to find out the orientation of your nxt-vehicle, then you cannot find out which of both motors is the right or the left one.
(Otherwise you could find out the left motor by making one random motor of both just moving and observe the change of the orientation with the compass sensor.
This approach makes only sense with an conceptual model like "the vehicle has a left and a right motor, a compass sensor and a distance sensor left and one right ...")

You usually "tag" devices like sensors and motors in the area of "embedded systems" , i.e. you leave special information you can read out for identification of devices.
No sensor with nxt gives you the opportunity as far as I know :-(
Maybe someone will once create some additional hardware for "tagging" devices ...
(I would like to do it but I'm not a technician for microelectronics yet. Moreover I have no time but too many projects I still have to finish before I begin new ones like that one ... :-(

Frankly speaking, I would give that idea up because you waste only your time (as I was doing once).
I know it would be nice when you could just plug in your sensors and motors while ignoring the sockets.

Michael
burti
Novice
 
Posts: 61
Joined: Thu Jun 25, 2009 11:41 pm


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff