Linear CCD

I am thinking about using this Linear CCD ( , TSL1401R-LF) to measure light input in a colorimeter. I am willing to try other methods of input or other sensors; I am not stuck on this one. This sensor has 128x1 sensor elements, it would be nice to have greater resolution, but I do not want to add needless cost and complexity to the project. The sensor should be under $20 USD.

Can I use the PWM output to control the clock on this chip or will I need a separate clock to run this?

Why do you think you need PWM?

I am new to using anything more complicated than an led and blinking.

Would I be able to use a digital output to clock the CCD sensor? And then use another digital output to start the serial output? And then using an analogue input to collect the data from the sensor after the CCD starts to send data out on its Ao.

The suggestion of the app note is that there is a maximum clock speed, but it specifies no minimum, so any digital output should work as a clock.
This looks a bit of a fun way of getting some form of machine vision - I've not seen this device before.

Hi strateego, as you can see in my signature I have just started to interface an TSL214, its an 64x1 array instead.
From what I have seen from datasheets, they are interfaced in pretty much the same way, so the code should work with minor modifications.

As soon as I have a more or less functional code I will post it to github, now I only have a 500kHz clock working using the Timer1 library.

The speed limiting factor is the ADC conversion on the Arduino, clocking with a digital pin is fine. The device can clock at 8MHz without losing much analog precision - but the Arduino ADC conversion time is about 100us if I remember right - certainly around 3 orders of magnitude slower.

Chiva, I was wondering if you had made any progress on your code?

Hi strateego,

Because there wasn't a library to toggle the SI line the way I thought of, I have rewritten the code without the Timer1 library, as I have to study the timers inner workings anyway, so I'm in the same spot, the 500kHz clock, but now hand configured.
The SI line should be now implemented in no time (maybe tomorrow) .

I'm right now documenting the timer configuration I have made, as there is not much info out there.

The code is being uploaded to github: GitHub - chiva/Arduino-CCD-TSL214: Interfacing a TLS214 linear CCD sensor with Arduino , you can follow the development there.
I have a Mega 1280 board, but will keep the code compatible with the 328 (Uno, duemilanove, diecimila, etc.) ones.

Why do you need a 500kHz clock?
have you got some fast external A/D connected to the Arduino?

I only need to read about two samples (every value of the ccd) a second. Would it be easier for me to use the tone function to generated the CLK and use a digital write to trigger the SI line.

I was thinking something like:

setup () {
tone(10, 5000); // Start 5k Hz clk on ccd
pinMode(8, OUTPUT);

loop () {
digital.Write(8, HIGH);
digital.Write(8, LOW); // This would trigger the pulse to start the read
delay(????); // Delay 18 CLK cycles for the ccd to integrate the light
// reading code => array[63] => serial.Print to computer for manipulation.

I'm not sure if this code will work in my situation, but all I need a a couple reads of the sensor per second.
I would imagine that there might be some timing issues with this code.

The read-out rate is limited by the A/D conversion speed of the Arduino
You could generate the clock with simple digitalWrites.

That looks like a neat little device! Oddly enough, exactly what I need for one "answer" to my seismograph project!

A few thoughts....

The 202R...

... appears to be very similar, but with twice the resolution, and not marked "not recommended for new designs". For less than $20, why put time in on something which may become unavailable?

I've only glanced at the datasheet, but I suspect you are too worried about the "clock" signal.

You tell the device "Report what the sensors see", and it then stands by to do just that.

It gives you the 1st bit, the 2nd bit, the 3rd... when YOU are ready, within reason. And you tell it you're ready by toggling the "clock" signal. Within reason, that can be as fast, as slow, or as irregular as you wish. Clock is an output from the Arduino (or other controller), and an input to the linear sensor array....

... if I've understood the chip's operation correctly.

When I went to order the TSL1401R they were out of stock, so I upgraded to the TSL202R. It looks like is two of the 128x1 arrays put on the same package.

It arrived in the mail today, so I will be hooking it up this afternoon. Hopefully I will be able to pull data from it by this evening.

Sorry; I reported that I bought the wrong sensor. I got the TSL1402R which is a 256x1 linear ccd.

This is the code I am using, whenever I type 'O' in the serial console it outputs data. Right now the data output is not what I am expecting.

int analogPin = 0; 
int siPin = 8;
int clkPin = 4;
int sensorValue;
int incomingByte;

void setup() 
  Serial.print("Initalizing Code...\n");
  pinMode(siPin, OUTPUT);
  pinMode(clkPin, OUTPUT);
  Serial.print("Code Initialized\n");

void loop() 
  if (Serial.available() > 0) 
    incomingByte =;
      if (incomingByte == 79) 


void clock()
  digitalWrite(clkPin, HIGH);
  digitalWrite(clkPin, LOW);

void si()
  digitalWrite(siPin, HIGH);
  digitalWrite(clkPin, HIGH);
  digitalWrite(siPin, LOW);
  digitalWrite(clkPin, LOW);

void readSensor()
  Serial.print("\nReading Data From Sensor\n");
  clock(); // Run Clock
  si(); // Trigger Signal
  for ( int i = 0; i < 17; i++ ) // Wait for internal Reset
  for ( int j = 0; j < 255; j++)
    sensorValue = analogRead(analogPin);
  // outputData();

Right now the data output is not what I am expecting

That's helpful.
You were expecting "Dejeuner sur l'herbe"?

I updated the code, and hand toggling the clock line (just sending the control pulses) should take less than 1ms for 64 pixels, but when doing the analog reads, it ramps up to almost 36ms.

It works OK in both cases and output from the CCD is as expected.