View unanswered posts | View active topics It is currently Wed Sep 23, 2020 4:17 pm






Reply to topic  [ 9 posts ] 
Programatically detecting type of sensors 
Author Message
Rookie

Joined: Mon Jan 04, 2010 10:51 am
Posts: 15
Location: Portugal
Post Programatically detecting type of sensors
I know I'm probably asking a lot, but is there a way to programatically discover the type of sensor/motor that is attached to each port in the NXT? I'm using Lego, Hi-Technic and MindSensors sensors and motors.

I'm guessing that it probably isn't possible with analog sensors, but is it possible at least with I2C sensors and motors?

Miguelb


Sun Jan 10, 2010 7:50 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Programatically detecting type of sensors
Miguel,

You can find a similar conversation in this thread: http://forums.nxtasy.org/index.php?showtopic=4592. It's for NXC, but the same principles apply to ROBOTC.

What kind of motors are you using?

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jan 10, 2010 7:59 am
Profile WWW
Rookie

Joined: Mon Jan 04, 2010 10:51 am
Posts: 15
Location: Portugal
Post Re: Programatically detecting type of sensors
Thanks - it's a good starting place. I am also planning on using Mindsensor multiplexer for I2c sensors, so I guess I will have a bit more work, but I am glad to know that at least I2C are discoverable - even if analog is trickier.

I am planning to use mindsensors servos besides lego motors. I haven't used them yet, but I am interested to see their capabilities.


Sun Jan 10, 2010 9:53 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Programatically detecting type of sensors
miguelb,

Which Mindsensors sensor multiplexer are you talking about? They have one, that's the one for RCX sensors. Those are all analogue by default.

I develop and maintain a driver suite for almost all Mindsensors sensors and all HiTechnic ones. You can download it here: http://rdpartyrobotcdr.sourceforge.net/. It includes support for the servo controller and also the RCX mux.

Is there a specific reason you need to be able to scan the sensor ports for sensor types?

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jan 10, 2010 10:00 am
Profile WWW
Rookie

Joined: Mon Jan 04, 2010 10:51 am
Posts: 15
Location: Portugal
Post Re: Programatically detecting type of sensors
I'm talking about this one:

http://www.mindsensors.com/index.php?mo ... PAGE_id=79

Supposedly it is I2C compatible.

Thanks - your driver suite will came in handy and save me some work - particularly with the servos.

I am just trying out different sensors and motors to know their limitations. Because of that I am allways changing the configuration - and hence automatic detection cames in handy so that I don't have to be allways changing code and recompiling.

Besides, I am planning on create validation mechanisms to use in future assemblies, to make sure the configuration is correct.

Miguelb


Sun Jan 10, 2010 12:03 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Programatically detecting type of sensors
The sensor MUX you linked is I2C compatible, only you need to pay really good attention to the fact that you cannot have more than one pair of pull-up sensors on your bus. That means if you put one sensor on there, you need to make sure the others have their disabled. The Mindsensors sensors are capable of this, the HiTechnic ones are not. Another caveat is that you cannot have two sensors with the same address on the bus. Most standard Lego sensors (and HiTechnic) use the 0x02 address. Mindsensors uses different addresses for different sensors. You can also manually override the address a Mindsensors sensor listen to.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jan 10, 2010 12:51 pm
Profile WWW
Rookie

Joined: Mon Jan 04, 2010 10:51 am
Posts: 15
Location: Portugal
Post Re: Programatically detecting type of sensors
You mean I can't have several active sensors at the same time? Or that I just have to make sure to read their values sequentially, but not in parallel - simply reading values from different sensors in the same task won't garantee that?

I was aware that I have to change the addresses in the mindsensors sensors (their documentation is fairly good). Is it possible to do the same with the hi-technic?


Sun Jan 10, 2010 7:12 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Programatically detecting type of sensors
HiTechnic does not officially support this kind of setup and neither does Lego. Normally an NXT sensor has a pair of pull ups on the bus. That means that if you add another sensor, you will have two pairs. That's one too many. The MS sensors can deal with this, but the HT and Lego ones can't. That means you can only ever have one HT sensor on there and, say, 3 MS ones with their pull ups disabled. I2C works with slave addresses. You cannot have more than one slave with the same address on the bus.

You can only do one transaction at a time on an I2C bus. It's a simplex serial bus :)

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jan 10, 2010 7:25 pm
Profile WWW
Rookie

Joined: Mon Jan 04, 2010 10:51 am
Posts: 15
Location: Portugal
Post Re: Programatically detecting type of sensors
Got it. Thanks for the tip. That's the kind of limitation I'm trying to find out.


Sun Jan 10, 2010 8:21 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.