projects:anemometer
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| projects:anemometer [2023/10/02 18:23] – [Calculating wind speed] jattie | projects:anemometer [2024/02/18 19:54] (current) – [Important notes about reed switches] jattie | ||
|---|---|---|---|
| Line 29: | Line 29: | ||
| Therefore, with a rotation speed of 60 RPM, the resulting wind speed would be approximately 7.307 meters per second. | Therefore, with a rotation speed of 60 RPM, the resulting wind speed would be approximately 7.307 meters per second. | ||
| + | |||
| + | ===== interrupt-driven counter ===== | ||
| + | |||
| + | |||
| + | To create an interrupt-driven counter on a Raspberry Pi using GPIO pins, you can follow these steps: | ||
| + | |||
| + | ==== Import the required libraries ==== | ||
| + | |||
| + | <code python> | ||
| + | import RPi.GPIO as GPIO | ||
| + | import time | ||
| + | </ | ||
| + | |||
| + | ==== Set up the GPIO mode and initialize the counter variable ==== | ||
| + | |||
| + | ```python | ||
| + | GPIO.setmode(GPIO.BCM) | ||
| + | counter = 0 | ||
| + | ``` | ||
| + | |||
| + | ==== Set up the GPIO pin for input and configure the interrupt ==== | ||
| + | |||
| + | |||
| + | <code python> | ||
| + | GPIO.setup(pin_number, | ||
| + | GPIO.add_event_detect(pin_number, | ||
| + | </ | ||
| + | |||
| + | **Note:** Replace '' | ||
| + | |||
| + | ==== Define the callback function to increment the counter ==== | ||
| + | |||
| + | <code python> | ||
| + | def increment_counter(channel): | ||
| + | global counter | ||
| + | counter += 1 | ||
| + | </ | ||
| + | |||
| + | ==== Create a loop to keep the program running ==== | ||
| + | |||
| + | <code python> | ||
| + | try: | ||
| + | while True: | ||
| + | time.sleep(1) | ||
| + | except KeyboardInterrupt: | ||
| + | GPIO.cleanup() | ||
| + | </ | ||
| + | |||
| + | This code sets up the GPIO pin as an input with a pull-up resistor and detects falling edge interrupts. When the interrupt is triggered, the '' | ||
| + | |||
| + | Remember to replace '' | ||
| + | |||
| + | ===== Important notes about reed switches ===== | ||
| + | |||
| + | The sensitivity of a REED switch is characterized by the value of the magnetic field which is required to | ||
| + | change its state. The magnetic field is expressed in Ampere-turns | ||
| + | |||
| + | <WRAP center round tip 60%> | ||
| + | OAT<CAT is always true | ||
| + | </ | ||
| + | |||
| + | Order of magnitude OAT-CAT : | ||
| + | |||
| + | ^For standard switches^^ | ||
| + | |CAT |12 and 50 Ampere-turns| | ||
| + | |OAT |5 and 30 Ampere-turns|. | ||
| + | ^For standard or mercury wetted switches^^ | ||
| + | |CAT |35 and 150 Ampere-turns| | ||
| + | |OAT |10 and 80| | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | NOTE : if the leads on a switch are cut, the CAT and OAT values will increase | ||
| + | |||
| + | Bending modifies the CAT and OAT values of a switch | ||
| + | Cutting the leads on a REED switch has the effect of increasing the CAT and OAT ratings in a significant manner. | ||
| + | </ | ||
| + | |||
| + | The figure below illustrates this variation. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===== Reed Reference Documents ===== | ||
| + | |||
| + | |||
| + | * {{: | ||
| + | * {{: | ||
projects/anemometer.1696271036.txt.gz · Last modified: by jattie
