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]);
  }

}
  • It should be noted that analogRead() causes a delay of at least 104 µs, so the delayMicroseconds() right after it is probably not needed. – Edgar Bonet Jun 3 '16 at 14:22
3

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.

  • That helps a lot, thank you. But even though this is a B&W camera can I still turn the numbers to actual values? – Fortuna Iwasaki Jun 3 '16 at 15:05
  • @FortunaIwasaki: What do you mean by “actual values”? – Edgar Bonet Jun 3 '16 at 15:07
  • Sorry I mean B&W pixels, also can you let me know where in the datasheet you only need the delay after reading the whole array? – Fortuna Iwasaki Jun 3 '16 at 15:14
  • @FortunaIwasaki: You want to turn the numbers into pixels? That doesn't make sense. You want to turn them into pixel values? They are already pixel values. The timings are on page 4, “Timing Requirements”: tql(min) = 20 µs, the other min values are at most 50 ns. – Edgar Bonet Jun 3 '16 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.