Download Print this page

Excel Macro - Global Water FC220 Manual

Data logger option
Hide thumbs Also See for FC220:

Advertisement

VI.

Excel Macro

This Visual Basic macro can be used in an Excel spreadsheet to extract the relay
state information from the recorded analog voltage:
Function RelayStatus(RelayVoltage As Double, RelayNumber As Integer) As String
Dim Alpha As String
Application.Volatile
On Error GoTo FixError
' Convert relay voltage to integer from 0-80, in base 3 this value represents the state of all 4 relays
' Most significant digit is relay 4, least is relay 1
' 0 = Off, 1 = On, 2 = Pulse
RelayVoltage = Int((RelayVoltage + 0.025) / 0.05) - 1
' Test for invald data
If RelayVoltage < 0 Then GoTo Interval
If RelayVoltage > 80 Then GoTo FixError
If RelayNumber < 1 Then GoTo FixError
If RelayNumber > 4 Then GoTo FixError
' Perform relay number base 3 conversion
If RelayNumber = 1 Then RelayStatus = RelayVoltage Mod 3
If RelayNumber = 2 Then RelayStatus = Int(RelayVoltage / 3) Mod 3
If RelayNumber = 3 Then RelayStatus = Int(RelayVoltage / 9) Mod 3
If RelayNumber = 4 Then RelayStatus = Int(RelayVoltage / 27)
GoTo RelayStates
' RelayVoltage of <0 indicates a normal sample interval
Interval:
Alpha = "---"
RelayStatus = Alpha
Exit Function
' Test for relay state
RelayStates:
If RelayStatus = 0 Then Alpha = "Off"
If RelayStatus = 1 Then Alpha = "On"
If RelayStatus = 2 Then Alpha = "Pulse"
RelayStatus = Alpha
Exit Function
FixError:
RelayStatus = "#Value"
End Function
Global Water
800-876-1172 • globalw.com
9

Hide quick links:

Advertisement

loading

This manual is also suitable for:

Pc320