Problem interfacing TSL1401CL line sensor and Arduino Due

Hello everyone,

I am trying to interface my Arduino Due with a line scan sensor, the TSL1401CL. The sensor is a 128-pixels optical sensor with 2 digital control inputs and an analog output. It is soldered to a PCB of my own’s design, which is basically just used for simple housing and connection (the schematic is attached). This is NOT the Line Scan Camera module based on the same sensor.

I based my code on this project: http://playground.arduino.cc/Main/TSL1402 , however I had to apply some changes since this project’s code refer to another sensor of the same family, with two 64-pixel arrays.

The output of my code is a string with all 128 pixel values separated by semicolons ( ; ). New line corresponds to a new sweep.

My problem is that the code is not working properly:
when I start reading the measurements through serial, I get very low values, about 16-17 (max=4096), which is maybe ok as a low-level + offset (this happens in daylight in my office). Problem is there is no change in pixel data if I sweep my finger on the sensor to cover it, or if I point a small red laser dot on it.

The only type of feedback I get from the sensor is when I use my mobile phone as a flashlight and place it right over the sensor. In this case, the sensor’s output rapidly oscillated and goes to saturation in the time of a few seconds. It does not recover from saturation unless I unplug and reconnect the Due’s USB supply.

I am quite sure that the board is working correctly, it is basically just the sensor and a connector, and the sensor is drawing the right amount of supply current. Also, the fact that the sensors responds to strong light, albeit in a strange way, seems to indicate that the problem is not in the hardware.

Can someone take a look at my code and see if there is any obvious error I overlooked? I checked on the internet other versions of the code for making this sensor work with Arduino, but I cannot seem to find the problem.

Thanks!

Here is my current code:

#define AOpin  A1     
#define SIpin  10     
#define CLKpin 13     

int IntArray[128]; 

void setup() {


  analogReadResolution(12);

  pinMode(CLKpin, OUTPUT); 
  pinMode(SIpin, OUTPUT); 
  pinMode(A0, INPUT);

  digitalWrite(SIpin, LOW);   
  digitalWrite(CLKpin, LOW);  

  for(int i=0;i<= 128;i++)
  { ClockPulse(); }

    delayMicroseconds(1);
    digitalWrite(SIpin, HIGH);
    delayMicroseconds(1);     
    digitalWrite(CLKpin, HIGH);
    delayMicroseconds(1);   
    digitalWrite(SIpin, LOW);
    delayMicroseconds(1);
    digitalWrite(CLKpin, LOW);
  
  for(int i=0;i<= 128;i++)
  { ClockPulse(); }

  Serial.begin(115200);

}

void loop() {
  
      // SI (start integration) signal and first CLK pulse:   
        delayMicroseconds(1);
        digitalWrite(SIpin, HIGH);
        delayMicroseconds(1);     
        digitalWrite(CLKpin, HIGH);
        delayMicroseconds(1);   
        digitalWrite(SIpin, LOW);
        delayMicroseconds(1);
        digitalWrite(CLKpin, LOW);
      
      for(int i=0; i <= 127; i++)
      {        
          delayMicroseconds(20);  
          IntArray[i] = analogRead(AOpin);         
          ClockPulse(); 
      }
       
      for(int i = 0; i <= 127; i++)
      {        
        Serial.print(IntArray[i]); Serial.print(";"); 
      }
      
      Serial.println(""); 

}

void ClockPulse()
{
  delayMicroseconds(1);
  digitalWrite(CLKpin, HIGH);
  delayMicroseconds(1);
  digitalWrite(CLKpin, LOW);
}

I live the same problem myself, if you have found a solution, help me.

Hi,

I´ve experienced a similar problem.
Try to not print the values to the Terminal (basically just comment the corresponding for loop out) and look at an oscilloscope. It this betters your results, try to raise your Baudrate until it works well.
It is also possible that your Integration Time is too short, refer to the TLS1401CL Datasheet for more info about that.

I hope i could help you with your problem you seem to have over a year now and you now can, finally, sleep in peace and freedom :slight_smile:

Regards,
Armin