Difference: TCS3200 (7 vs. 8)

Revision 82022-06-28 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

TCS3200 Color Sensor

Introduction

Line: 71 to 71
 
  • @prop_setter, where prop is the name of the property to be set

Towards reading the frequency of the OUT signal

Changed:
<
<
In order to better understand the TCS3200 it is necessary to get a feeling for the frequencies it emits. In order to measure this frequency, we must be able to set the filter and the frequency divider. This is done in the program filter_and_freq.py. The test program sets debugging mode, and it writes and reads back the filter and frequency divider settings.
>
>
In order to better understand the TCS3200 it is necessary to get a feeling for the frequencies it emits. To measure this frequency, we must be able to set the filter and the frequency divider. This is done in the program filter_and_freq.py. The test program sets debugging mode, and it writes and reads back the filter and frequency divider settings.

Reading the raw signal

The outSignal.py application sets up the filter to clear and the frequency divider to 2%. After this, it reads out the raw signal with the method testOut. This method sets up an empty data list named values, and it then polls the OUT line during 100 ms at a sampling frequency of 10 kHz (a sample every 100 us). The data acquired are saved in values and returned by the testOut method. outSignal finally prints out the result. The testOut method has been implemented for test only and is not strictly necessary. However, it gives a visual impression of the signal to be treated and is therefore interesting for a better understanding.

You can save these values to a file on the PC with

ampy run outSignal.py > resultData.txt

and finally, plot the with gnuplot.

Here are the plots when a black and when a white paper is placed in front of the sensor. You clearly see the much higher output frequency for a white paper.

The black paper:

black.png

The white paper

white.png

 

Measuring the frequency

In order to measure the frequency, the time elapsed for the detection of a number of OUT signal cycles is measured. The number of cycles to be used is set in the cycles variable. Of course, we again need getter and setter methods to control _cycles. We attach an interrupt handler to the OUT pin (_cbfwhich stands for _callback function). The number of cycles, already measured, is saved in the _cycle (without the "s"). This value is set to zero when the interrupt handler is started (connected to _cbf). When the first rising edge of the signal is seen, the current system clock in us is saved in _start_tick. For each rising edge of the OUT signal, _cycle is incremented until the value In _cycles is reached, in which case the system clock is saved in _end_tick. The duration between the start of the measurement and the moment the number of requested cycles has been seen is then

Line: 134 to 152
 
META FILEATTACHMENT attachment="d546fed5-1ee1-4daf-9233-1a845b81fe2d.jpg" attr="" comment="" date="1652704089" name="d546fed5-1ee1-4daf-9233-1a845b81fe2d.jpg" path="d546fed5-1ee1-4daf-9233-1a845b81fe2d.jpg" size="25198" user="UliRaich" version="1"
META FILEATTACHMENT attachment="tcs3200Block.png" attr="" comment="" date="1652705272" name="tcs3200Block.png" path="tcs3200Block.png" size="29645" user="UliRaich" version="1"
META FILEATTACHMENT attachment="freq_result.png" attr="" comment="" date="1652713939" name="freq_result.png" path="freq_result.png" size="46112" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="black.png" attr="" comment="" date="1656430651" name="black.png" path="black.png" size="47415" user="UliRaich" version="1"
META FILEATTACHMENT attachment="white.png" attr="" comment="" date="1656430651" name="white.png" path="white.png" size="92279" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback