From 97aadd0dc8105f4cbdc1765a66a47645b5055c7b Mon Sep 17 00:00:00 2001 From: amit lissack Date: Mon, 8 Nov 2021 15:03:34 -0500 Subject: [PATCH 1/4] convert duration, velocity, and acceleration to 32-bit --- .../drivers/can_bus/messages/payloads.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hardware/opentrons_hardware/drivers/can_bus/messages/payloads.py b/hardware/opentrons_hardware/drivers/can_bus/messages/payloads.py index 7f7675cef5b..66b6aface28 100644 --- a/hardware/opentrons_hardware/drivers/can_bus/messages/payloads.py +++ b/hardware/opentrons_hardware/drivers/can_bus/messages/payloads.py @@ -67,20 +67,15 @@ class AddToMoveGroupRequestPayload(MoveGroupRequestPayload): """Base of add to move group request to a message group.""" seq_id: utils.UInt8Field - # TODO (al, 2021-10-2021): this should be 32 bits - duration: utils.UInt16Field + duration: utils.UInt32Field @dataclass class AddLinearMoveRequestPayload(AddToMoveGroupRequestPayload): """Add a linear move request to a message group.""" - # TODO (al, 2021-10-2021): this should be 32 bits - acceleration: utils.Int16Field - # TODO (al, 2021-10-2021): this should be 32 bits - velocity: utils.Int16Field - # TODO (al, 2021-10-2021): this should be present and 32 bits - # position: utils.UInt32Field + acceleration: utils.Int32Field + velocity: utils.Int32Field @dataclass From 4bda9f9dc1e26ea377bd52c9e66bcd5f38080495 Mon Sep 17 00:00:00 2001 From: amit lissack Date: Mon, 8 Nov 2021 15:12:47 -0500 Subject: [PATCH 2/4] use 32-bit values for motion now that CanFD works. --- .../hardware_control/move_group_runner.py | 8 ++-- ...scheduler.py => test_move_group_runner.py} | 38 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) rename hardware/tests/opentrons_hardware/hardware_control/{test_move_scheduler.py => test_move_group_runner.py} (93%) diff --git a/hardware/opentrons_hardware/hardware_control/move_group_runner.py b/hardware/opentrons_hardware/hardware_control/move_group_runner.py index ccd0a85e142..95ec610c8c9 100644 --- a/hardware/opentrons_hardware/hardware_control/move_group_runner.py +++ b/hardware/opentrons_hardware/hardware_control/move_group_runner.py @@ -20,7 +20,7 @@ ) from opentrons_hardware.hardware_control.constants import interrupts_per_sec from opentrons_hardware.hardware_control.motion import MoveGroups -from opentrons_hardware.utils import UInt8Field, UInt16Field, Int16Field +from opentrons_hardware.utils import UInt8Field, UInt32Field, Int32Field log = logging.getLogger(__name__) @@ -68,11 +68,11 @@ async def _send_groups(self, can_messenger: CanMessenger) -> None: payload=AddLinearMoveRequestPayload( group_id=UInt8Field(group_i), seq_id=UInt8Field(seq_i), - duration=UInt16Field( + duration=UInt32Field( int(step.duration_sec * interrupts_per_sec) ), - acceleration=Int16Field(0), - velocity=Int16Field( + acceleration=Int32Field(0), + velocity=Int32Field( int(interrupts_per_sec * step.velocity_mm_sec) ), ) diff --git a/hardware/tests/opentrons_hardware/hardware_control/test_move_scheduler.py b/hardware/tests/opentrons_hardware/hardware_control/test_move_group_runner.py similarity index 93% rename from hardware/tests/opentrons_hardware/hardware_control/test_move_scheduler.py rename to hardware/tests/opentrons_hardware/hardware_control/test_move_group_runner.py index c9541b2b011..a010bed0b5e 100644 --- a/hardware/tests/opentrons_hardware/hardware_control/test_move_scheduler.py +++ b/hardware/tests/opentrons_hardware/hardware_control/test_move_group_runner.py @@ -26,7 +26,7 @@ message_definitions as md, MessageDefinition, ) -from opentrons_hardware.utils import UInt8Field, Int16Field, UInt16Field +from opentrons_hardware.utils import UInt8Field, Int32Field, UInt32Field @pytest.fixture @@ -129,14 +129,14 @@ async def test_single_send_setup_commands( payload=AddLinearMoveRequestPayload( group_id=UInt8Field(0), seq_id=UInt8Field(0), - velocity=Int16Field( + velocity=Int32Field( int( move_group_single[0][0][NodeId.head].velocity_mm_sec * interrupts_per_sec ) ), - acceleration=Int16Field(0), - duration=UInt16Field( + acceleration=Int32Field(0), + duration=UInt32Field( int( move_group_single[0][0][NodeId.head].duration_sec * interrupts_per_sec @@ -161,14 +161,14 @@ async def test_multi_send_setup_commands( payload=AddLinearMoveRequestPayload( group_id=UInt8Field(0), seq_id=UInt8Field(0), - velocity=Int16Field( + velocity=Int32Field( int( move_group_multiple[0][0][NodeId.head].velocity_mm_sec * interrupts_per_sec ) ), - acceleration=Int16Field(0), - duration=UInt16Field( + acceleration=Int32Field(0), + duration=UInt32Field( int( move_group_multiple[0][0][NodeId.head].duration_sec * interrupts_per_sec @@ -185,14 +185,14 @@ async def test_multi_send_setup_commands( payload=AddLinearMoveRequestPayload( group_id=UInt8Field(1), seq_id=UInt8Field(0), - velocity=Int16Field( + velocity=Int32Field( int( move_group_multiple[1][0][NodeId.gantry_x].velocity_mm_sec * interrupts_per_sec ) ), - acceleration=Int16Field(0), - duration=UInt16Field( + acceleration=Int32Field(0), + duration=UInt32Field( int( move_group_multiple[1][0][NodeId.gantry_x].duration_sec * interrupts_per_sec @@ -208,14 +208,14 @@ async def test_multi_send_setup_commands( payload=AddLinearMoveRequestPayload( group_id=UInt8Field(1), seq_id=UInt8Field(0), - velocity=Int16Field( + velocity=Int32Field( int( move_group_multiple[1][0][NodeId.gantry_y].velocity_mm_sec * interrupts_per_sec ) ), - acceleration=Int16Field(0), - duration=UInt16Field( + acceleration=Int32Field(0), + duration=UInt32Field( int( move_group_multiple[1][0][NodeId.gantry_y].duration_sec * interrupts_per_sec @@ -232,14 +232,14 @@ async def test_multi_send_setup_commands( payload=AddLinearMoveRequestPayload( group_id=UInt8Field(2), seq_id=UInt8Field(0), - velocity=Int16Field( + velocity=Int32Field( int( move_group_multiple[2][0][NodeId.pipette].velocity_mm_sec * interrupts_per_sec ) ), - acceleration=Int16Field(0), - duration=UInt16Field( + acceleration=Int32Field(0), + duration=UInt32Field( int( move_group_multiple[2][0][NodeId.pipette].duration_sec * interrupts_per_sec @@ -255,14 +255,14 @@ async def test_multi_send_setup_commands( payload=AddLinearMoveRequestPayload( group_id=UInt8Field(2), seq_id=UInt8Field(1), - velocity=Int16Field( + velocity=Int32Field( int( move_group_multiple[2][1][NodeId.pipette].velocity_mm_sec * interrupts_per_sec ) ), - acceleration=Int16Field(0), - duration=UInt16Field( + acceleration=Int32Field(0), + duration=UInt32Field( int( move_group_multiple[2][1][NodeId.pipette].duration_sec * interrupts_per_sec From 3bc09b4d21ab61cc38224a0fef8a39fbca75921e Mon Sep 17 00:00:00 2001 From: amit lissack Date: Mon, 8 Nov 2021 15:28:47 -0500 Subject: [PATCH 3/4] change frequency of interrupt. --- hardware/opentrons_hardware/hardware_control/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/opentrons_hardware/hardware_control/constants.py b/hardware/opentrons_hardware/hardware_control/constants.py index 5f5503779dd..63a20554055 100644 --- a/hardware/opentrons_hardware/hardware_control/constants.py +++ b/hardware/opentrons_hardware/hardware_control/constants.py @@ -2,5 +2,5 @@ from typing_extensions import Final -interrupts_per_sec: Final = 8500000 +interrupts_per_sec: Final = 850000 """The number of motor interrupts per second.""" From 2aafb9cdac0cca8cd41b40d346cd710fffdff80c Mon Sep 17 00:00:00 2001 From: amit lissack Date: Mon, 8 Nov 2021 15:41:37 -0500 Subject: [PATCH 4/4] fix clock. --- hardware/opentrons_hardware/hardware_control/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/opentrons_hardware/hardware_control/constants.py b/hardware/opentrons_hardware/hardware_control/constants.py index 63a20554055..1777deb0b2b 100644 --- a/hardware/opentrons_hardware/hardware_control/constants.py +++ b/hardware/opentrons_hardware/hardware_control/constants.py @@ -2,5 +2,5 @@ from typing_extensions import Final -interrupts_per_sec: Final = 850000 +interrupts_per_sec: Final = 170000 """The number of motor interrupts per second."""