Skip to content

Commit bbdfd4a

Browse files
committed
Changes to Sequencer table from testing with PandA
1 parent 9f5813d commit bbdfd4a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/ophyd_async/fastcs/panda/_trigger.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def __init__(self, seq: SeqBlock, name="") -> None:
5656
self.name = name
5757

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

68-
fast_axis = chunk.axes()[len(chunk.axes()) - 2]
6967
gaps = np.append(gaps, scan_size)
68+
fast_axis = chunk.axes()[len(chunk.axes()) - 2]
69+
# Get the resolution from the PandA Encoder?
70+
resolution = await fast_axis.encoder_res.get_value()
7071
start = 0
7172
# Wait for GPIO to go low
7273
rows = SeqTable.row(trigger=SeqTrigger.BITA_0)
7374
for gap in gaps:
7475
# Wait for GPIO to go high
7576
rows += SeqTable.row(trigger=SeqTrigger.BITA_1)
7677
# Wait for position
77-
if chunk.midpoints[fast_axis][gap - 1] > chunk.midpoints[fast_axis][start]:
78+
if (
79+
chunk.midpoints[fast_axis][gap - 1] * resolution
80+
> chunk.midpoints[fast_axis][start] * resolution
81+
):
7882
trig = SeqTrigger.POSA_GT
79-
dir = False
83+
dir = False if resolution > 0 else True
8084

8185
else:
8286
trig = SeqTrigger.POSA_LT
83-
dir = True
87+
dir = True if resolution > 0 else False
8488
rows += SeqTable.row(
8589
trigger=trig,
8690
position=int(
87-
chunk.lower[fast_axis][start]
91+
chunk.midpoints[fast_axis][start]
8892
/ await fast_axis.encoder_res.get_value()
8993
),
9094
)
@@ -98,15 +102,16 @@ async def prepare(self, value: ScanSpecInfo):
98102
outa1=True,
99103
outb1=dir,
100104
outa2=False,
101-
outb2=False,
105+
outb2=dir,
102106
)
103107

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

107111
start = gap
108112
await asyncio.gather(
109-
self.seq.prescale.set(0),
113+
self.seq.prescale.set(1.0),
114+
self.seq.prescale_units.set(TimeUnits.us),
110115
self.seq.repeats.set(1),
111116
self.seq.table.set(rows),
112117
)

tests/fastcs/panda/test_trigger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def sim_x_motor():
7878
async with DeviceCollector(mock=True):
7979
sim_motor = motor.Motor("BLxxI-MO-STAGE-01:X", name="sim_x_motor")
8080

81-
set_mock_value(sim_motor.encoder_res, 0.2)
81+
set_mock_value(sim_motor.encoder_res, 0.02)
8282

8383
yield sim_motor
8484

@@ -115,7 +115,7 @@ async def test_seq_scanspec_trigger_logic(mock_panda, sim_x_motor, sim_y_motor)
115115
SeqTrigger.IMMEDIATE,
116116
SeqTrigger.BITA_0,
117117
]
118-
assert (out.position == [0, 0, 2, 0, 0, 0, 27, 0, 0, 0, 2, 0, 0]).all()
118+
assert (out.position == [0, 0, 50, 0, 0, 0, 250, 0, 0, 0, 50, 0, 0]).all()
119119
assert (out.time1 == [0, 0, 0, 900000, 0, 0, 0, 900000, 0, 0, 0, 900000, 0]).all()
120120
assert (out.time2 == [0, 0, 0, 100000, 0, 0, 0, 100000, 0, 0, 0, 100000, 0]).all()
121121

0 commit comments

Comments
 (0)