Color Measurement with TCS3200 Sensor and a Teensy 3.2 Board

  • Thread starter BestOutOfBubbleSort
  • Start date
Status
Not open for further replies.
B

BestOutOfBubbleSort

Guest
Hey,
I'm working on a project in which I want to detect the color from objects passing by a sensor. I'm using 8 TCS3200 Color Sensors each of them are placed in one pipe. The objects are 2 - 3 meters per second fast. The output of the color sensor is a square wave (50% duty cycle) with frequency directly proportional to light intensity. The peak duration changes depending on the color of the passing object. Thats why I need to measure the frequency in microseconds continously and parallel for the 8 sensors. I'm currently using an Arduino Uno Board, which is not capable of that :(
Then I found the Teensy 3.1/2 Board with which I could solve my problem using the FreqMeasureMulti Library. Before I order the Board I wanted to ask , if it would function as I imagined and which Teensy Board you would recommend.

Here the Datasheet from the sensor http://image.dfrobot.com/image/data/SEN0101/TCS3200%20TCS3210.pdf
 
You might want to consider some sort of hardware peak detector on each color output and clock it with another sensor that just reads the presence of the object.
 
FreqMeasureMulti has a fair amount of overhead. If you stick with a 10kHz full scale frequency, it will be fine (with all Teensy 3.x).

8 channels at 100kHz won't work. FreqMeasureMulti always captures both signal edges (even if it doesn't record them), so you would have a worst case 100'000 * 8 * 2 = 1'600'000 interrupts per second - Teensy won't handle that.

By pairing up timer channels, the input capture could be done entirely without interrupts and you could process any frequency you want. Teensy 3.5 / 3.6 have enough timer channels to do that (you need 2 * 8), Teensy 3.2 doesn't.
 
tni, please describe (hardware wise) how capture is done without CPU time?
What types of signals (logic level only?) can be captured and where (and how) is the data stored?
 
tni, please describe (hardware wise) how capture is done without CPU time?
In the sketch in #4, the timer value registers (FTM1_C0V, FTM1_C1V) are continuously updated with the latest time measurement of (rising edge 1, rising edge 2).

What types of signals (logic level only?) can be captured and where (and how) is the data stored?
Normally it's logic level. But the MCU also has comparators (manual, chapter 'Comparator (CMP)') that can be configured to trigger the timer (look at the manual, 'System Options Register 4 (SIM_SOPT4)').

The sketch #4 only periodically samples the captured (FTM1_C0V, FTM1_C1V) values. The DMA version in #3 continuously transfers them into a ring buffer.
 
Thanks for the answers. Currently I'm getting approximately 6000 Measurements per second by using the pulseIn(OUT, LOW) method from the Arduino library. The measurements are spreading between 40 for white and 93 for black. I'm not switching between the color channels, in this case I'm using the blue photodiode type and I set the scaling from the sensor to 20%. (With a full scaling 100% the peak duration are between 0 and 35). The pulseIn() returns the length of the pulse in microseconds. This accuracy is not optimal, but it's enough to seperate two objects from each other and the background, which is black in my case.
I read your code, it's a bit to hard for me to understand all lines :p . First I'll try it with the FreqMeasureMulti library. Do you know how much the overhead FreqMeasureMulti would have in my case? When it doesnt functions I'll give the hardwarebased solution a try.
 
I read your code, it's a bit to hard for me to understand all lines :p .
You need to read the FTM documentation a few times.

First I'll try it with the FreqMeasureMulti library. Do you know how much the overhead FreqMeasureMulti would have in my case?
With 6000Hz, it will be fine, even if you have several sensors. As a rough estimate, you can expect FreqMeasureMulti to use 1us CPU time per signal edge.
 
Status
Not open for further replies.
Back
Top