Trace: » timings
Back to neurospy for developers
Direct Digital Synthesis timings
Contributed by Dejan Vučinić
Conclusions for the impatient:
- There is a fixed 80 microsecond overhead to send one pre-formatted sequence of scanning commands from Java; the shortest round-trip time until the USB write() returns control to the program is close to 300 microseconds.
- There is no point performing a single-packet scan shorter than 50 microseconds; shorter scans must be arranged intra-packet, in which case all the commands must be aligned on the 512 boundary to get accurate timings.
This page discusses hardware limitations on how fast one can scan an acousto-optic deflector by using an AD9959 Direct Digital Synthesis chip and neurospy. The physics of fast scanning with acousto-optic deflectors is discussed at length in other articles.1), 2)
The measurements below were done with neurospy firmware version 5 and Scanner-AD9959 module from October 11th, 2007. All the measurements were done on the scanning subsystem only, there was no communication with the digitizer. These are, therefore, the absolute limits on how fast one can command the DDS chip with the hardware described.
The Cypress 68013 firmware neurospy uses to communicate with the AD9959 chip is very simple: it receives 512-byte packets over the USB bus and writes them to the AD9959 pins as fast as possible. The time it takes to write out one 512-byte packet is in the vicinity of twenty microseconds, depending on the selection of clock frequency, but there is an additional overhead in the controller when switching between packets.
Starting with firmware version 5, at the beginning of every packet a handshake can be added that tells the USB controller to idle a certain number of cycles after the packet is written out. This makes it easy to send a series of longer sweeps of arbitrary durations without having to keep sending “idler” packets for the duration of the sweep. Therefore, to send a series of line scans to get a full frame, each line requires only 512 bytes to be sent over the USB bus regardless of how long it takes to scan it.
Here is a plot of the time between the starts of two subsequent packets as a function of the number of “idler” cycles requested, as seen on the oscilloscope:
Therefore, one cycle adds 1.42 microseconds to the delay between packets, 13.72 microseconds are wasted by the controller switching between the packets, and the fastest one can go is around one packet every thirty-odd microseconds.
Now let's add neurospy to the mix. The fastest one can send packets out is right around fifty microseconds per:
This is a function of the controller overhead, but also of USB clock timing (new packets are only sent every 125 microseconds if there's room in the buffer on the controller) and the fixed overhead of sending the scan commands from Java, which is made evident by this measurement:
Therefore, 80 microseconds are spent setting up the transfer from Java to USB, and the shortest round-trip time for the transfer to return control to the program is close to 300 microseconds (220 of which happens after the scan has started).


