Using Mux with hitechnic color sensor
Page 1 of 1

Author:  sam-wattnxt7350 [ Thu Mar 12, 2015 10:37 pm ]
Post subject:  Using Mux with hitechnic color sensor

Hello everyone,
I was wondering if its possible to read normalized rgb values when the hitechnic color sensor is plugged into a multiplexor. We had our color sensor plugged directly into the NXT and we were using Xander's drivers to get the rgb values. When I plugged it in to our mux, I was unable to get rgb values.
When it is in the mux I get values like:
R:14418175, G:9830655, B:3932415

Looking at Xander's code for the color sensor, I see this.
int HTCS2readColor(tSensors link);
bool HTCS2readRGB(tSensors link, int &red, int &green, int &blue);
bool HTCS2readHSV(tSensors link, float &hue, float &saturation, float &value);
bool HTCS2readWhite(tSensors link, int &white);
bool HTCS2readNormRGB(tSensors link, int &red, int &green, int &blue);
bool HTCS2readRawRGB(tSensors link, bool passive, long &red, long &green, long &blue);
bool HTCS2readRawWhite(tSensors link, bool passive, long &white);
bool _HTCSsendCommand(tSensors link, byte command);

int HTCS2readColor(tMUXSensor muxsensor);
bool HTCS2readRGB(tMUXSensor muxsensor, int &red, int &green, int &blue);

tConfigParams HTCS2_config = {HTSMUX_CHAN_I2C, 4, 0x02, 0x42};  /*!< Array to hold SMUX config data for sensor */
#endif // __HTSMUX_SUPPORT__

We have declared the mux driver first, so that is not an issue.

#include "hitechnic-sensormux.h"
#include "hitechnic-colour-v2.h"

I noticed that there weren't as many functions for the mux as there are for the nxt. Is this because the color sensor needs write access to get normal rgb values? If the color sensor does require write access, will the values I am getting now be consistent?

This is the part of the code I am using to read the values.

   HTCS2readRGB(colorport, r, g,b);      
   writeDebugStream("R:%d, G:%d, B:%d\n", r,g,b);

colorport is defined like this:

#define colorport msensor_S4_1


Author:  mightor [ Tue Mar 17, 2015 3:24 am ]
Post subject:  Re: Using Mux with hitechnic color sensor

That is not a bug in your code or a problem with your sensor, it's an issue with the conversion from int to short. I'll go through the code and fix where applicable. I noticed you are using the old driver suite. Are you still using ROBOTC 3.x?

= Xander

Author:  sam-wattnxt7350 [ Sun Mar 29, 2015 1:46 pm ]
Post subject:  Re: Using Mux with hitechnic color sensor

Sorry for the late response, the past few weeks have been crazy.
We are using RobotC 3.62. Is there a problem with that?


Author:  mightor [ Mon Mar 30, 2015 2:26 am ]
Post subject:  Re: Using Mux with hitechnic color sensor

Yeah, I am not really supporting the older version of ROBOTC anymore. You should deffo be upgrading to 3.65, for one thing. My Suite is really only for version 4.x now. You could try the following:
Set your menu level to "expert" and go to the compiler preferences. In there, change the size of int variables to short:
Screenshot at 08-24-57.png
Screenshot at 08-24-57.png [ 21.06 KiB | Viewed 12725 times ]

Let me know if that fixes your issue.

= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group