Skip to content

Commit

Permalink
Merge pull request #268 from oss-slu/263-document-dc-motor-control-mo…
Browse files Browse the repository at this point in the history
…dule-for-pi4micronaut

DC Motor documentation
  • Loading branch information
yrlmanoharreddy authored Oct 21, 2024
2 parents 71c567d + 727fa73 commit 3e99403
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pi4j:
shutdown: 0
servo-motor:
name: Servo Motor
address: 18
address: 17
pwmType: SOFTWARE
provider: pigpio-pwm
initial: 0
Expand Down Expand Up @@ -199,4 +199,4 @@ pi4j:
provider: pigpio-pwm
initials: 0, 0, 0
shutdowns: 0, 0, 0
# end::multiPWM[]
# end::multiPWM[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
:imagesdir: img/

ifndef::rootpath[]
:rootpath: ../../
endif::rootpath[]

ifdef::rootpath[]
:imagesdir: {rootpath}{imagesdir}
endif::rootpath[]

==== Motor

[.text-right]
https://github.com/oss-slu/Pi4Micronaut/edit/develop/pi4micronaut-utils/src/docs/asciidoc/components/outputComponents/motor.adoc[Improve this doc]

===== Overview

This section provides details of the DC motor, including its components and assembly instructions.

===== Components

* 1 x RaspberryPi
* 1 x Breadboard
* 1 x T-Extension Board
* 1 x DC Motor
* 8 x Jumper wires
* 1 x L293D Motor Controller IC 1
* 1 x battery pack with 4 AA or AAA batteries
* Power source (appropriate voltage, typically 3.3V)

===== Assembly Instructions

* Connect the ground (GND) pin of the Raspberry Pi to the ground rail on the breadboard.
* Place the L293D Motor Controller on the breadboard.
* Connect a jumper wire from the L293D to the ground rail on the breadboard.
* Connect the motor to the breadboard, attaching both terminals in line with the L293D.
* Connect a jumper wire from pin 17 to the L293D.
* Connect the battery pack to the breadboard.
* Connect a jumper wire from the positive end of the battery pack to the L293D.
* Connect a jumper wire from the negative end of the battery pack to the ground rail on the breadboard.
* Connect a jumper wire from pin 18 of the Raspberry Pi to the L293D.
* Connect a jumper wire from pin 4 of the Raspberry Pi to the L293D.
* Connect a jumper wire from the 5V pin of the Raspberry Pi to the L293D.


===== Circuit Diagram

image::motor_bb.png[]

===== Schematic Diagram

image::Motor_schem.png[]

===== Functionality

Motor can be enabled or disabled, change speed to custom value 0 to 100, and switch directions between clockwise and counterclockwise.

===== Testing

Use the below commands to test the component.
This will cause the motor to turn.

[source,bash]
----
$ curl http://localhost:8080/motor/enable
----

* `/enable` - Enables the motor.
* `/disable` - Disables the motor.
* `/setSpeed/{speed}` - Sets the speed of the motor to custom value 0 to 100.
* `/setClockwise/{clockwise}` - Sets the direction of the motor; "true" for clockwise, "false" for counterclockwise.
* `/switchDirection` - Switches the direction from clockwise to counterclockwise or vice versa.

===== Troubleshooting

* Motor does not turn on
- Ensure all connections are secure and correct.
- Check for appropriate voltage from power source.
- Check the L239D for proper orientation and placement.
- Ensure the software configuration matches the hardware setup.
- Look for any error messages in the console or logs.

* Motor turns on but does not respond to commands
- Check the software configuration for any discrepancies.
- Ensure the L239D is functioning properly.
- Check for appropriate voltage from power source.

===== YAML Configuration

[source,yaml]
----
pwm:
motor:
name: Motor
address: 17
pwmType: SOFTWARE
provider: pigpio-pwm
initial: 0
shutdown: 0
----

===== Constructor and Methods

To see the constructor and methods of our MotorHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/outputdevices/MotorHelper.html[here]
for more details.

===== An Example Controller

[source,java]
----
include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/MotorController.java[tag=ex]
----
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3e99403

Please sign in to comment.