0

So I have a line scan camera attached to my Arduino Mega and I'm trying to send it a digital clock impulse and get an analog output back. The line scan camera is supposed to return 128 pixels.

So far I've been able to send the impulses and get analog values back which I am printing out. However, the values are different every time, which doesn't make sense because the camera didn't move so I assume that it should give back similar numbers.

Also, is there a way to determine what these numbers mean? Is there some way of turning analog signals into color pixels? My ultimate goals is to be able to determine if something has moved through the vision of the line scanner

Here is the datasheet for the line scanner: http://www.farnell.com/datasheets/315815.pdf

Here is my code:

void loop() {

  int delayTime = 20;
  digitalWrite(syncPin, HIGH);
  delayMicroseconds(delayTime);
  digitalWrite(clockPin, HIGH);
  delayMicroseconds(delayTime);
  digitalWrite(syncPin, LOW);
  delayMicroseconds(delayTime);
  digitalWrite(clockPin, LOW);
  delayMicroseconds(delayTime);

  for (int i = 0; i < 128; i++)
  {
    digitalWrite(clockPin, HIGH);
    pixelValue[i] = analogRead(dataPin);
    delayMicroseconds(delayTime);
    digitalWrite(clockPin, LOW);
    delayMicroseconds(delayTime);
  }

  digitalWrite(clockPin, HIGH);
  delayMicroseconds(delayTime);
  digitalWrite(clockPin, LOW);
  delayMicroseconds(delayTime);

  for (int j = 0; j < 128; j++)
  {
    Serial.print("I received: ");
    Serial.println(pixelValue[j]);
  }

}

1 Answers1

2

First, a preliminary note: according to the datasheet, the only time you need a delay in your program is after reading the whole array and before sending the next sync pulse. All the other timing requirements are shorter than a single CPU cycle of your Mega, so no need to add extra delays.

the camera didn't move so I assume that it should give back similar numbers.

Similar: yes. Identical: no. You expect noise to make every reading slightly different, and you also will have variations due to uneven timing of your program (e.g. the timer interrupt kicking in from time to time).

is there a way to determine what these numbers mean?

They are proportional to the amount of light collected by each pixel. That's about all you know about their meaning.

Is there some way of turning analog signals into color pixels?

No. This is a B&W camera.

Edgar Bonet
  • 45,094
  • 4
  • 42
  • 81