Multiple TCS230 Color Sensors


my setup follows:


  • 5 x tcs230 color sensors (http://www.dx.com/p/tcs230-color-sensor-detector-module-for-arduino-148739?item=1#.wy7i9ilbouu)
  • 3 x cd74hc4067 multiplexers (https://eckstein-shop.de/sparkfun-analog-digital-mux-breakout-cd74hc4067)
  • majicdesign's library (https://github.com/majicdesigns/md_tcs230)


i'm trying use 5 color sensors @ same time, i'm not sure wiring / setup. wiring looks this:

  • all s2 pins sensors multiplexed , connectes pin 12
  • all s3 pins sensors multiplexed , connectes pin 13
  • all out pins sensors multiplexed , connectes pin 5
  • all s0-s3 of multiplexers connected pin 1-4


with code / setup values of sensors seem depend on each other - if hold white card in front of reader0, values of other readers change accordingly (and randomly).

this code i'm trying use:

code: [select]

#include <md_tcs230.h>
#include <freqcount.h>

// pin definitions
#define color_s2  12          // s2 pins colorsensors bundled here
#define color_s3  13          // s3 pins colorsensors bundled here
#define color_oe   8          // oe pins colorsensors bundled here
#define color_out  5          // out-pins colorsensors bundled here
#define m_out_0    1          // controll pins s0 multiplexers
#define m_out_1    2          // controll pins s1 multiplexers 
#define m_out_2    3          // controll pins s2 multiplexers
#define m_out_3    4          // controll pins s3 multiplexers

const int nrsensors = 5;
md_tcs230 cs(color_s2, color_s3, color_oe);


void setup() {
  serial.begin(9600);
  pinmode(m_out_0, output);
  pinmode(m_out_1, output);
  pinmode(m_out_2, output);
  pinmode(m_out_3, output);

  cs.begin();
}

void loop() {
  readsensors();
}


void readsensors()
{

  (int = 0; < nrsensors; i++) {
    digitalwrite(m_out_0, bitread(i, 0));
    digitalwrite(m_out_1, bitread(i, 1));
    digitalwrite(m_out_2, bitread(i, 2));
    digitalwrite(m_out_3, bitread(i, 3));

    static  bool  waiting;
    if (!waiting)
    {
      cs.read();
      waiting = true;
    }
    else
    {
      if (cs.available())
      {
        colordata  rgb;
        cs.getrgb(&rgb);
        serial.print("sensor ");
        serial.print(i);
        serial.print("rgb [");
        serial.print(rgb.value[tcs230_rgb_r]);
        serial.print(",");
        serial.print(rgb.value[tcs230_rgb_g]);
        serial.print(",");
        serial.print(rgb.value[tcs230_rgb_b]);
        serial.println("]");
        waiting = false;
        delay(50);
      }
    }
  }
}



i not sure oe pins of sensors , appreciate help.
i tried connecting oe pins gnd , used md_tcs230 cs(color_s2, color_s3). tried connecting oe pins pin 8, using md_tcs230 cs(color_s2, color_s3, color_oe); or multiplexing them - nothing worked. guess shows, how little understand, oe pins there for.

if point me in right direction, i'd appreciate much.
thanks in advance!

the first thing test devices work on own. verifies setup respect pins , frequency detection. if not work mux setup not work also.

the oe active low input sensor enables output sensor. datasheet "output enable (oe) places output in high-impedance state multiple-unit sharing of microcontroller input line." in other words, oe enable frequency output of sensor many sensors can connected same microcontroller input. high impedance state allows outputs connected without being damaged.

your code can turn off current oe (set digital output high) , turn on output next sensor (digital output low), take reading, , flow on down line. implies there no need mux @ all.


Arduino Forum > Using Arduino > Sensors > Multiple TCS230 Color Sensors


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts