Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DC Motor Support #257

Merged
merged 10 commits into from
Oct 6, 2024
Merged

Conversation

leandrumartin
Copy link
Collaborator

Fixes Issue #255. Added helper and controller classes for a DC motor. The classes can control a DC motor's speed. Planned are direction controls (forward/reverse) and tests for the helper class.

The structure of the code added follows the basic set structure for adding components to the repository: application.yml specifies what pins to use for the motor, the helper class is added under pi4micronaut-utils, and the controller class is added under components/controllers.

I chose to rename the MotorController.java as specified in the issue description to DCMotorController.java to more easily differentiate it from the similarly named servo motor component.

@leandrumartin leandrumartin self-assigned this Sep 27, 2024
@leandrumartin leandrumartin added the New Component Implementing new component support label Sep 27, 2024
@leandrumartin leandrumartin linked an issue Sep 27, 2024 that may be closed by this pull request
@leandrumartin
Copy link
Collaborator Author

I have named the classes back to MotorController. I've now also added the API and method for changing the motor speed. I have added the API for changing the direction and stubbed out the method implementing that functionality.

Copy link
Collaborator

@Ed0827 Ed0827 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, Leandru has successfully implemented the MotorController, MotorHelper, and application.yml. The files have been placed correctly, with MotorController in the inputdevice folder and MotorHelper in the outputdevice folder.

import jakarta.inject.Named;

//tag::ex[]
@Controller("/DCMotor")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All methods from the MotorHelper.java class and every single line in MotorController look great!

@@ -35,6 +35,13 @@ pi4j:
provider: pigpio-pwm
initial: 0
shutdown: 0
dc-motor:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure in application.yml looks great! I’m just curious—could the address be a different number? Is it possible to choose the address randomly?

* Switches the direction of the DC motor.
*/
public void switchDirection() {
setClockwise(!isClockwise);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well written description of each method and well implemented them as well.

@leandrumartin
Copy link
Collaborator Author

The direction setting is now complete and the MotorHelper class now has tests implemented for all methods.

Copy link
Collaborator

@yrlmanoharreddy yrlmanoharreddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Developed MotorHelper.java for DC motor control using the Pi4J library, including methods for initialization, PWM speed control, and direction change (forward/reverse), with example controller on how to use MotorHelper.java with GPIO pin configuration integrated via YAML

@yrlmanoharreddy yrlmanoharreddy marked this pull request as ready for review October 6, 2024 14:14
@yrlmanoharreddy yrlmanoharreddy merged commit 0f805ac into main Oct 6, 2024
6 checks passed
@yrlmanoharreddy yrlmanoharreddy deleted the 255-implement-motor-control-functionality branch October 6, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Component Implementing new component support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Motor Control Functionality
3 participants