View unanswered posts | View active topics It is currently Fri Jul 25, 2014 3:08 pm






Reply to topic  [ 57 posts ]  Go to page Previous  1, 2, 3, 4
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?
today I received my new calibrated sensor back from Hitechnic's, they recalibrated it with a Lego program.
now pointing to a white sheet of paper it shows quite correctly
red=54
green=58
blue=62
color=17=white

It's really a mess that it's not been possible to have such a claibration tool from the RobotC Co.!!

_________________
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)}


Wed Jan 21, 2009 9:54 am
Profile
Rookie

Joined: Wed Jan 14, 2009 3:14 am
Posts: 16
Post Re: HT Color sensor: -> calibrating?
Ford Prefect wrote:
today I received my new calibrated sensor back from Hitechnic's, they recalibrated it with a Lego program.
now pointing to a white sheet of paper it shows quite correctly
red=54
green=58
blue=62
color=17=white

It's really a mess that it's not been possible to have such a claibration tool from the RobotC Co.!!


Given the HiTechnic site doesn't provide the documentation for calibration I don't see why RobotC would provide a calibratin routine. It seems details had been provided at one point because folks have developed calibration programs for the sensor, but I wouldn't expect any official support for this until Hitechnic provides official documentation. Currently the Command byte used to switch to calibration mode is listed by HiTechnic as reserved for future use. One of these days I'll add this functionality for my sensor. It looks pretty straight forward. Here is a link with some sample code (not RobotC but shouldn't be difficult to translate): http://www.mindstorms.rwth-aachen.de/su ... ateColor.m


Wed Jan 21, 2009 11:04 pm
Profile
Rookie

Joined: Sat Apr 19, 2008 11:51 am
Posts: 43
Post Re: HT Color sensor: -> calibrating?
as Ford wrote above, Hitechnic actually provided the data for calibration, but nevertheless all attempts with RobotC calibration programs didn't work! E.g., you can read a program written by Mightor above, but unfortunately it didn't work (I was able to watch this as I visited Ford).

Hitechnic doesn't support RobotC, so I agree that it's wishful that the RobotC Company supports third party sensors like Hitechnic.


Thu Jan 22, 2009 12:41 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
yes, correct.
the reason why RobotC calibration programs don't work, are incompatibilities of the RobotC I²C driver libraries and intrinsics with the Hitechnic and Lego standards - and it's not due to the calibration algorithm itself.

_________________
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)}


Thu Jan 22, 2009 3:55 pm
Profile
Rookie

Joined: Wed Jan 14, 2009 3:14 am
Posts: 16
Post Re: HT Color sensor: -> calibrating?
Ford Prefect wrote:
yes, correct.
the reason why RobotC calibration programs don't work, are incompatibilities of the RobotC I²C driver libraries and intrinsics with the Hitechnic and Lego standards - and it's not due to the calibration algorithm itself.


Well for sure I don't know much about RobotC but couldn't the problem be with the sample code you're trying? Shouldn't the line

_data[1] = _link;

be

_data[1] = 0x02;

Here is my simple calibration routine

Code:
typedef struct
{
  byte nMsgSize;
  byte nDeviceAddress;
  byte nRegisterIndex;
  byte nData;
} TI2C_Output;

void CalibrateColorSensor(tSensors ColorSensor, int Mode)
{
  TI2C_Output sOutput;

  switch(Mode)
  {
    // white point calibration
    // sensor should be positioned about a half inch above a white surface
     case 1:
      sOutput.nData = 0x43; // white calibration
      break;

    // black point calibration
    // sensor should be pointed in a direction with no near objects
    case 2:
      sOutput.nData = 0x42; // black point calibration
      break;

    default:
      return;
  }
  sOutput.nMsgSize = 3;
  sOutput.nDeviceAddress = 0x02;
  sOutput.nRegisterIndex = 0x41;
  sendI2CMsg(ColorSensor, sOutput.nMsgSize, 0);
  return;
}


I haven't tested this yet as under my current lighting conditions my sensor reads a white as 17. I'm guessing you won't want to test it on yours either given its newly calibrated condition.


Fri Jan 23, 2009 2:13 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3163
Location: Rotterdam, The Netherlands
Post Re: HT Color sensor: -> calibrating?
You are right, setting the address to _link will definitely cause a failure :)

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 Jan 23, 2009 4:14 am
Profile WWW
Rookie

Joined: Wed Jan 14, 2009 3:14 am
Posts: 16
Post Re: HT Color sensor: -> calibrating?
mightor wrote:
You are right, setting the address to _link will definitely cause a failure :)

Xander


Well someday I'll get up the gumption to test it out. I really didn't trust chalking this up to differences in standards and driver libraries.


Fri Jan 23, 2009 10:11 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post Re: HT Color sensor: -> calibrating?
Sorry guys, I still feel like your doing something wrong.....

Have you guys tried using other I2C buss settings other than HiTechnic Color? If you can find another buss setting that works, maybe the HiTechnic Color setting should have the same specs and you can let Dick know.

Id try I2C custom just to see, stay away from the fast ones. Cant hurt anything to try.

Scott B-)

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Sun Feb 08, 2009 3:37 pm
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
hi.
is there now a (tested) calibrating routine for RobotC or not?
(I woudn't like to uncalibrate my new enjusted sensor just for a test...)

_________________
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 Mar 08, 2009 9:49 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3163
Location: Rotterdam, The Netherlands
Post Re: HT Color sensor: -> calibrating?
I have a program for it now :)

Usual charge applies, of course. I'll keep checking my bank statements. KKTHX

Regards,
Xander "I'm gonna be rich!!" Soldaat

Just kidding. This should do the trick for you :)

Just so you know I am working very hard on a driver suite that will include the following:
* ALL of the HiTechnic sensors, including their less frequently used functionality (like calibration)
* NXT Cam
* MAX127 ADC
* MCP23008

All of them will be heavily documented with examples. They all share common code to reduce size. Stay tuned!

For some reason I can't attach files to my posts, so I'll have to paste it in:
Code:
#pragma config(Sensor, S1,     HTCS_PORT,           sensorI2CCustomStd)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*
    Name: HTCS-calibrate.c
    Author: Xander Soldaat
    Date: 05/02/2009
    Version: 0.2
    Contact: mightor_at_gmail.com

    Address      Type      Contents
      00 - 07H   chars      Sensor version number
      08 - 0FH   chars      Manufacturer
      10 - 17H   chars      Sensor type
      18 - 3DH   bytes      Not used
      3E, 3FH      chars      Reserved
      40H            byte      Not used
      41H            byte      Reserved
      42H            byte      Color number
      43H            byte      Red reading
      44H            byte      Green reading
      45H            byte      Blue reading

    More information is available at www.hitechnic.com or by email at support@hitechnic.com
*/

byte cmdbuff[4];
byte reply[8];
byte _tmp;

task main() {

  while (nI2CBytesReady[HTCS_PORT] > 0)
    readI2CReply(HTCS_PORT, _tmp, 1);

  while(nI2CStatus[HTCS_PORT]== STAT_COMM_PENDING)
  wait1Msec(2);

  cmdbuff[0] = 2;                           // Number of bytes in I2C command
  cmdbuff[1] = 0x02;                        // I2C address of colour sensor
  cmdbuff[2] = 0x10;                        // Set write address to calibration register

  sendI2CMsg(HTCS_PORT, cmdbuff[0], 8);
  while(nI2CStatus[HTCS_PORT]== STAT_COMM_PENDING)
    wait1Msec(2);

  eraseDisplay();
  if (nI2CStatus[HTCS_PORT] != NO_ERR) {
    nxtDisplayTextLine(1, "ERROR: Couldn't");
    nxtDisplayTextLine(2, "talk to sensor.");
    nxtDisplayTextLine(4, "Check connection");
    nxtDisplayTextLine(5, "and try again.");
    PlaySound(soundException);
    while(bSoundActive);
    wait1Msec(5000);
    StopAllTasks();
  }

  readI2CReply(HTCS_PORT, reply[0], 8);

  cmdbuff[0] = 3;                           // Number of bytes in I2C command
  cmdbuff[1] = 0x02;                        // I2C address of colour sensor
  cmdbuff[2] = 0x41;                        // Set write address to calibration register
  cmdbuff[3] = 0x43;                        // The data to be written

  eraseDisplay();
  nxtDisplayTextLine(2, "Calibr. %s", reply);
  PlaySound(soundFastUpwardTones);
  while(bSoundActive);
  sendI2CMsg(HTCS_PORT, cmdbuff[0], 0);    // Send command to protoboard
  wait1Msec(1000);
  if (nI2CStatus[S1] == ERR_COMM_BUS_ERR) {
    nxtDisplayTextLine(1, "ERROR: Couldn't");
    nxtDisplayTextLine(2, "calibrate sensor.");
    nxtDisplayTextLine(4, "Check connection");
    nxtDisplayTextLine(5, "and try again.");
    PlaySound(soundException);
    while(bSoundActive);
    wait1Msec(5000);
    StopAllTasks();
  } else {
    nxtDisplayTextLine(4, "Done");
    PlaySound(soundBeepBeep);
    while(bSoundActive);
  }
  wait1Msec(1000);
}

_________________
| 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 Mar 08, 2009 10:02 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3163
Location: Rotterdam, The Netherlands
Post Re: HT Color sensor: -> calibrating?
I've tested this program with my own sensor and it works like a charm. Before calibration the readings tended towards the green. After I ran the program, the readings were perfect.

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 Mar 10, 2009 1:05 pm
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: HT Color sensor: -> calibrating?
fine, thank you! (since when have you got a color sensor? ;)
so I won't have to ship my sensor each time for calibrating to the U.S. any more. :P

what about Royalties from the R.C.C. and the H.T.C. for your 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)}


Tue Mar 10, 2009 3:29 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 57 posts ]  Go to page Previous  1, 2, 3, 4

Who is online

Users browsing this forum: No registered users and 1 guest


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.