Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Simplify the sequencer table as per PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
rtuck99 committed Aug 7, 2024
1 parent fe546a8 commit 41a6bec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 55 deletions.
36 changes: 7 additions & 29 deletions src/hyperion/device_setup_plans/setup_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ def _get_seq_table(
SEQUENCER TABLE:
1. Wait for physical trigger from motion script to mark start of scan / change of direction
2. Wait for POSA (X2) to be greater than X_START and send 1 trigger
3. Send out the remaining x_steps - 1 triggers every time_between_steps_ms
4. Wait for physical trigger from motion script to mark change of direction
5. Wait for POSA (X2) to be less than X_START + X_STEP_SIZE * x_steps + exposure distance, then
send 1 trigger
6. Send the remaining x_steps - 1 triggers every time_between_steps_ms
7. Go back to step one.
2. Wait for POSA (X2) to be greater than X_START and send x_steps triggers every time_between_steps_ms
3. Wait for physical trigger from motion script to mark change of direction
4. Wait for POSA (X2) to be less than X_START + X_STEP_SIZE * x_steps + exposure distance, then
send x_steps triggers every time_between_steps_ms
5. Go back to step one.
For a more detailed explanation and a diagram, see https://github.com/DiamondLightSource/hyperion/wiki/PandA-constant%E2%80%90motion-scanning
Expand Down Expand Up @@ -92,6 +90,7 @@ def _get_seq_table(

rows.append(
SeqTableRow(
repeats=num_pulses,
trigger=SeqTrigger.POSA_GT,
position=start_of_grid_x_counts,
time1=PULSE_WIDTH_US,
Expand All @@ -101,22 +100,12 @@ def _get_seq_table(
)
)

if num_pulses > 1:
rows.append(
SeqTableRow(
repeats=num_pulses - 1, # account for previous 1 pulse at start
time1=PULSE_WIDTH_US,
outa1=True,
time2=delay_between_pulses - PULSE_WIDTH_US,
outa2=False,
)
)

# -ve direction scan
rows.append(SeqTableRow(trigger=SeqTrigger.BITA_1, time2=1))

rows.append(
SeqTableRow(
repeats=num_pulses,
trigger=SeqTrigger.POSA_LT,
position=end_of_grid_x_counts + exposure_distance_x_counts,
time1=PULSE_WIDTH_US,
Expand All @@ -126,17 +115,6 @@ def _get_seq_table(
)
)

if num_pulses > 1:
rows.append(
SeqTableRow(
repeats=num_pulses - 1, # account for previous 1 pulse at start
time1=PULSE_WIDTH_US,
outa1=True,
time2=delay_between_pulses - PULSE_WIDTH_US,
outa2=False,
)
)

table = seq_table_from_rows(*rows)

return table
Expand Down
28 changes: 2 additions & 26 deletions tests/unit_tests/device_setup_plans/test_setup_panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_setup_panda_correctly_configures_table(
expected_seq_rows: list[SeqRow] = [
SeqRow(1, SeqTrigger.BITA_1, 0, 0, 0, 1, 0),
SeqRow(
1,
x_steps,
SeqTrigger.POSA_GT,
int(params.x_start * MM_TO_ENCODER_COUNTS),
PULSE_WIDTH_US,
Expand All @@ -146,25 +146,13 @@ def test_setup_panda_correctly_configures_table(
0,
),
]
if x_steps > 1:
expected_seq_rows.append(
SeqRow(
x_steps - 1,
SeqTrigger.IMMEDIATE,
0,
PULSE_WIDTH_US,
1,
SPACE_WIDTH_US,
0,
)
)

exposure_distance_counts = exposure_distance_mm * MM_TO_ENCODER_COUNTS
expected_seq_rows.extend(
[
SeqRow(1, SeqTrigger.BITA_1, 0, 0, 0, 1, 0),
SeqRow(
1,
x_steps,
SeqTrigger.POSA_LT,
int(
(params.x_start + (params.x_steps - 1) * params.x_step_size)
Expand All @@ -178,18 +166,6 @@ def test_setup_panda_correctly_configures_table(
),
]
)
if x_steps > 1:
expected_seq_rows.append(
SeqRow(
x_steps - 1,
SeqTrigger.IMMEDIATE,
0,
PULSE_WIDTH_US,
1,
SPACE_WIDTH_US,
0,
)
)

for key in SeqRow._fields:
np.testing.assert_array_equal(
Expand Down

0 comments on commit 41a6bec

Please sign in to comment.