Skip to content

Commit

Permalink
Changes to Sequencer table from testing with PandA
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtrafford committed Nov 18, 2024
1 parent 16990ef commit e9387b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions src/ophyd_async/fastcs/panda/_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def __init__(self, seq: SeqBlock, name="") -> None:
self.name = name

async def prepare(self, value: ScanSpecInfo):
await self.seq.prescale_units.set(TimeUnits.us)
await self.seq.enable.set(BitMux.zero)
path = Path(value.spec.calculate())
chunk = path.consume()
Expand All @@ -65,26 +64,31 @@ async def prepare(self, value: ScanSpecInfo):
gaps = np.delete(gaps, 0)
scan_size = len(chunk)

fast_axis = chunk.axes()[len(chunk.axes()) - 2]
gaps = np.append(gaps, scan_size)
fast_axis = chunk.axes()[len(chunk.axes()) - 2]
# Get the resolution from the PandA Encoder?
resolution = await fast_axis.encoder_res.get_value()
start = 0
# Wait for GPIO to go low
rows = SeqTable.row(trigger=SeqTrigger.BITA_0)
for gap in gaps:
# Wait for GPIO to go high
rows += SeqTable.row(trigger=SeqTrigger.BITA_1)
# Wait for position
if chunk.midpoints[fast_axis][gap - 1] > chunk.midpoints[fast_axis][start]:
if (
chunk.midpoints[fast_axis][gap - 1] * resolution
> chunk.midpoints[fast_axis][start] * resolution
):
trig = SeqTrigger.POSA_GT
dir = False
dir = False if resolution > 0 else True

else:
trig = SeqTrigger.POSA_LT
dir = True
dir = True if resolution > 0 else False
rows += SeqTable.row(
trigger=trig,
position=int(
chunk.lower[fast_axis][start]
chunk.midpoints[fast_axis][start]
/ await fast_axis.encoder_res.get_value()
),
)
Expand All @@ -98,15 +102,16 @@ async def prepare(self, value: ScanSpecInfo):
outa1=True,
outb1=dir,
outa2=False,
outb2=False,
outb2=dir,
)

# Wait for GPIO to go low
rows += SeqTable.row(trigger=SeqTrigger.BITA_0)

start = gap
await asyncio.gather(
self.seq.prescale.set(0),
self.seq.prescale.set(1.0),
self.seq.prescale_units.set(TimeUnits.us),
self.seq.repeats.set(1),
self.seq.table.set(rows),
)
Expand Down
4 changes: 2 additions & 2 deletions tests/fastcs/panda/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def sim_x_motor():
async with DeviceCollector(mock=True):
sim_motor = motor.Motor("BLxxI-MO-STAGE-01:X", name="sim_x_motor")

set_mock_value(sim_motor.encoder_res, 0.2)
set_mock_value(sim_motor.encoder_res, 0.02)

yield sim_motor

Expand Down Expand Up @@ -115,7 +115,7 @@ async def test_seq_scanspec_trigger_logic(mock_panda, sim_x_motor, sim_y_motor)
SeqTrigger.IMMEDIATE,
SeqTrigger.BITA_0,
]
assert (out.position == [0, 0, 2, 0, 0, 0, 27, 0, 0, 0, 2, 0, 0]).all()
assert (out.position == [0, 0, 50, 0, 0, 0, 250, 0, 0, 0, 50, 0, 0]).all()
assert (out.time1 == [0, 0, 0, 900000, 0, 0, 0, 900000, 0, 0, 0, 900000, 0]).all()
assert (out.time2 == [0, 0, 0, 100000, 0, 0, 0, 100000, 0, 0, 0, 100000, 0]).all()

Expand Down

0 comments on commit e9387b5

Please sign in to comment.