how to use a TCD1201D with an arduino UNO
Here a video in action, using 2 black and 1 one red eletrical tape to cover the sensor, and a 5v class3 laser alimented @ 3.3v with a coin battery.
Some days ago, i recived a TCD1201D.
Before buying them i lurked a bit around the internet but i didn’t found many data about them, just some people having problem and others people having better luck.
But because those chip are pretty cheap, and because i like to bang my head against a brick wall try things myself, i decided to buy some and try to get them work.
I must admin that the datasheet is pretty confusing, as in the Timing Chart you don’t get what is really going on, especially when BT and RS need to be switched, and i found better luck redrawing that graph starting from the Timing Requirment, witch gives better particular, but loose the “full vision”.
What is important here is to understand the fact that integration time is really important, that this sensor is potentially hundred time faster that the UNO, BUT it does not seems to have upperlimitation in timing;
obviusly we will try to read it as fast as possible, so we will use directregister manipulation while interrupting the interrupt (ahah) to get better timings.
Also we keep only the 8 LSB of the ADC reading (the chip for normally stand at very low voltage, and because light should DECREASE the output i don’t think to need more.)
This also mean we can easily pack every readingin one byte, so we don’t have to sincronize
the code is pretty straight forward and can be found here for the arduino uno, and here for the processing GUI
here a nice scope of the analog output (yellow) and RS signal (blue), credit to Stefano
and here a little helper to make the connections