Clock Pulses to device on shield

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
flounder
 
Posts: 494
Joined: Wed Sep 18, 2013 9:10 pm

Clock Pulses to device on shield

Post by flounder »

I will be using a protoshield to connect a photosensor array to an Arduino. What I need is a 10KHz clock (max) to clock the data out; it may be necessary to slow this clock down. There is a 20ns setup and hold time before the rising edge of this clock during which time I must raise a signal line, then drop it. The pulse width on this signal line may not exceed 1/clock, and ideally be 1/(2*clock), max.

What is the best way to get a clock with constant frequency from the board? And how do I guarantee that the one pulse I must deliver meets the setup, hold, and duration requirements of the part? I must also read the analog input pin at a certain minimum time delay (ts, in the spec sheet) after every clock rising edge, and complete that reading before the next rising edge. The spec sheet suggests to me that reading the data on the clock falling edge might be the easiest point to do this; thus, the clock must not run faster than the analog input settling time (or, more precisely, half of that duration, assuming symmetric high and low times on the clock). The part looks like an 896-long (analog) shift register (two 448-bit registers wired in series), and the "start readout" pulse may not arrive more than 897 clocks apart. I could wire SO2 to an interrupt pin to indicate completion of a cycle.

The clock frequency will be dominated by the analog input pin settling time, and once set, will not change. The interval between start pulses is critical (it is the signal integration time) and must be settable in software; too short, and "on" levels will not be high enough to look like saturation, too long, and "off" levels (which are actually reduced intensity, rather than zero intensity) can saturate. Too irregular, and the signals will not be reliable reading-to-reading.

For reference, the part is a TLS2014 sensor array, http://www.ams.com/eng/content/download ... 749/142522

Please note that I am a highly-experienced programmer (50+ years) and the idea of possibly having to write interrupt-driven assembly code is not terrifying, but would be, at worst, "inconvenient", because I don't know the Arduino architecture. I would like to avoid doing it, if possible. Note that on a "bare" machine of many architectures I have worked on (6800, 6502, Z80, 8088, x86, 68x00) I would know how to code it, but the Arduino using Processing is a bit of a mystery as to the best approach.

Suggestions for approaches, or pointers to code samples that illustrate techniques, would be appreciated.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Clock Pulses to device on shield

Post by adafruit_support_mike »

If you don't want to use interrupts, the 'micros()' function is probably your next best bet. That returns the number of microseconds the code has been running, accurate to 4us on a 16MHz Arduino and 8us on an 8MHz unit.

With that, you can use an unrolled timing loop similar to "Blink Without Delay": http://arduino.cc/en/Tutorial/BlinkWithoutDelay

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”