| 1 | |
|---|
| 2 | <!DOCTYPE html |
|---|
| 3 | PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|---|
| 4 | <html><head> |
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
|---|
| 6 | <!-- |
|---|
| 7 | This HTML is auto-generated from an M-file. |
|---|
| 8 | To make changes, update the M-file and republish this document. |
|---|
| 9 | --><title>CalibrateColor</title><meta name="generator" content="MATLAB 7.9"><meta name="date" content="2009-10-07"><meta name="m-file" content="script_CalibrateColor"> |
|---|
| 10 | <link type="text/css" rel="stylesheet" href="../../style.css"> |
|---|
| 11 | </head><body><div class="content"><h1>CalibrateColor</h1><!--introduction--><p>Enables calibration mode of the HiTechnic color sensor</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#2">Syntax</a></li><li><a href="#5">Description</a></li><li><a href="#10">Example</a></li><li><a href="#12">See also</a></li><li><a href="#14">Signature</a></li></ul></div><h2>Syntax<a name="2"></a></h2><p><tt>CalibrateColor(port, mode)</tt></p><p><tt>CalibrateColor(port, mode, handle)</tt></p><h2>Description<a name="5"></a></h2><p>Calibrate the color sensor with white balance and black value. I don't know whether calibration of color sensor makes sence Hitech doku says nothing, some internet freaks say it is necessary, but it works and has effect ;-) The sensor LEDs make a short flash after successful calibration. When calibrated, the sensor keeps this information in non-volatile memory. There are two different modes for calibration: <tt>mode</tt> = 1: white balance calibration Puts the sensor into white balance calibration mode. For best results the sensor should be pointed at a diffuse white surface at a distance of approximately 15mm before calling this method. After a fraction of a second the sensor lights will flash and the calibration is done. <tt>mode</tt> = 2: black level calibration Puts the sensor into black/ambient level calibration mode. For best results the sensor should be pointed in a direction with no obstacles for 50cm or so. This reading the sensor will use as a base level for other readings. After a fraction of a second the sensor lights will flash and the calibration is done. When calibrated, the sensor keeps this information in non-volatile memory.</p><p>The color sensor has to be opened (using <tt>OpenColor</tt>) before execution.</p><p>The given <tt>port</tt> number specifies the connection port. The value <tt>port</tt> can be addressed by the symbolic constants <tt>SENSOR_1</tt> , <tt>SENSOR_2</tt>, <tt>SENSOR_3</tt> and <tt>SENSOR_4</tt> analog to the labeling on the NXT Brick.</p><p>The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call <tt>COM_SetDefaultNXT</tt> to set one).</p><h2>Example<a name="10"></a></h2><pre class="codeinput"> <span class="comment">% color must be open for calibration</span> |
|---|
| 12 | OpenColor(SENSOR_2); |
|---|
| 13 | |
|---|
| 14 | <span class="comment">% white calibration mode</span> |
|---|
| 15 | CalibrateColor(SENSOR_2, 1); |
|---|
| 16 | <span class="comment">% pause for changing position</span> |
|---|
| 17 | pause(5); |
|---|
| 18 | <span class="comment">% black calibration mode</span> |
|---|
| 19 | CalibrateColor(SENSOR_2, 2); |
|---|
| 20 | </pre><h2>See also<a name="12"></a></h2><p>OpenColor, GetColor, CloseSensor</p><h2>Signature<a name="14"></a></h2><div><ul><li><b>Author:</b> Rainer Schnitzler, Linus Atorf (see AUTHORS)</li><li><b>Date:</b> 2008/08/01</li><li><b>Copyright:</b> 2007-2009, RWTH Aachen University</li></ul></div><p class="footer"><br> |
|---|
| 21 | </p></div><!-- |
|---|
| 22 | ##### SOURCE BEGIN ##### |
|---|
| 23 | %% CalibrateColor |
|---|
| 24 | % Enables calibration mode of the HiTechnic color sensor |
|---|
| 25 | %% |
|---|
| 26 | %% Syntax |
|---|
| 27 | % |CalibrateColor(port, mode)| |
|---|
| 28 | %% |
|---|
| 29 | % |CalibrateColor(port, mode, handle)| |
|---|
| 30 | %% |
|---|
| 31 | %% Description |
|---|
| 32 | % Calibrate the color sensor with white balance and black value. |
|---|
| 33 | % I don't know whether calibration of color sensor makes sence |
|---|
| 34 | % Hitech doku says nothing, some internet freaks say it is necessary, |
|---|
| 35 | % but it works and has effect ;-) The sensor LEDs make a short flash |
|---|
| 36 | % after successful calibration. When calibrated, the sensor keeps this |
|---|
| 37 | % information in non-volatile memory. |
|---|
| 38 | % There are two different modes for calibration: |
|---|
| 39 | % |mode| = 1: white balance calibration |
|---|
| 40 | % Puts the sensor into white balance calibration mode. For best results |
|---|
| 41 | % the sensor should be pointed at a diffuse white surface at a distance |
|---|
| 42 | % of approximately 15mm before calling this method. After a fraction of |
|---|
| 43 | % a second the sensor lights will flash and the calibration is |
|---|
| 44 | % done. |
|---|
| 45 | % |mode| = 2: black level calibration |
|---|
| 46 | % Puts the sensor into black/ambient level calibration mode. For best |
|---|
| 47 | % results the sensor should be pointed in a direction with no obstacles |
|---|
| 48 | % for 50cm or so. This reading the sensor will use as a base level for |
|---|
| 49 | % other readings. After a fraction of a second the sensor lights will |
|---|
| 50 | % flash and the calibration is done. When calibrated, the sensor keeps |
|---|
| 51 | % this information in non-volatile memory. |
|---|
| 52 | %% |
|---|
| 53 | % The color sensor has to be opened (using |OpenColor|) before execution. |
|---|
| 54 | %% |
|---|
| 55 | % The given |port| number specifies the connection port. The value |port| can be |
|---|
| 56 | % addressed by the symbolic constants |SENSOR_1| , |SENSOR_2|, |SENSOR_3| and |SENSOR_4| |
|---|
| 57 | % analog to the labeling on the NXT Brick. |
|---|
| 58 | %% |
|---|
| 59 | % The last optional argument can be a valid NXT handle. If none is |
|---|
| 60 | % specified, the default handle will be used (call |COM_SetDefaultNXT| to |
|---|
| 61 | % set one). |
|---|
| 62 | %% |
|---|
| 63 | %% Example |
|---|
| 64 | % color must be open for calibration |
|---|
| 65 | OpenColor(SENSOR_2); |
|---|
| 66 | |
|---|
| 67 | % white calibration mode |
|---|
| 68 | CalibrateColor(SENSOR_2, 1); |
|---|
| 69 | % pause for changing position |
|---|
| 70 | pause(5); |
|---|
| 71 | % black calibration mode |
|---|
| 72 | CalibrateColor(SENSOR_2, 2); |
|---|
| 73 | %% |
|---|
| 74 | %% See also |
|---|
| 75 | % OpenColor, GetColor, CloseSensor |
|---|
| 76 | %% |
|---|
| 77 | %% Signature |
|---|
| 78 | %% |
|---|
| 79 | % * *Author:* Rainer Schnitzler, Linus Atorf (see AUTHORS) |
|---|
| 80 | % * *Date:* 2008/08/01 |
|---|
| 81 | % * *Copyright:* 2007-2009, RWTH Aachen University |
|---|
| 82 | % |
|---|
| 83 | |
|---|
| 84 | ##### SOURCE END ##### |
|---|
| 85 | --></body></html> |
|---|