Code: Select all
' definitions for measuring Battery Parameters
Private Const VoltagePin as Byte = 13
Private Const CurrentPin as Byte = 14
Dim Voltage As Single
Dim OutVolt as Single
Dim Current as Single
Dim OutCurrent as Single
' Get the voltage measurement
Private Sub ReadVoltage()
Call Getadc(VoltagePin, Voltage)
OutVolt = Voltage * 14.75
Call BatteryStatus
If ((Temp = 1) and (Outvolt > 11.70) _
and (OutVolt < 13.77)) then
Call ClearLine()
End If
call Delay(0.25)
End sub
' Get the current measurement
Private Sub ReadCurrent()
Call Getadc(CurrentPin, Current)
OutCurrent = Current * 2.188
call Delay(0.25)
End Sub
' Check the current status of the batteries
Private Sub BatteryStatus()
If Outvolt < 11.70 Then
call LowBattery
elseif OutVolt >13.77 then
call BatteryCharging
End If
End Sub
Private Sub LowBattery()
Call LCD_DisplayStrAt("Low Batt", 2, 1)
Temp = 1
End Sub
Private Sub BatteryCharging()
Call LCD_DisplayStrAt("Charging", 2, 1)
Temp = 1
End Sub
'Clear line 2 of the LCD display
Private Sub ClearLine()
Dim i as Byte
i = 10
Do While (i > 0)
Call LCD_DisplayStrAt(" ", 2, i)
i = i -1
Loop
Temp = 0
End Sub
Thanks
Patrick