Skip to content

Commit

Permalink
fix(api): temporarily increase Z_L hold current to prevent 96-channel…
Browse files Browse the repository at this point in the history
… from falling when motor is re-engaged (#14377)

* temporarily increase Z_L hold current to prevent stage from falling RQA-2251
  • Loading branch information
ahiuchingau committed Jan 29, 2024
1 parent 85be090 commit 4c427eb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
8 changes: 8 additions & 0 deletions api/src/opentrons/hardware_control/backends/flex_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ def restore_z_r_run_current(self) -> AsyncIterator[None]:
"""
...

@asynccontextmanager
def increase_z_l_hold_current(self) -> AsyncIterator[None]:
"""
Temporarily increase the hold current when engaging the Z_L axis
while the 96-channel is attached
"""
...

async def watch(self, loop: asyncio.AbstractEventLoop) -> None:
...

Expand Down
18 changes: 18 additions & 0 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,24 @@ async def restore_z_r_run_current(self) -> AsyncIterator[None]:
{Axis.Z_R: high_throughput_settings[Axis.Z_R].run_current}
)

@asynccontextmanager
async def increase_z_l_hold_current(self) -> AsyncIterator[None]:
"""
Temporarily increase the hold current when engaging the Z_L axis
while the 96-channel is attached
"""
assert self._current_settings
high_throughput_settings = deepcopy(self._current_settings)
await self.set_hold_current(
{Axis.Z_L: high_throughput_settings[Axis.Z_L].run_current}
)
try:
yield
finally:
await self.set_hold_current(
{Axis.Z_L: high_throughput_settings[Axis.Z_L].hold_current}
)

@staticmethod
def _build_event_watcher() -> aionotify.Watcher:
watcher = aionotify.Watcher()
Expand Down
8 changes: 8 additions & 0 deletions api/src/opentrons/hardware_control/backends/ot3simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,14 @@ async def restore_z_r_run_current(self) -> AsyncIterator[None]:
"""
yield

@asynccontextmanager
async def increase_z_l_hold_current(self) -> AsyncIterator[None]:
"""
Temporarily increase the hold current when engaging the Z_L axis
while the 96-channel is attached
"""
yield

@ensure_yield
async def watch(self, loop: asyncio.AbstractEventLoop) -> None:
new_mods_at_ports = [
Expand Down
9 changes: 8 additions & 1 deletion api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,14 @@ async def _home_axis(self, axis: Axis) -> None:

if encoder_ok:
# ensure stepper position can be updated after boot
await self.engage_axes([axis])
if axis == Axis.Z_L and self.gantry_load == GantryLoad.HIGH_THROUGHPUT:
# we're here if the left mount has been idle and the brake is engaged
# we want to temporarily increase its hold current to prevent the z
# stage from dropping when switching off the ebrake
async with self._backend.increase_z_l_hold_current():
await self.engage_axes([axis])
else:
await self.engage_axes([axis])
await self._update_position_estimation([axis])
# refresh motor and encoder statuses after position estimation update
motor_ok = self._backend.check_motor_status([axis])
Expand Down

0 comments on commit 4c427eb

Please sign in to comment.