Skip to content

Separate undershoot and scan phase adjustment#30

Draft
marktsuchida wants to merge 2 commits into
mainfrom
scan-phase
Draft

Separate undershoot and scan phase adjustment#30
marktsuchida wants to merge 2 commits into
mainfrom
scan-phase

Conversation

@marktsuchida
Copy link
Copy Markdown
Member

These are two separate adjustments (time for scanner to settle into linear motion vs compensation for command-scanner lag), and it works better to have individual adjustments.

Also decouple the scan waveform sample frequency from the pixel rate, and make the retrace duration scale with amplitude. These refactorings were easier to do in one step.

Clock output, for now, uses aoRateHz. In the future it might make sense for it to follow detector acquisition instead.

The default values of the new parameters preserve behavior for 256x256, 200kHz, zoom=1.

Remove DumpWaveform rather than maintain it, because we now have WaveformTool and waveform_viewer.py (which are updated here).

These are two separate adjustments (time for scanner to settle into
linear motion vs compensation for command-scanner lag), and it works
better to have individual adjustments.

Also decouple the scan waveform sample frequency from the pixel rate,
and make the retrace duration scale with amplitude. These refactorings
were easier to do in one step.

Clock output, for now, uses aoRateHz. In the future it might make sense
for it to follow detector acquisition instead.

The default values of the new parameters preserve behavior for 256x256,
200kHz, zoom=1.

Remove DumpWaveform rather than maintain it, because we now have
WaveformTool and waveform_viewer.py (which are updated here).

(Assisted by Claude Code; any errors are mine.)
@marktsuchida
Copy link
Copy Markdown
Member Author

marktsuchida commented Apr 7, 2026

Might need to rethink this, because completely decoupling scan waveform sample rate from detector pixel rate might not actually be feasible, at least when we want to generate accurate line/frame clocks.

  • If we use the AO sample rate for the line/frame clocks (as done here), they can be a fraction of a pixel time off at line end.
  • If we use the AI sample rate for the line/frame clocks, triggering the frame clock will require using an additional counter, which is doable but a bit wasteful (NI 6356 does have 4 counters). And complicated.

So maybe we should require an integer multiple between AO/AI sample rates, or auto-choose the AO sample rate based on the desired AI rate, etc.

@marktsuchida marktsuchida mentioned this pull request May 21, 2026
The AO scan waveform and the line/frame clocks are produced on the AO
sample grid, but the detector acquires pixels on the pixel grid. With
the AO rate an independent setting, the per-line scan window didn't
exactly equal the acquisition window: the line clock edge could be a
fraction of a pixel off at line end.

Remove the user setting for AO rate; constrain aoRate = K * pixelRate
for integer K dividing the pixel period in sample clock timebase
(usually 100 MHz) ticks. This makes the AO rate an exact timebase
divisor (keeping the timebase-derived line counter drift-free) and the
scan window an exact integer number of pixels.

Among valid K with the AO rate in [100 kHz, device max], pick the rate
closest to 200 kHz (galvo bandwidth is ~kHz; higher only wastes
memory/CPU), preferring the higher on a tie.

(Assisted by Claude Code; any errors are mine.)
@marktsuchida
Copy link
Copy Markdown
Member Author

require an integer multiple between AO/AI sample rates, or auto-choose the AO sample rate based on the desired AI rate

Did both of those. Not tested yet.

@marktsuchida marktsuchida mentioned this pull request May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant