Initial Stepper Motor Interface Implementation #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR creates a class to handle interfacing with the stepper motors, given commands from the raspberry pi over the can bus. Using the Adafruit stepper motor hat library, as well as the mcp2515 can interfacing class, the interface is able to parse a can message from the bus, and perform one of three different tasks based on the id of the incoming message:
Initialization command - initializes one of the two steppers that can be connected to the hat, given that it has not already been initialized. The interface then sends a response message back to the pi over the can bus, to confirm that initialization has occurred. The data payload for this message includes the address of the stepper (either 1 or 2), and the step size is the number of steps per revolution that the stepper is capable of
Stepper speed command - Sets the speed at which the stepper actuates, this is an rpm value. The data payload includes the stepper's address (1 or 2), and the rpm value. The interface sends a stepper speed response back to the pi to confirm successful configuration.
Stepper step command - Actuates the stepper. The data payload includes the number of steps, the direction (forward (1) or backward (2)), and the step type (see details about what this means here. The stepper command is blocking, and will not return until actuation is complete. When it is complete, the interface will send a step response message back to the pi to confirm actuation was successful.
Heartbeat message - Will be sent to the pi to confirm that can communications have been sustained. The message will be sent once per application loop, and the interface on the pi will be aware that when an actuation command is sent, the heartbeat message will be delayed.
Stuff that still needs to be done: