1. Aufgabe
Die Funktion ist für Bascom-AVR geschrieben und ermöglicht es, die
Windgeschwindigkeit (in Km/h) in Windstärke nach Beaufort umzurechnen.
2. Programm
'***************************************************************************************** |
'
Name
' Author
' Purpose
' Version
' Compiler
' Bytes
' Chiptype
|
:
beaufort.bas
: DG1XPZ
: conversion wind speed into wind velocity
: V0.1
: Bascom AVR 1.11.7.4
: 2632
: Atmel AVR |
|
'***************************************************************************************** |
$regfile = "m8def.dat"
$crystal = 4000000
Declare Function Beaufort(wind As Word) As Integer
Dim Wind_v As Word
Dim Windstaerke As Integer
Wind_v = 150
'Wert Windgeschwindigkeit
Windstaerke = Beaufort(wind_v)
Print Wind_v ; "Km/h = Windstärke(Beaufort): " ; Windstaerke
'Ausgabe der Windstaerke
Function Beaufort(wind As Word) As Integer
Dim Ws As Single
Dim Tmp As Single
Dim Wsi As Integer
Ws = Wind / 3.6
Ws = Ws - 0.07
Ws = Ws / 0.834
Ws = Ws * Ws
Ws = Log(ws)
Tmp = Log(10)
Ws = Ws / Tmp
Ws = Ws / 3
Tmp = 10
Ws = Power(tmp , Ws)
Ws = Round(ws)
Wsi = Int(ws)
Beaufort = Wsi
End Function
End |
|