0
\$\begingroup\$

I have a custom proof-of-concept project to detect fluid color within a PVC tube coming out of a patient's brain and turbidity (a reduction in light passing through) using an Arduino micro, a TCS3200 sensor, and an LED. The tube sits in a custom housing, and the LED shines from the other side and passes through it.

This is the TCS3200 set inside a PLA dark chamber:

TCS3200

Tube passes through this chamber:

Tube going through the chamber

Very very crude diagram of the setup:

Diagram

I've found out that, interestingly, the sensor output increases nearly fifty-fold when I measure with an LED with low resistance (220 Ω resistor, 5 V) compared to (68 kΩ, 5 V, to obtain 100~ measurements of clear when I'm measuring distilled water).

Here are the recordings over 5 minutes, averaging 7 standardized fluids and the empty tube. Both for 66 kΩ and 200 Ω. I feel like the numbers I'm getting from here are basically noise at 220 Ω.

I also measured absorbance using a standard spectrophotometer and "reversed" it in the color scale to its appropriate color (since absorbance gives the wavelength of blue when the fluid is red, for instance).

Table
Test 0: Empty tube.
Test 1: Distilled water.
Test 2: 1:10 dilution of a yellow drug.
Test 3: 1:100 dilution of a yellow drug.
Test 4: 1:100 dilution of a red drug. (due to the max absorbance of being limited by the spectrophotometer, this is not a good test) Test 5: 1:1000 dilution of a red drug. (The color of the drug got close to yellow at this dilution, effectively leaving me with only two standard fluids)
Test 6: 1:1000 dilution of a blue drug.
Test 7: 1:10k dilution of a blue drug.

I'm using this LED to shine light on the TCS3200 sensor:

LED table

And here is the linearity data for the TCS3200 sensor: ±0.1% for output frequencies between 0 to 5 kHz ±0.2% for output frequencies between 0 to 50 kHz ±0.5% for output frequencies between 0 to 500 kHz

I can see that the values of the low-intensity (68 kΩ) LED light are more in line with the real color and have more sensitivity compared to the 4000~ sensor readings I'm getting.

I don't think the code is exactly relevant, but for completeness sake, here is the color sensor bit:

  void readColor(int &colorCount, int S2State, int S3State) {
  // Setting frequency scaling to 20%
  digitalWrite(S0, HIGH);
  digitalWrite(S1, LOW);

  digitalWrite(S2, S2State);
  digitalWrite(S3, S3State);
  unsigned long startTime = millis();
  colorCount = 0;
  int dynamicMeasurementTime = 50;
  unsigned long currentTime = millis();

  while (currentTime - startTime < dynamicMeasurementTime) {
    int pulseWidth = pulseIn(sensorOut, LOW, pulseTimeout);
    if (pulseWidth > 0) {
      colorCount++;
    }
    currentTime = millis();
  }

My question is, why is it recording this very high, probably filled with noise values when the LED is bright?

Also, what would be a good way to correlate the wavelength readings to the RGB sensor outputs?

\$\endgroup\$
4
  • \$\begingroup\$ What does the datasheet say about linearity? \$\endgroup\$
    – winny
    Commented Aug 15 at 17:26
  • \$\begingroup\$ Do you have a frequency counter? The guaranteed maximum output frequency of the sensor before saturation is documented in the datasheet, and is 10kHz, 100kHz or 500kHz depending on configuration. It would be better to look directly at the raw frequency data for troubleshooting. Most modern oscilloscopes will give you an accurate enough digital display of frequency if you don't have a frequency counter. \$\endgroup\$ Commented Aug 15 at 17:30
  • \$\begingroup\$ I added data about linearity. I'm getting readings every 50ms and a mean of 250 hits in the distilled water recording session, which is the reference value of 5000Hz. Or am I understanding this incorrectly? While I'm getting 4000 in the 220 ohms, which is 80kHz, and thus has less accuracy according to the datasheet. \$\endgroup\$ Commented Aug 15 at 18:03
  • \$\begingroup\$ I can procure an oscilloscope if it is vital to this experiment and your question. \$\endgroup\$ Commented Aug 15 at 18:04

1 Answer 1

1
\$\begingroup\$

The sensor is saturating, the trick will be to figure out why. There are also a few ways to improve your setup.

A few recommendations:

  1. Have an adjustable light source. Ether use a variable resistor, PWM or constant current source. to vary the intensity of the LED. The light is probably too bright and you are on the upper end of the intensity

  2. More broadband light source Something like this where the intensity Vs wavelength is a little more broadband.

enter image description here

https://www.yujiintl.com/wp-content/uploads/2022/03/P3190005.00-2.3-YJ-BC-2835L-G03-4.pdf

  1. Make everything black around the sensor and light source The pcb is still what looks to be white, so you will have some reflections around that, make that black. The edge of the PLA is curved (side facing PCB) block that out also. It's not critical but you'll have a better measurement. Also make sure that light isn't internally reflecting in the pipe.
\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the in-depth response. 1. The value 66k ohm was reached at the end of a session with a potentiometer, there I had no leaking light outside the system and still received about 100-250~ readings per 50ms. This helped a lot: electronics.stackexchange.com/questions/709495/… 2. Wouldn't it be not that important at a low-intensity level? But this makes sense. 3. Okay, I realized this was an oversight while working today. I will be making the hole smaller. \$\endgroup\$ Commented Aug 15 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.