View unanswered posts | View active topics It is currently Sun Sep 23, 2018 1:47 pm






Reply to topic  [ 4 posts ] 
Using Mux with hitechnic color sensor 
Author Message
Rookie

Joined: Thu Mar 12, 2015 9:55 pm
Posts: 2
Post 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:
Code:
R:14418175, G:9830655, B:3932415


Looking at Xander's code for the color sensor, I see this.
Code:
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);

#ifdef __HTSMUX_SUPPORT__
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.

Code:
#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.

Code:
while(true)
   {
   HTCS2readRGB(colorport, r, g,b);      
   writeDebugStream("R:%d, G:%d, B:%d\n", r,g,b);
   wait1Msec(1000);
   }
   

colorport is defined like this:

Code:
#define colorport msensor_S4_1



Thanks,
Sam


Thu Mar 12, 2015 10:37 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post 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

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


Tue Mar 17, 2015 3:24 am
Profile WWW
Rookie

Joined: Thu Mar 12, 2015 9:55 pm
Posts: 2
Post Re: Using Mux with hitechnic color sensor
Hey,
Sorry for the late response, the past few weeks have been crazy.
We are using RobotC 3.62. Is there a problem with that?

Thanks,
Sam


Sun Mar 29, 2015 1:46 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post 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:
Attachment:
Screenshot at 08-24-57.png
Screenshot at 08-24-57.png [ 21.06 KiB | Viewed 6268 times ]

Let me know if that fixes your issue.

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


Mon Mar 30, 2015 2:26 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.