View unanswered posts | View active topics It is currently Fri Apr 18, 2014 11:49 am






Reply to topic  [ 57 posts ]  Go to page Previous  1, 2, 3, 4  Next
HT Color sensor: -> calibrating? 
Author Message
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
as Hitechnic wrote, the calibration of my faulty color sensor was successful - they programmed the calibration with Lego Software.
The calibration with a RobotC program (as suggested above) was not successful , so we need a correctly working RobotC calibration program.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sun Dec 28, 2008 12:25 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3105
Location: Rotterdam, The Netherlands
Post Re: HT Color sensor: -> calibrating?
Ford Prefect wrote:
as Hitechnic wrote, the calibration of my faulty color sensor was successful - they programmed the calibration with Lego Software.
The calibration with a RobotC program (as suggested above) was not successful , so we need a correctly working RobotC calibration program.

If I had one, I'd be happy to write one for you. However, I can't really afford to buy one now.

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 Dec 28, 2008 12:29 pm
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
thx Xander,
I think now it's up to the developers....

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sun Dec 28, 2008 2:46 pm
Profile
Rookie

Joined: Wed Jun 25, 2008 6:07 pm
Posts: 46
Post Re: HT Color sensor: -> calibrating?
Ford, I have a color sensor and I have a little bit of free time over the next few days, so I can fiddle with this a bit. I assume you're ok with the way it reads the RGB values. Are you just looking for a way to 'calibrate' the detected colors?

What I'm envisioning is a program that you would run on your own. It would let you hold the sensor up to a variety of different items and show you the RGB values of each. When you like what you see, you would hit a button and have the points stored in a local file. Then, when you use the sensor later, the data file would be read. When the sensor values are polled, they would look to see which of the stored color points is closest to what it sees, and return that as the 'color' value.

Would that suit your needs?


Sun Dec 28, 2008 5:38 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
hi avidprogrammer,
the problem WAS:

Quote:
Testing the colors I found out that the returned green and red values always are too small, compared to blue,
so the colors appear "bluish".


e.g.
Code:
real_color  red  green  blue     recognized
white         70   70   100       3  = cyan
green         20    0   120       1  = violet
violet        10    0    90       1/2= violet/blue
cyan          16    8   120       2  = blue
yellow        80   50   105       11 = lightViolet
orange        20    0    60       3  = cyan
red           60    0    20       10 = pink
light blue    40    2   120       1  = violet
 


Quote:
The color "names " may be a little faulty, but at the white color you may see clearly, that the 3 color values are not identical as they should be.


the reason was that the calibration definetively was faulty, and I couldn't re-calibrate ist.
So I sent the sensor to Hitechnic, and THEA managed to re-calibrate it. As thea wrote, the sensor now should work correctly.

But for the future it's neccessary to have such a calibrating program, cause I won't want to send it each time from germany to the US just for recalibrating :? If this works with NXC, why shouldn't it work with ROBOTC?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sun Dec 28, 2008 6:24 pm
Profile
Rookie

Joined: Wed Jun 25, 2008 6:07 pm
Posts: 46
Post Re: HT Color sensor: -> calibrating?
Ford Prefect wrote:
If this works with NXC, why shouldn't it work with ROBOTC?

I'm just guessing here, but I don't think NXC would be doing anything more than just directly reading the RGB and color values from the sensor. Are you saying that when you tried the code with NXC (before getting the sensor re-calibrated) that it gave back better RGB values than you were getting from the sample code in RobotC? (IE -- before sending your sensor back, RobotC had high blue values, but NXC didn't?)

In any case, I'm still having some fun fiddling with the color sensor for my own purposes. I'll post some code in a few days for those who are interested in giving it a try.


Sun Dec 28, 2008 6:37 pm
Profile
Rookie

Joined: Wed Jun 25, 2008 6:07 pm
Posts: 46
Post Re: HT Color sensor: -> calibrating?
Ok, I think I figured out what you're looking for. Is it this? http://thenxtstep.blogspot.com/2006/05/ ... ement.html

Apparently, the sensor itself has (or had) a way to re-calibrate for white and black. I'll see if I can find out more. Hopefully, it will be as easy as setting a register value while holding up white and black pieces of paper and then you'll be all set.

More to come soon.

Edit: It definitely looks like the calibration routines are generally accessible. Lejos seems to have them available, so I'm going to work backwards from their code to figure out what needs to be done: http://www.stmarycss.ca/oconnor/ICE3M/1 ... ensor.html


Sun Dec 28, 2008 7:06 pm
Profile
Rookie

Joined: Wed Jun 25, 2008 6:07 pm
Posts: 46
Post Re: HT Color sensor: -> calibrating?
Just more notes for people who are interested:

It looks like you set the configuration mode by writing to register 0x41 over I2C. (The HiTechnic specs refer to that as a 'command' register, reserved for future use.) Writing a 0x42 appears to enter 'black level' calibration. 0x43 is used for 'white balance.'

Code coming soon after I get a chance to test it.

[Edit:] Xander, sorry, it looks like you've already written code for this. I really should learn to read the whole thread before I get into things. Your code looks like it only does the white cal, though. I'm giving it a try and I'll add the black/ambient calibration as well.


Sun Dec 28, 2008 7:23 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3105
Location: Rotterdam, The Netherlands
Post Re: HT Color sensor: -> calibrating?
AvidProgrammer wrote:
[Edit:] Xander, sorry, it looks like you've already written code for this. I really should learn to read the whole thread before I get into things. Your code looks like it only does the white cal, though. I'm giving it a try and I'll add the black/ambient calibration as well.

Great, thanks. I had no idea that there was more than one command, but come to think of it, it kind of makes sense to have two calibration points, one at each end. Thanks for adding the extra code.

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]


Mon Dec 29, 2008 3:06 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
hi folks,
actually white calibration should be good enough.
again, this is a note I received from Hitechnic:
Quote:
You can recalibrate the color sensor by using an I2C write command and write 0x43 to location 0x41. Note that the sensor MUST be facing a white target surface at the prescribed distance before executing the calibrate otherwise the sensor may not work at all until successfully recalibrated. Review the instructions for calibrating I previously sent to you.
Once the calibrate command has been sent to the sensor it will complete the calibration in about ½ a second and then reset and be ready to use as normal.

but instead of 50-50-50 (red-green-blue) for "white" my sensor always showed 70-70-100. If the white calibration had worked correctly, there should have been at least something like 70-70-70 or 100-100-100 instead. Maybe it's because of passing an array of int?

Edit:
I only tried the sensor with RobotC, I don't use NXC or NXT-G so far.
The faulty colors have been detected by me only with my RobotC program (see above).
My problem is not reading, but calibrating.
A calibrating program for NXT-G exists, but I don't have NXT-G, so I cant use this program (and actually I hate NXT-G).

Because the RobotC calibrating program didn't work, I sent the sensor to HT, they calibrated it with Lego software, and now it works fine (as they said).

What do the developers say to this? Plz give them a chance to reply! :poke:

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Mon Dec 29, 2008 9:14 am
Profile
Rookie

Joined: Wed Jun 25, 2008 6:07 pm
Posts: 46
Post Re: HT Color sensor: -> calibrating?
Mightor,

Out of curiosity, is there any good way to avoid bus errors? I've noticed, for example, that if I run your code without any modifications, it doesn't have any problem. If I wait, though, and display some text, then hijack the buttons and wait for a specific key press, there is a bus error after the key press.

But -- if I wait again between the key press and the I2C command, there isn't any bus error (~1/2 second seems sufficient).

Have you seen things like this before? Or am I just having a bad day with I2C?


Tue Dec 30, 2008 1:19 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3105
Location: Rotterdam, The Netherlands
Post Re: HT Color sensor: -> calibrating?
There are no good ways to avoid bus errors, however, I am working on a driver that automatically recovers from this kind of thing without user intervention. It's all part of a frame work I am, well, working on. I am not sure why this error would occur. Perhaps you should submit it to the Mantis database with some instructions on how to recreate the error. Then Dick can have a look at it :) By the way, what speed are you using the sensor at? Normal, Faster or Fastest? Try the normal speed to see if the problem still occurs.

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]


Tue Dec 30, 2008 3:08 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
my observartions:
Xanders 1st program used the sensor type: HitechnicColorSensor with intrinsic RobotC driver (high speed).
result: No I²C error (no buzz), and no calibrating.

My 2nd try was with sensor type I²C low speed (code see above)
result: I²C error (buzz), but also no calibrating.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Tue Dec 30, 2008 2:35 pm
Profile
Rookie

Joined: Wed Jan 14, 2009 3:14 am
Posts: 16
Post Re: HT Color sensor: -> calibrating?
I've done some testing with my color sensor and I think the calibration issue isn't so much a faulty sensor or factory calibration but more an issue of what was used to set the initial calibration. With my sensor, if I take readings on a standard white sheet of paper I get a 3 reading like the OP. If I take a reading on a glossy white surface I get a 17 as per spec. Thus it appears that a calibration may be required for various situations.


Wed Jan 14, 2009 3:25 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
yes, you're probably right.

So it's much more important to have a correctly working calibration util.

... developers...?!?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sat Jan 17, 2009 9:13 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 57 posts ]  Go to page Previous  1, 2, 3, 4  Next

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.