Share My Creation Wind gauge

This system can measure wind speed.
we used OptoCounter module in wind gauge system.

that code is below.


Sub Process_Globals
Public Serial1 As Serial
Public opto_pin As Pin
Public opto_value As Int
Private opto_timer As Timer
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
opto_pin.Initialize(8,opto_pin.MODE_INPUT )
opto_pin.AddListener("opto_value_plus")

opto_timer.Initialize("opto_timer_tick",1000)
opto_timer.Enabled = True
opto_value=0
End Sub
Sub opto_value_plus (State As Boolean)
If State Then
opto_value=opto_value+1
End If
End Sub
private Sub opto_timer_tick
Dim a As Float
Dim r As Float
Dim wind_speed As Long
r=9
a=2*3.14*r
wind_speed=opto_value*a*3600/100000 'km/h
Log("wind speed is " , wind_speed , " Km/h")
opto_value=0
End Sub
 

Attachments

  • ۲۰۲۱۰۹۰۸_۰۰۴۷۱۸.jpg
    ۲۰۲۱۰۹۰۸_۰۰۴۷۱۸.jpg
    97.7 KB · Views: 118
  • Wind gauge.jpg
    Wind gauge.jpg
    146.5 KB · Views: 34
Top