View unanswered posts | View active topics It is currently Wed Aug 27, 2014 7:56 pm






Reply to topic  [ 8 posts ] 
Using a Colour Sensor with a motor multiplexer (NXTMMX)? 
Author Message
Rookie

Joined: Mon Aug 20, 2007 4:01 am
Posts: 28
Post Using a Colour Sensor with a motor multiplexer (NXTMMX)?
Hello,

How do I use a LEGO Colour Sensor from the NXT v2.0 box, with an Mindsensors Multiplexer for NXT Motors (NXTMMX-v2)?

I am using RobotC v3.04 and the latest Xander's ROBOTC Drivers v2.4 (the mindsensors file gave an error message). The NXTMMX is plugged into S4 on the NXT, and I have a motor on M1 and a LEGO Colour Sensor on the sensor port. With the Colour Sensor plugged in, it does not work, but with it removed, the motor turns as expected.

Can anyone help?

Thanks
Karl.

The code below is mostly from Xander's example test file.
Code:
#pragma config(Sensor, S4,     MSMMUX,              sensorI2CCustom)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "drivers/MSMMUX-driver.h"
#pragma platform(NXT)

task main() {

  MSMMUXinit();
  MSMotorStop(mmotor_S4_1);
  MSMMotorEncoderResetAll(MSMMUX);
  MSMMUXsetPID(MSMMUX, 0x1B58, 0x0000, 0x927C, 0x3A98, 0x012c, 0x1D4C, 0x10, 0x80);
  MSMMotorEncoderReset(mmotor_S4_1);
  MSMMotorSetBrake(mmotor_S4_1);
 
  MSMMotorSetEncoderTarget(mmotor_S4_1, 150);
  MSMMotor(mmotor_S4_1, 50);
 
  PlaySound(soundBeepBeep);
  wait1Msec(500);

}



Thu Dec 29, 2011 5:30 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3196
Location: Rotterdam, The Netherlands
Post Re: Using a Colour Sensor with a motor multiplexer (NXTMMX)?
I don't think it's a supported configuration, at least it's not something I've ever tested. My guess is the colour sensor interferes with the I2C bus. It is a very unusual sensor. It's analogue but not the same way the regular analogue ones are, like the touch or sound sensor. It uses the dig0 and dig1 pins (used for SCL and SDA for I2C) to go through a series of calibration commands. No publicly available information on how this sensor exists.

You could ask Mindsensors to see if this is something they support, you can find their support email address on their website: http://www.mindsensors.com/

Do you not have another digital sensor you could hook up to that port?

- 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]


Thu Dec 29, 2011 5:38 pm
Profile WWW
Rookie

Joined: Mon Aug 20, 2007 4:01 am
Posts: 28
Post Re: Using a Colour Sensor with a motor multiplexer (NXTMMX)?
Hello Xander

Thanks for the quick reply, I shall email mindsensors and ask. I do have a Hi Technic Colour Sensor, I don't think they're as good. But it does appear to work.

Karl.

Code:
#pragma config(Sensor, S4,     MSMMUX,              sensorI2CCustom)

#include "drivers/MSMMUX-driver.h"
#include "drivers/HTCS-driver.h"
#pragma platform(NXT)
#define HTCS S4

task main() {
  int red = 0;
  int green = 0;
  int blue = 0;
  int _color = 0;
  string _tmp;
  int encA = 0;
  MSMMUXinit();
  MSMotorStop(mmotor_S4_1);
  MSMMotorEncoderResetAll(MSMMUX);
  MSMMUXsetPID(MSMMUX, 0x1B58, 0x0000, 0x927C, 0x3A98, 0x012c, 0x1D4C, 0x10, 0x80);
  MSMMotorEncoderReset(mmotor_S4_1);
  MSMMotorSetBrake(mmotor_S4_1);

  MSMMotorSetEncoderTarget(mmotor_S4_1, 150);
  MSMMotor(mmotor_S4_1, 50);

  PlaySound(soundBeepBeep);
  wait1Msec(500);
 
  while (true) {
    _color = HTCSreadColor(HTCS);
    encA = MSMMotorEncoder(mmotor_S4_1);

    nxtDisplayCenteredTextLine(0, "C: %d, E: %d", _color, encA);
    nxtDisplayCenteredBigTextLine(1, "R  G  B");

    nxtEraseRect(0,10, 99, 41);
    nxtFillRect( 0, 10, 30, 10 + (red+1)/8);
    nxtFillRect(35, 10, 65, 10 + (green+1)/8);
    nxtFillRect(70, 10, 99, 10 + (blue+1)/8);
    StringFormat(_tmp, " %3d   %3d", red, green);
    nxtDisplayTextLine(7, "%s   %3d", _tmp, blue);

    wait1Msec(100);
  }



Thu Dec 29, 2011 6:15 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3196
Location: Rotterdam, The Netherlands
Post Re: Using a Colour Sensor with a motor multiplexer (NXTMMX)?
Is it a new or old HiTechnic colour sensor? The V2 ones are fantastic, a LOT better than the LEGO one.

- 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]


Thu Dec 29, 2011 6:22 pm
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Using a Colour Sensor with a motor multiplexer (NXTMMX)?
karl101 wrote:
I do have a Hi Technic Colour Sensor, I don't think they're as good.


There is a comparison of the LEGO and HT Color sensors here. I don't think you'll be able to use the LEGO one on it anyway. Here's why:
Mindsensor.com from the NXTMMX V2 Product Page wrote:
It also has a pass-through Digital Sensor Port to connect more sensors/multiplexers.


But, not having the Multiplexer or the HT sensor, I can't be sure.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Thu Dec 29, 2011 6:24 pm
Profile WWW
Rookie

Joined: Mon Aug 20, 2007 4:01 am
Posts: 28
Post Re: Using a Colour Sensor with a motor multiplexer (NXTMMX)?
Hello,

My hi-technic sensor will be the old one. Obviously, I shall have to upgrade.

Thanks.

Karl


Thu Dec 29, 2011 8:22 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3196
Location: Rotterdam, The Netherlands
Post Re: Using a Colour Sensor with a motor multiplexer (NXTMMX)?
Well, not necessarily. Does it have two little round lenses on the front or one round and one flat? If it's two round ones, it's a V1 and if one round, one flat it's a V2.

- 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]


Fri Dec 30, 2011 2:34 am
Profile WWW
Rookie

Joined: Mon Aug 20, 2007 4:01 am
Posts: 28
Post Re: Using a Colour Sensor with a motor multiplexer (NXTMMX)?
Both the lenses are rounded. I've had the sensor for quite some time.

Karl.


Fri Dec 30, 2011 5:28 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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.