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

Added Speed Sensor Documentation #269

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pi4j:
provider: pigpio-digital-input
speed-sensor:
name: Speed Sensor # <1>
address: 22 # <2>
address: 17 # <2>
pulses-per-revolution: 20 # <3>
provider: pigpio-digital-input # <4>
debounce: 500 # <5>
Expand Down
ThomasMacas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
:imagesdir: img/

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

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

==== Speed Sensor

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

===== Overview
This section provides the details of the Speed Sensor circuit, including its components, assembly instructions, and functionality.

===== Components
* Speed Sensor
* Bread Board
* T-Extension Board
* 7x Jumper Cables
* Green LED Light Bulb
* Red LED Light Bulb
* 2x 220Ω Resistors
* Power source

===== Assembly Instructions
. Ground (GND): Connect the GND pin on the speed sensor to the ground rail on the breadboard.
. VCC: Connect the VCC pin on the speed sensor to the 5V pin on the Raspberry Pi GPIO header via the breadboard power rail.
. Digital Output (D0): Connect the D0 pin on the speed sensor to GPIO 17 (Pin 11) on the Raspberry Pi GPIO header.
. Connect the longer leg (anode) of the red LED to a row on the breadboard.
. Place a 220-ohm resistor between the shorter leg (cathode) of the red LED and the ground rail on the breadboard.
. Use a jumper wire to connect the same row as the anode of the red LED to GPIO 27 (Pin 13) on the Raspberry Pi.
. Similarly, place the green LED on the breadboard.
. Connect the longer leg (anode) to a free row.
. Place another 220-ohm resistor between the cathode of the green LED and ground.
. Use a jumper wire to connect the anode of the green LED to GPIO 22 (Pin 15).
. Connect the ground rail on the breadboard to a ground pin (GND) on the Raspberry Pi GPIO header (e.g., Pin 6).
. Connect the power rail on the breadboard to a 5V pin on the Raspberry Pi GPIO header (e.g., Pin 2).

===== Circuit Diagram

image::SpeedSensor-Circuit.png[]

*Schematic Diagram:*

image::SpeedSensor-Schematic.png[]

===== Functionality

===== Testing the Circuit:

Use the below command to test the speed sensor.

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

* `/enable` - Initializes the Speed Sensor

[source, bash]
----
$curl http://localhost:8080/speedSensor/speed/rpm
----

* `/speed/rpm` - Returns the speed in RPM

[source, bash]
----
$curl http://localhost:8080/speedSensor/speed/disable
----

* `/disable` - Disables the Speed Sensor

===== Troubleshooting

Verify that all connections are correct and that the order of components in a row are correct.

===== YAML Configuration
The speed sensor as it appears in the application.yml:

[source, yaml]
----
digital-input:
speed-sensor:
name: Speed Sensor
address: 17
pulses-per-revolution: 20
provider: pigpio-digital-input
debounce: 500
----

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

===== An Example Controller

====== This controller sets up Speed Sensor

[source, java]
----
include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/SpeedSensorController.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.
Loading