VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form GUI 
   BackColor       =   &H00000000&
   Caption         =   "<  Multi Function IO Controller >"
   ClientHeight    =   7710
   ClientLeft      =   60
   ClientTop       =   750
   ClientWidth     =   10080
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   24
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Serial IO Controller.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   7710
   ScaleWidth      =   10080
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame14 
      BackColor       =   &H0000FFFF&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   720
      Left            =   120
      TabIndex        =   70
      Top             =   6400
      Width           =   9855
      Begin VB.Frame Frame5 
         Height          =   35
         Index           =   1
         Left            =   0
         TabIndex        =   89
         Top             =   25
         Width           =   9855
      End
      Begin VB.TextBox SampleUpdateInterval 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   300
         Left            =   1850
         MaxLength       =   4
         TabIndex        =   74
         Text            =   "100"
         Top             =   240
         Width           =   735
      End
      Begin VB.ComboBox FastUpdateVariable 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         ItemData        =   "Serial IO Controller.frx":030A
         Left            =   5175
         List            =   "Serial IO Controller.frx":031D
         TabIndex        =   73
         Text            =   "AN 2"
         Top             =   240
         Width           =   1320
      End
      Begin VB.OptionButton Mode 
         BackColor       =   &H00000000&
         Caption         =   "Fast Update Mode  For"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   300
         Index           =   1
         Left            =   3175
         TabIndex        =   72
         Top             =   240
         Width           =   2055
      End
      Begin VB.OptionButton Mode 
         BackColor       =   &H00000000&
         Caption         =   "Update &Data Every"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   300
         Index           =   0
         Left            =   120
         TabIndex        =   71
         Top             =   240
         Value           =   -1  'True
         Width           =   1815
      End
      Begin VB.Line Line3 
         BorderColor     =   &H0000FFFF&
         BorderWidth     =   10
         X1              =   0
         X2              =   6600
         Y1              =   0
         Y2              =   0
      End
      Begin VB.Image Image2 
         Height          =   750
         Left            =   6600
         Picture         =   "Serial IO Controller.frx":033F
         Stretch         =   -1  'True
         Top             =   0
         Width           =   3220
      End
      Begin VB.Label SecsLabel 
         BackStyle       =   0  'Transparent
         Caption         =   "mS"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   1
         Left            =   2660
         TabIndex        =   75
         Top             =   285
         Width           =   420
      End
   End
   Begin VB.Frame Frame6 
      BackColor       =   &H00E0E0E0&
      Caption         =   "Communications Serial Port"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   2130
      Left            =   6690
      TabIndex        =   56
      Top             =   4320
      Width           =   3285
      Begin VB.CommandButton Calibration 
         Caption         =   "Calibration"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1650
         TabIndex        =   84
         Top             =   1680
         Width           =   1500
      End
      Begin VB.CommandButton AlarmsAndTimers 
         Caption         =   "Alarms && Timers"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1650
         TabIndex        =   83
         Top             =   1340
         Width           =   1500
      End
      Begin VB.CommandButton ResetSys 
         Caption         =   "RESET"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   120
         TabIndex        =   82
         Top             =   1680
         Width           =   1500
      End
      Begin VB.CommandButton ShowDataLogging 
         Caption         =   "Data Logging"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   120
         TabIndex        =   81
         Top             =   1340
         Width           =   1500
      End
      Begin VB.CommandButton RLY1 
         Caption         =   "Toggle Relay &1"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   120
         TabIndex        =   80
         Top             =   650
         Width           =   1500
      End
      Begin VB.CommandButton RLY2 
         Caption         =   "Toggle Relay &2"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1650
         TabIndex        =   79
         Top             =   650
         Width           =   1500
      End
      Begin VB.CommandButton BuzzerON 
         Caption         =   "Buzzer &ON"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   120
         TabIndex        =   78
         Top             =   990
         Width           =   1500
      End
      Begin VB.CommandButton BuzzerOFF 
         Caption         =   "Buzzer OF&F"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1650
         TabIndex        =   77
         Top             =   990
         Width           =   1500
      End
      Begin VB.ComboBox CommPortSelection 
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         ItemData        =   "Serial IO Controller.frx":21222
         Left            =   500
         List            =   "Serial IO Controller.frx":2123E
         TabIndex        =   58
         Text            =   "Comm 1"
         Top             =   220
         Width           =   1110
      End
      Begin VB.CommandButton Connect 
         Caption         =   "Connect "
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   1650
         TabIndex        =   57
         Top             =   220
         Width           =   1500
      End
      Begin VB.Image Image3 
         Height          =   465
         Left            =   105
         Picture         =   "Serial IO Controller.frx":21282
         Stretch         =   -1  'True
         Top             =   135
         Width           =   375
      End
   End
   Begin VB.Frame Frame3 
      BackColor       =   &H00E0E0E0&
      Caption         =   "10 BIT Output Port "
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   2130
      Index           =   1
      Left            =   120
      TabIndex        =   16
      Top             =   4320
      Width           =   3290
      Begin VB.Frame Frame4 
         Caption         =   "Frame4"
         Height          =   615
         Index           =   0
         Left            =   1625
         TabIndex        =   86
         Top             =   960
         Width           =   15
      End
      Begin VB.Frame Frame8 
         BackColor       =   &H00E0E0E0&
         Caption         =   "HEX Value"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   855
         Index           =   2
         Left            =   1800
         TabIndex        =   20
         Top             =   795
         Width           =   1335
         Begin VB.TextBox ShowOutputHEX 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   13.5
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   465
            Left            =   150
            MaxLength       =   3
            TabIndex        =   21
            Text            =   "0"
            Top             =   240
            Width           =   1035
         End
      End
      Begin VB.Frame Frame8 
         BackColor       =   &H00E0E0E0&
         Caption         =   "Decimal Value"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   855
         Index           =   3
         Left            =   160
         TabIndex        =   18
         Top             =   795
         Width           =   1335
         Begin VB.TextBox ShowOutputDecimal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   13.5
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   465
            Left            =   140
            MaxLength       =   4
            TabIndex        =   19
            Text            =   "0"
            Top             =   240
            Width           =   1035
         End
      End
      Begin VB.CommandButton RefreshOutputPort 
         BackColor       =   &H00E0E0E0&
         Caption         =   "< Write Data To Port >"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   150
         Style           =   1  'Graphical
         TabIndex        =   17
         Top             =   1680
         Width           =   2990
      End
      Begin VB.Shape Shape1 
         BackColor       =   &H0000FFFF&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H00FFFFFF&
         Height          =   775
         Index           =   0
         Left            =   1510
         Top             =   870
         Width           =   255
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "D0  D1  D2  D3  D4  D5  D6  D7  D8  D9"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   255
         Index           =   1
         Left            =   180
         TabIndex        =   22
         Top             =   520
         Width           =   3015
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   9
         Left            =   2880
         Picture         =   "Serial IO Controller.frx":2158C
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   8
         Left            =   2580
         Picture         =   "Serial IO Controller.frx":22BE2
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   7
         Left            =   2280
         Picture         =   "Serial IO Controller.frx":24238
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   6
         Left            =   1980
         Picture         =   "Serial IO Controller.frx":2588E
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   5
         Left            =   1680
         Picture         =   "Serial IO Controller.frx":26EE4
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   4
         Left            =   1380
         Picture         =   "Serial IO Controller.frx":2853A
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   3
         Left            =   1080
         Picture         =   "Serial IO Controller.frx":29B90
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   2
         Left            =   780
         Picture         =   "Serial IO Controller.frx":2B1E6
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   1
         Left            =   480
         Picture         =   "Serial IO Controller.frx":2C83C
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDOFF 
         Height          =   225
         Index           =   0
         Left            =   180
         Picture         =   "Serial IO Controller.frx":2DE92
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   9
         Left            =   2880
         Picture         =   "Serial IO Controller.frx":2F4E8
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   8
         Left            =   2580
         Picture         =   "Serial IO Controller.frx":30BDC
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   7
         Left            =   2280
         Picture         =   "Serial IO Controller.frx":322D0
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   6
         Left            =   1980
         Picture         =   "Serial IO Controller.frx":339C4
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   5
         Left            =   1680
         Picture         =   "Serial IO Controller.frx":350B8
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   4
         Left            =   1380
         Picture         =   "Serial IO Controller.frx":367AC
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   3
         Left            =   1080
         Picture         =   "Serial IO Controller.frx":37EA0
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   2
         Left            =   780
         Picture         =   "Serial IO Controller.frx":39594
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   1
         Left            =   480
         Picture         =   "Serial IO Controller.frx":3AC88
         Top             =   270
         Width           =   225
      End
      Begin VB.Image OutputLEDON 
         Height          =   225
         Index           =   0
         Left            =   180
         Picture         =   "Serial IO Controller.frx":3C37C
         Top             =   270
         Width           =   225
      End
   End
   Begin VB.Frame Frame3 
      BackColor       =   &H00E0E0E0&
      Caption         =   "10 BIT Input Port "
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   2130
      Index           =   0
      Left            =   3400
      TabIndex        =   23
      Top             =   4320
      Width           =   3290
      Begin VB.Frame Frame4 
         Caption         =   "Frame4"
         Height          =   615
         Index           =   1
         Left            =   1625
         TabIndex        =   87
         Top             =   960
         Width           =   15
      End
      Begin VB.Frame Frame8 
         BackColor       =   &H00E0E0E0&
         Caption         =   "Decimal Value"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   855
         Index           =   0
         Left            =   160
         TabIndex        =   27
         Top             =   795
         Width           =   1335
         Begin VB.TextBox ShowInputDecimal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   13.5
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   465
            Left            =   150
            Locked          =   -1  'True
            MaxLength       =   4
            TabIndex        =   28
            Text            =   "0"
            Top             =   240
            Width           =   1035
         End
      End
      Begin VB.Frame Frame8 
         BackColor       =   &H00E0E0E0&
         Caption         =   "HEX Value"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   855
         Index           =   1
         Left            =   1800
         TabIndex        =   25
         Top             =   795
         Width           =   1335
         Begin VB.TextBox ShowInputHEX 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   13.5
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   465
            Left            =   150
            Locked          =   -1  'True
            MaxLength       =   3
            TabIndex        =   26
            Text            =   "0"
            Top             =   240
            Width           =   1035
         End
      End
      Begin VB.CommandButton CombinationIOLogic 
         BackColor       =   &H00E0E0E0&
         Caption         =   "< &Combination Logic Control >"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   150
         Style           =   1  'Graphical
         TabIndex        =   24
         Top             =   1680
         Width           =   2990
      End
      Begin VB.Shape Shape1 
         BackColor       =   &H0000FFFF&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H00FFFFFF&
         Height          =   775
         Index           =   1
         Left            =   1510
         Top             =   870
         Width           =   255
      End
      Begin VB.Label Label1 
         BackStyle       =   0  'Transparent
         Caption         =   "D0  D1  D2  D3  D4  D5  D6  D7  D8  D9"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   255
         Index           =   4
         Left            =   180
         TabIndex        =   29
         Top             =   520
         Width           =   3015
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   0
         Left            =   180
         Picture         =   "Serial IO Controller.frx":3DA70
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   1
         Left            =   480
         Picture         =   "Serial IO Controller.frx":3F164
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   2
         Left            =   780
         Picture         =   "Serial IO Controller.frx":40858
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   3
         Left            =   1080
         Picture         =   "Serial IO Controller.frx":41F4C
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   4
         Left            =   1380
         Picture         =   "Serial IO Controller.frx":43640
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   5
         Left            =   1680
         Picture         =   "Serial IO Controller.frx":44D34
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   6
         Left            =   1980
         Picture         =   "Serial IO Controller.frx":46428
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   7
         Left            =   2280
         Picture         =   "Serial IO Controller.frx":47B1C
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   8
         Left            =   2580
         Picture         =   "Serial IO Controller.frx":49210
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDON 
         Height          =   225
         Index           =   9
         Left            =   2880
         Picture         =   "Serial IO Controller.frx":4A904
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   0
         Left            =   180
         Picture         =   "Serial IO Controller.frx":4BFF8
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   1
         Left            =   480
         Picture         =   "Serial IO Controller.frx":4D64E
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   2
         Left            =   780
         Picture         =   "Serial IO Controller.frx":4ECA4
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   3
         Left            =   1080
         Picture         =   "Serial IO Controller.frx":502FA
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   4
         Left            =   1380
         Picture         =   "Serial IO Controller.frx":51950
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   5
         Left            =   1680
         Picture         =   "Serial IO Controller.frx":52FA6
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   6
         Left            =   1980
         Picture         =   "Serial IO Controller.frx":545FC
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   7
         Left            =   2280
         Picture         =   "Serial IO Controller.frx":55C52
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   8
         Left            =   2580
         Picture         =   "Serial IO Controller.frx":572A8
         Top             =   270
         Width           =   225
      End
      Begin VB.Image InputLEDOFF 
         Height          =   225
         Index           =   9
         Left            =   2880
         Picture         =   "Serial IO Controller.frx":588FE
         Top             =   270
         Width           =   225
      End
   End
   Begin ComctlLib.StatusBar StatusBar1 
      Align           =   2  'Align Bottom
      Height          =   375
      Left            =   0
      TabIndex        =   85
      Top             =   7335
      Width           =   10080
      _ExtentX        =   17780
      _ExtentY        =   661
      Style           =   1
      SimpleText      =   ""
      _Version        =   327682
      BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
         NumPanels       =   1
         BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00E0E0E0&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4335
      Index           =   0
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   3280
      Begin VB.Frame Frame1 
         BackColor       =   &H00FF8080&
         Caption         =   "Analog Input 2"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   990
         Index           =   4
         Left            =   140
         TabIndex        =   9
         Top             =   3210
         Width           =   3015
         Begin VB.TextBox ShowAnalog2 
            Alignment       =   2  'Center
            BackColor       =   &H0000FFFF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   24
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   615
            Left            =   120
            Locked          =   -1  'True
            TabIndex        =   10
            Top             =   240
            Width           =   1450
         End
         Begin VB.Label Label2 
            BackStyle       =   0  'Transparent
            Caption         =   "(0-25) Volts"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   255
            Index           =   2
            Left            =   1920
            TabIndex        =   14
            Top             =   645
            Width           =   1065
         End
         Begin VB.Label Label1 
            Alignment       =   2  'Center
            BackColor       =   &H00FF8080&
            Caption         =   "VDC"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   18
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000080FF&
            Height          =   495
            Index           =   3
            Left            =   1800
            TabIndex        =   11
            Top             =   240
            Width           =   975
         End
      End
      Begin VB.Frame Frame1 
         BackColor       =   &H00FF8080&
         Caption         =   "Analog Input 1"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   975
         Index           =   3
         Left            =   140
         TabIndex        =   6
         Top             =   2200
         Width           =   3015
         Begin VB.TextBox ShowAnalog1 
            Alignment       =   2  'Center
            BackColor       =   &H0000FFFF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   24
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   615
            Left            =   120
            Locked          =   -1  'True
            TabIndex        =   7
            Top             =   240
            Width           =   1450
         End
         Begin VB.Label Label2 
            BackStyle       =   0  'Transparent
            Caption         =   "(0-5) Volts"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   255
            Index           =   1
            Left            =   1920
            TabIndex        =   13
            Top             =   645
            Width           =   915
         End
         Begin VB.Label Label1 
            Alignment       =   2  'Center
            BackColor       =   &H00FF8080&
            Caption         =   "VDC"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   18
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00800000&
            Height          =   495
            Index           =   2
            Left            =   1800
            TabIndex        =   8
            Top             =   240
            Width           =   975
         End
      End
      Begin VB.Frame Frame1 
         BackColor       =   &H00FF8080&
         Caption         =   "LDR Resistance"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   975
         Index           =   2
         Left            =   140
         TabIndex        =   4
         Top             =   1200
         Width           =   3015
         Begin VB.TextBox ShowResistance 
            Alignment       =   2  'Center
            BackColor       =   &H0000FFFF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   13.5
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   465
            Left            =   120
            Locked          =   -1  'True
            MaxLength       =   6
            TabIndex        =   5
            Top             =   240
            Width           =   1450
         End
         Begin VB.Image Image5 
            Height          =   495
            Index           =   1
            Left            =   1600
            Picture         =   "Serial IO Controller.frx":59F54
            Stretch         =   -1  'True
            Top             =   200
            Width           =   495
         End
         Begin VB.Image Image1 
            Height          =   510
            Left            =   2200
            Picture         =   "Serial IO Controller.frx":5A25E
            Top             =   195
            Width           =   525
         End
         Begin VB.Label Label2 
            BackStyle       =   0  'Transparent
            Caption         =   "*Approx Value With 100K In Parallel"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   255
            Index           =   0
            Left            =   105
            TabIndex        =   12
            Top             =   705
            Width           =   2775
         End
      End
      Begin VB.Frame Frame1 
         BackColor       =   &H00FF8080&
         Caption         =   "Temperature"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   975
         Index           =   1
         Left            =   140
         TabIndex        =   1
         Top             =   200
         Width           =   3015
         Begin VB.TextBox ShowTemperature 
            Alignment       =   2  'Center
            BackColor       =   &H0000FFFF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   24
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00000000&
            Height          =   615
            Left            =   120
            Locked          =   -1  'True
            TabIndex        =   2
            Top             =   240
            Width           =   1450
         End
         Begin VB.Image Image5 
            Height          =   630
            Index           =   0
            Left            =   1600
            Picture         =   "Serial IO Controller.frx":5BFF4
            Stretch         =   -1  'True
            Top             =   240
            Width           =   525
         End
         Begin VB.Label Label1 
            Alignment       =   2  'Center
            BackColor       =   &H00FF8080&
            Caption         =   "°C"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   24
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H0000FFFF&
            Height          =   495
            Index           =   0
            Left            =   2010
            TabIndex        =   3
            Top             =   300
            Width           =   735
         End
      End
      Begin VB.Shape Shape5 
         Height          =   4110
         Left            =   75
         Top             =   150
         Width           =   3135
      End
      Begin VB.Line Line1 
         BorderColor     =   &H00000000&
         BorderWidth     =   10
         X1              =   0
         X2              =   3240
         Y1              =   0
         Y2              =   0
      End
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H00E0E0E0&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4335
      Index           =   1
      Left            =   3400
      TabIndex        =   15
      Top             =   0
      Width           =   6570
      Begin VB.Frame Frame5 
         Height          =   35
         Index           =   0
         Left            =   240
         TabIndex        =   88
         Top             =   2310
         Width           =   6135
      End
      Begin VB.Frame Frame12 
         BackColor       =   &H00FF8080&
         Caption         =   "Analog Plotter"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   2055
         Left            =   120
         TabIndex        =   59
         Top             =   200
         Width           =   6320
         Begin VB.Timer StatusBar 
            Interval        =   16
            Left            =   5040
            Top             =   1440
         End
         Begin VB.Timer AutoLog 
            Enabled         =   0   'False
            Interval        =   990
            Left            =   4560
            Top             =   1440
         End
         Begin VB.Timer LogTimer 
            Enabled         =   0   'False
            Interval        =   990
            Left            =   4080
            Top             =   1440
         End
         Begin VB.Timer PlotTimer 
            Enabled         =   0   'False
            Interval        =   990
            Left            =   4080
            Top             =   840
         End
         Begin VB.Frame Frame13 
            BackColor       =   &H00FF8080&
            Caption         =   "Plot"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   1095
            Index           =   0
            Left            =   4480
            TabIndex        =   61
            Top             =   150
            Width           =   1720
            Begin VB.TextBox PlotUpdateInterval 
               Alignment       =   2  'Center
               BackColor       =   &H000000FF&
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               ForeColor       =   &H00FFFFFF&
               Height          =   300
               Left            =   680
               MaxLength       =   3
               TabIndex        =   67
               Text            =   "2"
               Top             =   650
               Width           =   500
            End
            Begin VB.CheckBox EnablePlotter 
               BackColor       =   &H00FF8080&
               Caption         =   "ON"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   360
               Left            =   1080
               TabIndex        =   63
               Top             =   240
               Width           =   600
            End
            Begin VB.ComboBox PlotVariable 
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   315
               ItemData        =   "Serial IO Controller.frx":5C2FE
               Left            =   120
               List            =   "Serial IO Controller.frx":5C30E
               TabIndex        =   62
               Text            =   "Temp"
               Top             =   240
               Width           =   855
            End
            Begin VB.Label ShowFastUpdate 
               BackColor       =   &H00FF8080&
               Caption         =   "Fast Update Mode"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   240
               TabIndex        =   76
               Top             =   720
               Visible         =   0   'False
               Width           =   1335
            End
            Begin VB.Label SecsLabel 
               BackStyle       =   0  'Transparent
               Caption         =   "Secs"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Index           =   0
               Left            =   1220
               TabIndex        =   68
               Top             =   675
               Width           =   420
            End
            Begin VB.Label EveryLabel 
               BackStyle       =   0  'Transparent
               Caption         =   "Every"
               BeginProperty Font 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Height          =   255
               Left            =   120
               TabIndex        =   66
               Top             =   680
               Width           =   645
            End
         End
         Begin VB.PictureBox PlotBox 
            AutoRedraw      =   -1  'True
            BackColor       =   &H00000000&
            Height          =   1710
            Left            =   120
            ScaleHeight     =   110
            ScaleMode       =   3  'Pixel
            ScaleWidth      =   247
            TabIndex        =   60
            Top             =   240
            Width           =   3765
            Begin VB.Shape Shape2 
               FillColor       =   &H0000FF00&
               FillStyle       =   6  'Cross
               Height          =   1695
               Left            =   0
               Top             =   0
               Width           =   6000
            End
         End
         Begin VB.Label Label3 
            BackColor       =   &H00FF8080&
            BackStyle       =   0  'Transparent
            Caption         =   "www.siliconchip.com.au"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Index           =   1
            Left            =   3940
            TabIndex        =   90
            Top             =   1800
            Width           =   2055
         End
         Begin VB.Image Image4 
            Height          =   480
            Left            =   3930
            Picture         =   "Serial IO Controller.frx":5C329
            Stretch         =   -1  'True
            Top             =   800
            Width           =   460
         End
         Begin VB.Label Label3 
            BackColor       =   &H00FF8080&
            Caption         =   "TX RX"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   405
            Index           =   0
            Left            =   6000
            TabIndex        =   69
            Top             =   1605
            Width           =   255
         End
         Begin VB.Image SCLEDOFF 
            Height          =   225
            Left            =   5700
            Picture         =   "Serial IO Controller.frx":5C633
            Top             =   1700
            Width           =   225
         End
         Begin VB.Image SCLEDON 
            Height          =   225
            Left            =   5700
            Picture         =   "Serial IO Controller.frx":5C947
            Top             =   1700
            Width           =   225
         End
         Begin VB.Image SCLogo 
            Height          =   555
            Left            =   4380
            Picture         =   "Serial IO Controller.frx":5CC5B
            Stretch         =   -1  'True
            Top             =   1275
            Width           =   1860
         End
         Begin VB.Label ShowPlotMinValue 
            BackStyle       =   0  'Transparent
            Caption         =   "25"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   255
            Left            =   3945
            TabIndex        =   65
            Top             =   1450
            Width           =   405
         End
         Begin VB.Label ShowPlotMaxValue 
            BackStyle       =   0  'Transparent
            Caption         =   "100 °C"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   3960
            TabIndex        =   64
            Top             =   270
            Width           =   420
         End
      End
      Begin VB.Frame Frame7 
         BackColor       =   &H00FF8080&
         Caption         =   "  [ Closed Loop Control Using Relay 2]   "
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   1830
         Index           =   1
         Left            =   3275
         TabIndex        =   43
         Top             =   2370
         Width           =   3150
         Begin VB.TextBox Relay2ClosedLoopControlVal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   300
            Index           =   1
            Left            =   2200
            TabIndex        =   52
            Top             =   645
            Width           =   800
         End
         Begin VB.TextBox Relay2ClosedLoopControlVal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   300
            Index           =   2
            Left            =   2200
            MaxLength       =   5
            TabIndex        =   50
            Top             =   1005
            Width           =   800
         End
         Begin VB.TextBox Relay2ClosedLoopControlVal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   300
            Index           =   3
            Left            =   2200
            TabIndex        =   48
            Top             =   1365
            Width           =   800
         End
         Begin VB.ComboBox Relay2ClosedLoopControlVariable 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   3
            ItemData        =   "Serial IO Controller.frx":8A2DF
            Left            =   1080
            List            =   "Serial IO Controller.frx":8A2F2
            TabIndex        =   44
            Text            =   "Temp"
            Top             =   1350
            Width           =   855
         End
         Begin VB.ComboBox Relay2ClosedLoopControlVariable 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   2
            ItemData        =   "Serial IO Controller.frx":8A314
            Left            =   1080
            List            =   "Serial IO Controller.frx":8A327
            TabIndex        =   45
            Text            =   "Temp"
            Top             =   990
            Width           =   855
         End
         Begin VB.ComboBox Relay2ClosedLoopControlVariable 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   1
            ItemData        =   "Serial IO Controller.frx":8A349
            Left            =   1080
            List            =   "Serial IO Controller.frx":8A35C
            TabIndex        =   46
            Text            =   "Temp"
            Top             =   630
            Width           =   855
         End
         Begin VB.TextBox Relay2ClosedLoopControlVal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   300
            Index           =   0
            Left            =   2200
            MaxLength       =   5
            TabIndex        =   54
            Top             =   280
            Width           =   800
         End
         Begin VB.ComboBox Relay2ClosedLoopControlVariable 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   0
            ItemData        =   "Serial IO Controller.frx":8A37E
            Left            =   1080
            List            =   "Serial IO Controller.frx":8A391
            TabIndex        =   47
            Text            =   "Temp"
            Top             =   270
            Width           =   855
         End
         Begin VB.CheckBox Relay2ClosedLoopControlOnIfLessThan 
            BackColor       =   &H00FF8080&
            Caption         =   "ON,  IF                         <"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   55
            Top             =   240
            Width           =   2100
         End
         Begin VB.CheckBox Relay2ClosedLoopControlOnIfGreaterThan 
            BackColor       =   &H00FF8080&
            Caption         =   "ON,  IF                         >"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   53
            Top             =   600
            Value           =   1  'Checked
            Width           =   2220
         End
         Begin VB.CheckBox Relay2ClosedLoopControlOffIfLessThan 
            BackColor       =   &H00FF8080&
            Caption         =   "OFF, IF                         <"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   51
            Top             =   960
            Width           =   2100
         End
         Begin VB.CheckBox Relay2ClosedLoopControlOffIfGreaterThan 
            BackColor       =   &H00FF8080&
            Caption         =   "OFF, IF                         >"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   49
            Top             =   1320
            Value           =   1  'Checked
            Width           =   2100
         End
      End
      Begin VB.Frame Frame7 
         BackColor       =   &H00FF8080&
         Caption         =   "  [ Closed Loop Control Using Relay 1]   "
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   1830
         Index           =   0
         Left            =   120
         TabIndex        =   30
         Top             =   2370
         Width           =   3150
         Begin VB.ComboBox Relay1ClosedLoopControlVariable 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   3
            ItemData        =   "Serial IO Controller.frx":8A3B3
            Left            =   1080
            List            =   "Serial IO Controller.frx":8A3C6
            TabIndex        =   42
            Text            =   "Temp"
            Top             =   1350
            Width           =   855
         End
         Begin VB.ComboBox Relay1ClosedLoopControlVariable 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   2
            ItemData        =   "Serial IO Controller.frx":8A3E8
            Left            =   1080
            List            =   "Serial IO Controller.frx":8A3FB
            TabIndex        =   41
            Text            =   "Temp"
            Top             =   990
            Width           =   855
         End
         Begin VB.ComboBox Relay1ClosedLoopControlVariable 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   1
            ItemData        =   "Serial IO Controller.frx":8A41D
            Left            =   1080
            List            =   "Serial IO Controller.frx":8A430
            TabIndex        =   40
            Text            =   "Temp"
            Top             =   630
            Width           =   855
         End
         Begin VB.ComboBox Relay1ClosedLoopControlVariable 
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Index           =   0
            ItemData        =   "Serial IO Controller.frx":8A452
            Left            =   1080
            List            =   "Serial IO Controller.frx":8A465
            TabIndex        =   39
            Text            =   "Temp"
            Top             =   270
            Width           =   855
         End
         Begin VB.TextBox Relay1ClosedLoopControlVal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   300
            Index           =   3
            Left            =   2200
            TabIndex        =   38
            Top             =   1365
            Width           =   800
         End
         Begin VB.CheckBox Relay1ClosedLoopControlOffIfGreaterThan 
            BackColor       =   &H00FF8080&
            Caption         =   "OFF, IF                         >"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   37
            Top             =   1320
            Value           =   1  'Checked
            Width           =   2220
         End
         Begin VB.TextBox Relay1ClosedLoopControlVal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   300
            Index           =   2
            Left            =   2200
            MaxLength       =   5
            TabIndex        =   36
            Top             =   1005
            Width           =   800
         End
         Begin VB.CheckBox Relay1ClosedLoopControlOffIfLessThan 
            BackColor       =   &H00FF8080&
            Caption         =   "OFF, IF                         <"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   35
            Top             =   960
            Width           =   2220
         End
         Begin VB.TextBox Relay1ClosedLoopControlVal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   300
            Index           =   1
            Left            =   2200
            TabIndex        =   34
            Top             =   645
            Width           =   800
         End
         Begin VB.CheckBox Relay1ClosedLoopControlOnIfGreaterThan 
            BackColor       =   &H00FF8080&
            Caption         =   "ON,  IF                         >"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   33
            Top             =   600
            Value           =   1  'Checked
            Width           =   2220
         End
         Begin VB.TextBox Relay1ClosedLoopControlVal 
            Alignment       =   2  'Center
            BackColor       =   &H000000FF&
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   300
            Index           =   0
            Left            =   2200
            MaxLength       =   5
            TabIndex        =   32
            Top             =   280
            Width           =   800
         End
         Begin VB.CheckBox Relay1ClosedLoopControlOnIfLessThan 
            BackColor       =   &H00FF8080&
            Caption         =   "ON,  IF                         <"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   375
            Left            =   120
            TabIndex        =   31
            Top             =   240
            Width           =   2220
         End
      End
      Begin VB.Shape Shape4 
         Height          =   4115
         Left            =   75
         Top             =   150
         Width           =   6415
      End
      Begin VB.Shape Shape3 
         BackColor       =   &H8000000F&
         BackStyle       =   1  'Opaque
         BorderColor     =   &H00C0C0C0&
         Height          =   135
         Left            =   120
         Top             =   2265
         Width           =   6300
      End
      Begin VB.Line Line2 
         BorderColor     =   &H00000000&
         BorderWidth     =   10
         X1              =   0
         X2              =   6600
         Y1              =   0
         Y2              =   0
      End
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   2040
      Top             =   3480
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   327680
      CommPort        =   2
      DTREnable       =   -1  'True
      InputLen        =   1
      BaudRate        =   2400
   End
   Begin VB.Menu MenuSetup 
      Caption         =   "       &System"
      Begin VB.Menu SystemCommPort 
         Caption         =   "Comm Port"
         Begin VB.Menu CommPort 
            Caption         =   "Comm 1"
            Checked         =   -1  'True
            Index           =   0
         End
         Begin VB.Menu CommPort 
            Caption         =   "Comm 2"
            Index           =   1
         End
         Begin VB.Menu CommPort 
            Caption         =   "Comm 3"
            Index           =   2
         End
         Begin VB.Menu CommPort 
            Caption         =   "Comm 4"
            Index           =   3
         End
         Begin VB.Menu CommPort 
            Caption         =   "Comm 5"
            Index           =   4
         End
         Begin VB.Menu CommPort 
            Caption         =   "Comm 6"
            Index           =   5
         End
         Begin VB.Menu CommPort 
            Caption         =   "Comm 7"
            Index           =   6
         End
         Begin VB.Menu CommPort 
            Caption         =   "Comm 8"
            Index           =   7
         End
      End
      Begin VB.Menu SystemConnect 
         Caption         =   "Connect..."
         Shortcut        =   {F1}
      End
      Begin VB.Menu SystemDisconnect 
         Caption         =   "Disconnect"
         Shortcut        =   {F2}
      End
      Begin VB.Menu Bar1 
         Caption         =   "-"
      End
      Begin VB.Menu SystemCalibration 
         Caption         =   "Calibration"
         Shortcut        =   {F3}
      End
      Begin VB.Menu SystemReset 
         Caption         =   "Reset..."
         Shortcut        =   {F4}
      End
      Begin VB.Menu Bar2 
         Caption         =   "-"
      End
      Begin VB.Menu SystemExit 
         Caption         =   "     < Exit >"
      End
   End
   Begin VB.Menu MenuDataLogging 
      Caption         =   "&Data Logging"
   End
   Begin VB.Menu MenuAlarmsAndTimers 
      Caption         =   "&Alarms && Timers"
   End
   Begin VB.Menu MenuIOLogic 
      Caption         =   "&Combination IO Logic"
   End
   Begin VB.Menu MenuAbout 
      Caption         =   "&About"
   End
End
Attribute VB_Name = "GUI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Form_Load()
'*************************************************************************
'Windows-based software for Silicon Chip Serial IO Controller Published
'November 2005. Entire application created using Visual Basic 5. By taking
'full advantage of OOP, software allows for some very nifty features
'*************************************************************************
'**Copyright, ©2005 - 2006 Silicon Chip Publications All Rights Reserved**
'*************************************************************************
'Beta release (1.0-1.2), inital release 30/11/05
'*Bug fixes*
'1) Fixes XP comms errors.
'2) Improved accuracy with logging intervals
'#########################################################################
'Beta release 1.3, update submitted 12/05/06
'*Bug fixes*
'1) Nasty crasher for long duration usage. Complete crash when logger ran
'   out of memory. Int overflow.
'#########################################################################
'Beta release 1.4, update submitted 30/06/06
'*Bug fixes*
'1) Memory leaks and incorrect declaration of some variables.
'2) Full tidy up of source.
'#########################################################################

'Begin
   Load GUI
   GUI.Hide
'well, this is the first piece of software to ever be branded with the DSE
'name. DSE logo is even animated on startup.
'hide all bmps to begin with, set visible property to false
   For LoopX = 0 To 8
       Splash.DSE(LoopX).Visible = False
   Next
   Splash.Show
'init startup variables
   UpdateInterval = 100
   LogTimerCount = 1
   LogTimerLoop = 1
   AutoLogTimerCount = 1
   AutoLogTimerLoop = 1
   PlotTimerCount = 1
   PlotTimerLoop = 1
   Call LoadConfiguration
'---------------------------------
'------ Init & Null Settings -----
'---------------------------------
   For LoopX = 0 To 9
       BitSet(LoopX) = False
   Next
'Load table with dec bit values, (1-10)
   BitValTable(0) = 1
   BitValTable(1) = 2
   BitValTable(2) = 4
   BitValTable(3) = 8
   BitValTable(4) = 16
   BitValTable(5) = 32
   BitValTable(6) = 64
   BitValTable(7) = 128
   BitValTable(8) = 256
   BitValTable(9) = 512
'deafult MScomm settings
   MSComm1.Settings = "2400, n,8, 1"
   DegreesCelsius = 0
'Load temperature table with values -275 to 275°
   For LoopX = 550 To 0 Step -1
       TempDegrees(LoopX) = Str(DegreesCelsius)
       DegreesCelsius = DegreesCelsius - 0.5
   Next

   DegreesCelsius = 0
   
   For LoopX = 551 To 1024
       TempDegrees(LoopX) = Str(DegreesCelsius)
       DegreesCelsius = DegreesCelsius + 0.5
   Next

   Voltage = 0.05
'Load analog channel 1 table with values (0 - 5)V   4.9mV steps
   For LoopX = 0 To 1024
       VCCTable(LoopX) = Str(Voltage)
       Voltage = Voltage + 0.0049
   Next

   Voltage = 0.05
'load analog channel 2 table with values (0 - 25)V   24.5mV steps
   For LoopX = 0 To 1024
       VCCTable2(LoopX) = Str(Voltage)
       Voltage = Voltage + 0.0245
   Next
'set all virtual LEDs off
   For LoopX = 0 To 9
       InputLEDON(LoopX).Visible = False
       InputLEDOFF(LoopX).Visible = True
       OutputLEDON(LoopX).Visible = False
       OutputLEDOFF(LoopX).Visible = True
   Next

   FastUpdateVariable.ListIndex = 3
   CurrentStatus = "   Not Connected"
'flush port
   Call ResetPorts
'load other GUIs
   Load DataLogging
   Load AlarmsTimers
   Load IOLogic
   Load CalElements
End Sub

Private Sub PlotUpdateInterval_Change()
   PlotTimerLoop = Val(PlotUpdateInterval.Text) - 1
   PlotTimerCount = PlotTimerLoop
End Sub

Private Sub SerialDataController()
   Do While Connected = True
      DoEvents
      On Error Resume Next
'virtual led proc flashes led in sync with comms TX/RX
      Call TXLEDProc

      If Mode(1).Value Then
         ToggleFunction = Val(FastUpdateVariable.ListIndex)
         PlotVariable.ListIndex = ToggleFunction
         
         If PlotVariable.Text <> "Input" Then
            SecsLabel(0).Visible = False
            EveryLabel.Visible = False
            PlotUpdateInterval.Visible = False
            ShowFastUpdate.Visible = True
            Call UpdatePlotter
            Sleep 0.1
         End If
      Else
'Increment auto function selection, temp, light, analog 1, analog 2 inputs sequentially
         For LoopX = 0 To Int(UpdateInterval / 10)
             Sleep 10
             DoEvents
             Call ManualToggleRelays
             Call Write10BitData
             Call ToggleBuzzer
             Call CheckTimers
         Next
'inc function to do
         ToggleFunction = ToggleFunction + 1
         ToggleFunction = ToggleFunction Mod 5
         SecsLabel(0).Visible = True
         EveryLabel.Visible = True
         PlotUpdateInterval.Visible = True
         ShowFastUpdate.Visible = False
      End If
   
      If ToggleFunction = 0 Then 'Temperature
         CurrentStatus = "   Now Reading Temperature":
         For LoopX = 0 To 2
             MSComm1.Output = "a" + Chr(1)
             Temperature = ""
             Buffer = ""
             ENDSTR = False
             StartSTR = False
             
             Do Until ENDSTR = True
                NoDataTimeOut = NoDataTimeOut + 1
                If NoDataTimeOut > 128000 Then GoSub LostComms
                If NoDataTimeOut > 8000 Then DoEvents 'yeild to OS if stuck
                Call ReadTemp
             Loop
         Next
      End If

      If ToggleFunction = 1 Then 'LDR resistance value
         CurrentStatus = "   Now Reading The LDR Resistance":
         MSComm1.Output = "a" + Chr(2)
         Light = ""
         Buffer = ""
         ENDSTR = False
         StartSTR = False
      
         Do Until ENDSTR = True
            NoDataTimeOut = NoDataTimeOut + 1
            If NoDataTimeOut > 128000 Then GoSub LostComms
            If NoDataTimeOut > 8000 Then DoEvents
            Call ReadLight
         Loop
      End If

      If ToggleFunction = 2 Then 'Analog input 1, (0-5) VDC
         CurrentStatus = "   Now Reading Analog Input 1"
         MSComm1.Output = "a" + Chr(4)
         VCC1 = ""
         Buffer = ""
         ENDSTR = False
         StartSTR = False

         Do Until ENDSTR = True
            NoDataTimeOut = NoDataTimeOut + 1
            If NoDataTimeOut > 128000 Then GoSub LostComms
            If NoDataTimeOut > 8000 Then DoEvents
            Call ReadVCC1
         Loop
      End If

      If ToggleFunction = 3 Then 'Analog input 2, (0-25) VDC
         CurrentStatus = "   Now Reading Analog Input 2"
         MSComm1.Output = "a" + Chr(3)
         VCC2 = ""
         Buffer = ""
         ENDSTR = False
         StartSTR = False

         Do Until ENDSTR = True
            NoDataTimeOut = NoDataTimeOut + 1
            If NoDataTimeOut > 128000 Then GoSub LostComms
            If NoDataTimeOut > 8000 Then DoEvents
            Call ReadVCC2
         Loop
      End If

      If ToggleFunction = 4 Then   'Digital inputs
         CurrentStatus = "   Now Reading 10 BIT Digital Inputs "
         MSComm1.Output = "a" + Chr(7)
         InputDecimalData = ""
         Buffer = ""
         ENDSTR = False
         StartSTR = False
           
         Do Until ENDSTR = True
            NoDataTimeOut = NoDataTimeOut + 1
            If NoDataTimeOut > 128000 Then GoSub LostComms
            If NoDataTimeOut > 8000 Then DoEvents
            Call Read10BitData
         Loop
            
         Call IOLogicControlProc
         Call ClosedLoopControlForInput
         Call BuzzerAlertForInput
      End If
'reset error variable since no error occured
      NoDataTimeOut = 0
   Loop
'=========
LostComms:
'=========
   CurrentStatus = "   Communications Error!...":
   MSComm1.PortOpen = False 'close port
   NoDataTimeOut = 0
   ToggleFunction = 0
'wait 8mS and open it again, this will normally resolve most issues
   Sleep 8
   MSComm1.PortOpen = True
   DoEvents
   Return
End Sub

Public Sub ReadTemp()
   On Error Resume Next
'load string buffer with byte
   Buffer = MSComm1.Input
'loop until end of string byte = "@"
   If Buffer = "@" Then
'Add calibration in offset variable
      IntBuffer = Val(Temperature + TempCal)
      Temperature = Str(IntBuffer)
'maintain a steady reading, no flickering from .5 to 1
'load new value only LSB + 1 is > last value
      If Val(Temperature) = Val(PreviousTempSample) + 1 Or Val(Temperature) = Val(PreviousTempSample) - 1 Then
         Temperature = PreviousTempSample
      End If

      ShowTemperature.Text = Trim(TempDegrees(IntBuffer))
      ENDSTR = True
      PreviousTempSample = Temperature
'calc plot
      If PlotVariable.Text = "Temp" Then
         AnalogBuffer = Val(Int(Temperature - 560) / 1.75)
         OkToPlot = True
      End If
           
      Call ClosedLoopControlForTemp
      Call BuzzerAlertForTemp
           
      If DataLogging.LogVariable.Text = "Temp" Then
         OkToLog = True
      End If
   End If
     
   If StartSTR = True And ENDSTR = False Then
      Temperature = Temperature + Buffer
   End If
'start byte from MSComm "a"?, this is a sync byte and denotes start of
'valid string accept value and load the rest of the string
   If Buffer = "a" Then StartSTR = True
End Sub

Public Sub ReadLight()
  On Error Resume Next
   Buffer = MSComm1.Input
   If Buffer = "@" Then
      If Val(Light) = Val(PreviousLightVal) + 1 Or Val(Light) = Val(PreviousLightVal) - 1 Then
         Light = PreviousLightVal
      End If
     
      LDRVCC = Val((Light + LDRCal) * 0.004887585533)
      IShunt = (LDRVCC / 10000)
      LDRResistance = Int((5 - LDRVCC) / IShunt)
      ShowResistance.Text = Trim(Str(LDRResistance))
      StartSTR = False
      ENDSTR = True
      PreviousLightVal = Light
     
      If PlotVariable.Text = "LDR" Then
         AnalogBuffer = Int(LDRResistance * 0.0011)
         OkToPlot = True
      End If
     
      Call ClosedLoopControlForLDR
      Call BuzzerAlertForLDR
      If DataLogging.LogVariable.Text = "LDR" Then OkToLog = True
   End If
   If StartSTR = True And ENDSTR = False Then
      Light = Light + Buffer
   End If
'got sync byte?
   If Buffer = "a" Then StartSTR = True
End Sub

Public Sub ReadVCC1()
   On Error Resume Next
   Buffer = MSComm1.Input
   If Buffer = "@" Then
      If Val(VCC1) <> 0 Then
         IntBuffer = Val(VCC1 + AN1Cal)
         ShowAnalog1.Text = Format(Val(VCCTable(IntBuffer)), "0.00")
         VCC1 = Trim(Str(IntBuffer))
         Call ClosedLoopControlForVCC1
         Call BuzzerAlertForVCC1
         ENDSTR = True
         If PlotVariable.Text = "AN 1" Then
            AnalogBuffer = IntBuffer * 0.107421
            OkToPlot = True
         End If
         If DataLogging.LogVariable.Text = "AN 1" Then
            OkToLog = True
         End If
      Else
         ShowAnalog1.Text = "0.00"
         ENDSTR = True
      End If
   End If
   If StartSTR = True And ENDSTR = False Then
      VCC1 = VCC1 + Buffer
   End If
   If Buffer = "a" Then StartSTR = True
End Sub

Public Sub ReadVCC2()
   On Error Resume Next
   Buffer = MSComm1.Input
   If Buffer = "@" Then
      If Val(VCC2) <> 0 Then
         IntBuffer = Val(VCC2 + An2Cal)
         VCC2 = Trim(Str(IntBuffer))
         ShowAnalog2.Text = Format(Val(VCCTable2(IntBuffer)), "0.00")
         Call ClosedLoopControlForVCC2
         Call BuzzerAlertForVCC2
         ENDSTR = True
         If PlotVariable.Text = "AN 2" Then
            AnalogBuffer = IntBuffer * 0.107421
            OkToPlot = True
         End If
         If DataLogging.LogVariable.Text = "AN 2" Then
            OkToLog = True
         End If
      Else
         ShowAnalog2.Text = "0.00"
         ENDSTR = True
      End If
   End If
   If StartSTR = True And ENDSTR = False Then
      VCC2 = VCC2 + Buffer
   End If
   If Buffer = "a" Then StartSTR = True
End Sub

Public Sub Read10BitData()
   On Error Resume Next
   Buffer = MSComm1.Input
   If Buffer = "@" Then
      ShowInputDecimal.Text = InputDecimalData
      ENDSTR = True
      Call UpdateVirtualInputLEDS
      
      If DataLogging.LogVariable.Text = "Input" Then
         OkToLog = True
      End If
   End If

   If StartSTR = True And ENDSTR = False Then
      InputDecimalData = InputDecimalData + Buffer
   End If
   
   If Buffer = "a" Then StartSTR = True
End Sub

Public Sub Write10BitData()
   If RequestToSend10BitData = True Then
      MSComm1.Output = "a" + Chr(8)
      CurrentStatus = "   Requesting To Write Data To 10 BIT Port "
      Call Delay100mS
      PortDecimalData = 0

      For LoopX = 0 To 7
          If BitSet(LoopX) = True Then
             PortDecimalData = PortDecimalData + BitValTable(LoopX)
          End If
      Next

      MSComm1.Output = "a" + Chr(PortDecimalData)
      RequestToSend10BitData = False
      Call Delay100mS
      Bit8ToPort = 0
      Bit9ToPort = 0
      If BitSet(8) = True Then Bit8ToPort = 1
      If BitSet(9) = True Then Bit9ToPort = 1
      MSComm1.Output = "a" + Chr(Bit8ToPort) + Chr(Bit9ToPort)
   End If
End Sub

Public Sub ToggleBuzzer()
   If RequestToSoundBuzzer = True Then
      MSComm1.Output = "a" + Chr(6)
      CurrentStatus = "   Requesting To Activate Buzzer "
      Call Delay100mS
      MSComm1.Output = "a" + Chr(BuzzerStatus)
      RequestToSoundBuzzer = False
   End If
End Sub

Public Sub ManualToggleRelays()

   If RequestToToggleRLY1 = True Then
      MSComm1.Output = "a" + Chr(5)
      CurrentStatus = "   Requesting To Toggle Relay 1 "
      Call Delay100mS
      ToggleRLY1 = ToggleRLY1 + 1
      ToggleRLY1 = ToggleRLY1 Mod 2
      MSComm1.Output = "a" + Chr(1) + Chr(ToggleRLY1)
      RequestToToggleRLY1 = False
   End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
   If RequestToToggleRLY2 = True Then
      MSComm1.Output = "a" + Chr(5)
      CurrentStatus = "   Requesting To Toggle Relay 2 "
      Call Delay100mS
      ToggleRLY2 = ToggleRLY2 + 1
      ToggleRLY2 = ToggleRLY2 Mod 2
      MSComm1.Output = "a" + Chr(2) + Chr(ToggleRLY2)
      RequestToToggleRLY2 = False
   End If
End Sub

Public Sub UpdatePlotter()
   On Error Resume Next
   If EnablePlotter.Value = 1 Then
      If PreviousPlotY = 0 Then GoTo NoLineJoin
         For LoopX = PreviousPlotY To AnalogBuffer
             PlotBox.PSet (PlotX, 110 - LoopX + 1), vbWhite
             PlotBox.PSet (PlotX + 1, 110 - LoopX + 1), vbWhite
             PlotBox.PSet (PlotX + 2, 110 - LoopX + 1), vbWhite
         Next

         For LoopX = AnalogBuffer To PreviousPlotY
             PlotBox.PSet (PlotX, 110 - LoopX), vbWhite
             PlotBox.PSet (PlotX + 1, 110 - LoopX + 1), vbWhite
             PlotBox.PSet (PlotX + 2, 110 - LoopX + 1), vbWhite
         Next
'==========
NoLineJoin:
'==========
         For LoopX = 0 To 10
             PlotBox.PSet (PlotX, 110 - AnalogBufer), vbWhite
             PlotBox.PSet (PlotX, (110 - AnalogBuffer) + 1), vbWhite
             PlotBox.PSet (PlotX, (110 - AnalogBuffer) + 2), vbWhite
             PlotX = PlotX + 1
             If PlotX > 248 Then PlotBox.Cls: PlotX = 0: PlotBox.Refresh
         Next
         OkToPlot = False
         PreviousPlotY = Int(AnalogBuffer)
   End If
End Sub

Private Sub OutputLEDON_Click(Index As Integer)
   OutputLEDON(Index).Visible = False
   OutputLEDOFF(Index).Visible = True
   BitSet(Index) = False
   DecimalOutputValue = 0
                              
   For LoopX = 0 To 9
       If BitSet(LoopX) = True Then
          DecimalOutputValue = DecimalOutputValue + BitValTable(LoopX)
       End If
   Next
            
   ShowOutputDecimal.Text = Trim(Str(DecimalOutputValue))
   ShowOutputHEX.Text = Trim(Hex(DecimalOutputValue))
End Sub

Private Sub OutputLEDOFF_Click(Index As Integer)
   OutputLEDON(Index).Visible = True
   OutputLEDOFF(Index).Visible = False
   BitSet(Index) = True
   DecimalOutputValue = 0
                             
   For LoopX = 0 To 9
       If BitSet(LoopX) = True Then
          DecimalOutputValue = DecimalOutputValue + BitValTable(LoopX)
       End If
   Next
   
   ShowOutputDecimal.Text = Trim(Str(DecimalOutputValue))
   ShowOutputHEX.Text = Trim(Hex(DecimalOutputValue))
End Sub

Public Sub ResetPorts()
   ToggleRLY1 = 1
   ToggleRLY2 = 1
   BuzzerStatus = 0

   For LoopX = 0 To 9
       InputLEDON(LoopX).Visible = False
       InputLEDOFF(LoopX).Visible = True
       OutputLEDON(LoopX).Visible = False
       OutputLEDOFF(LoopX).Visible = True
       BitSet(LoopX) = False
   Next

   RequestToSend10BitData = True
   ShowOutputDecimal.Text = "0"
   ShowOutputHEX.Text = "0"
   RequestToToggleRLY1 = True
   RequestToToggleRLY2 = True
End Sub

Private Sub PlotVariable_Click()
   Select Case PlotVariable.Text
          Case "Temp"
               ShowPlotMaxValue.Caption = "100 °C"
               ShowPlotMinValue.Caption = "25"
               ShowPlotMinValue.Top = 1400

          Case "AN 1"
               ShowPlotMaxValue.Caption = "5 V"
               ShowPlotMinValue.Caption = "GND"
               ShowPlotMinValue.Top = 1650

          Case "AN 2"
               ShowPlotMaxValue.Caption = "25 V"
               ShowPlotMinValue.Caption = "GND"
               ShowPlotMinValue.Top = 1650

          Case "LDR"
               ShowPlotMaxValue.Caption = "100K"
               ShowPlotMinValue.Caption = "15K"
               ShowPlotMinValue.Top = 1400
   End Select

   PlotBox.Cls
   PlotX = 0
   PreviousPlotY = 0
End Sub

Private Sub PlotBox_DblClick()
   PlotBox.Cls
   PlotX = 0
   PreviousPlotY = 0
End Sub

Private Sub AutoLog_Timer()
   On Error Resume Next
   If AutoLogTimerCount <> 0 Then
      AutoLogTimerCount = AutoLogTimerCount - 1
   Else
      AutoLogTimerCount = AutoLogTimerLoop
      If DataLogging.EnableAutoLogSave.Value = 1 Then
         Open App.Path & "\Auto Log.log" For Output As #1
              For LoopX = 1 To DataLogging.MSFlexGrid1.Row
                  For LoopZ = 0 To 3
                      Print #1, DataLogging.MSFlexGrid1.TextMatrix(LoopX, LoopZ)
                  Next
              Next
         Close #1
      End If
   End If
End Sub

Private Sub CommPortSelection_Click()
   On Error GoTo PortError
   If MSComm1.PortOpen = True Then
      MSComm1.PortOpen = False
   End If
   MSComm1.CommPort = CommPortSelection.ListIndex + 1
   MSComm1.PortOpen = True
            
   For LoopX = 0 To 7
       CommPort(LoopX).Checked = False
   Next
   CommPort(CommPortSelection.ListIndex).Checked = True
   Exit Sub
'=========
PortError:
'=========
'don't show error MSG on start up
   If ViewSplashTime < 32 Then Exit Sub
   IntBuffer = MsgBox("Port Already In Use Or Doesn't Exist!" + Chr$(13) + "Please" _
   + " Choose A Different Port." _
   , vbOKOnly + vbExclamation + vbDefaultButton2, "Communications Error")
   
   For LoopX = 0 To 7
       CommPort(LoopX).Checked = False
   Next
   CommPort(CommPortSelection.ListIndex).Checked = True
End Sub

Private Sub PlotUpdateInterval_KeyPress(KeyAscii As Integer)
   If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = 8)) Then KeyAscii = 0
End Sub

Private Sub SampleUpdateInterval_KeyPress(KeyAscii As Integer)
   If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = 8)) Then KeyAscii = 0
End Sub

Private Sub Relay1ClosedLoopControlVal_KeyPress(Index As Integer, KeyAscii As Integer)
   If KeyAscii = 46 Then Exit Sub
   If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = 8)) Then KeyAscii = 0
End Sub

Private Sub Relay2ClosedLoopControlVal_KeyPress(Index As Integer, KeyAscii As Integer)
   If KeyAscii = 46 Then Exit Sub
   If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = 8)) Then KeyAscii = 0
End Sub

Private Sub ClosedLoopControlVal_KeyPress(Index As Integer, KeyAscii As Integer)
   If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = 8)) Then KeyAscii = 0
End Sub

Private Sub ShowOutputDecimal_KeyPress(KeyAscii As Integer)
   If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = 8)) Then KeyAscii = 0
End Sub

Private Sub ShowOutputHEX_Change()
   HexValue = Trim(ShowOutputHEX.Text)
   Call HexConversion
   PortDecimalData = HexToDecimalValue
   Call UpdateVirtualOutputLEDS
End Sub

Private Sub ShowOutputDecimal_Change()
   PortDecimalData = ShowOutputDecimal.Text
   Call UpdateVirtualOutputLEDS
End Sub

Private Sub EnablePlotter_Click()
   If PlotTimer.Enabled = False Then
      PlotTimer.Enabled = True
   Else
      PlotTimer.Enabled = False
   End If
End Sub

Public Sub TXLEDProc()
'flash virtual LED below SC logo to indicate that there is indeed some action going on.
   If SCLEDON.Visible = False Then
      SCLEDON.Visible = True
      SCLEDOFF.Visible = False
   Else
      SCLEDON.Visible = False
      SCLEDOFF.Visible = True
   End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
'save configuration to disk
   Open App.Path & "\System.config" For Output As #1
'---------------------------------
'Save Closed Loop Control Settings
'------------ Relay 1 ------------
'---------------------------------
        For LoopX = 0 To 3
            Print #1, Relay1ClosedLoopControlVariable(LoopX).Text
            Print #1, Relay1ClosedLoopControlVal(LoopX).Text
        Next

        Print #1, Relay1ClosedLoopControlOnIfLessThan.Value
        Print #1, Relay1ClosedLoopControlOnIfGreaterThan.Value
        Print #1, Relay1ClosedLoopControlOffIfLessThan.Value
        Print #1, Relay1ClosedLoopControlOffIfGreaterThan.Value
'---------------------------------
'Save Closed Loop Control Settings
'------------ Relay 2 ------------
'---------------------------------
        For LoopX = 0 To 3
            Print #1, Relay2ClosedLoopControlVariable(LoopX).Text
            Print #1, Relay2ClosedLoopControlVal(LoopX).Text
        Next

        Print #1, Relay2ClosedLoopControlOnIfLessThan.Value
        Print #1, Relay2ClosedLoopControlOnIfGreaterThan.Value
        Print #1, Relay2ClosedLoopControlOffIfLessThan.Value
        Print #1, Relay2ClosedLoopControlOffIfGreaterThan.Value
'---------------------------------
'Save Timer Settings  Events 1 & 2
'------------ Relay 1 ------------
'---------------------------------
        For LoopX = 0 To 1
            Print #1, AlarmsTimers.Relay1StartDay(LoopX).Text
            Print #1, AlarmsTimers.Relay1StartMonth(LoopX).Text
            Print #1, AlarmsTimers.Relay1StartYear(LoopX).Text

            Print #1, AlarmsTimers.Relay1StartHR(LoopX).Text
            Print #1, AlarmsTimers.Relay1StartMin(LoopX).Text
            Print #1, AlarmsTimers.Relay1StartSec(LoopX).Text

            Print #1, AlarmsTimers.Relay1StopDay(LoopX).Text
            Print #1, AlarmsTimers.Relay1StopMonth(LoopX).Text
            Print #1, AlarmsTimers.Relay1StopYear(LoopX).Text

            Print #1, AlarmsTimers.Relay1StopHR(LoopX).Text
            Print #1, AlarmsTimers.Relay1StopMin(LoopX).Text
            Print #1, AlarmsTimers.Relay1StopSec(LoopX).Text
        Next

        Print #1, AlarmsTimers.Relay1EnableEvent1
        Print #1, AlarmsTimers.Relay1EnableEvent2
        Print #1, AlarmsTimers.Relay1UseDate(0)
        Print #1, AlarmsTimers.Relay1UseDate(1)
        Print #1, AlarmsTimers.Relay1StartTimeStatus(0)
        Print #1, AlarmsTimers.Relay1StartTimeStatus(1)
        Print #1, AlarmsTimers.Relay1StopTimeStatus(0)
        Print #1, AlarmsTimers.Relay1StopTimeStatus(1)
'---------------------------------
'Save Timer Settings  Events 1 & 2
'------------ Relay 2 ------------
'---------------------------------
        For LoopX = 0 To 1
            Print #1, AlarmsTimers.Relay2StartDay(LoopX).Text
            Print #1, AlarmsTimers.Relay2StartMonth(LoopX).Text
            Print #1, AlarmsTimers.Relay2StartYear(LoopX).Text

            Print #1, AlarmsTimers.Relay2StartHR(LoopX).Text
            Print #1, AlarmsTimers.Relay2StartMin(LoopX).Text
            Print #1, AlarmsTimers.Relay2StartSec(LoopX).Text

            Print #1, AlarmsTimers.Relay2StopDay(LoopX).Text
            Print #1, AlarmsTimers.Relay2StopMonth(LoopX).Text
            Print #1, AlarmsTimers.Relay2StopYear(LoopX).Text

            Print #1, AlarmsTimers.Relay2StopHR(LoopX).Text
            Print #1, AlarmsTimers.Relay2StopMin(LoopX).Text
            Print #1, AlarmsTimers.Relay2StopSec(LoopX).Text
        Next

        Print #1, AlarmsTimers.Relay2EnableEvent1
        Print #1, AlarmsTimers.Relay2EnableEvent2
        Print #1, AlarmsTimers.Relay2UseDate(0)
        Print #1, AlarmsTimers.Relay2UseDate(1)
        Print #1, AlarmsTimers.Relay2StartTimeStatus(0)
        Print #1, AlarmsTimers.Relay2StartTimeStatus(1)
        Print #1, AlarmsTimers.Relay2StopTimeStatus(0)
        Print #1, AlarmsTimers.Relay2StopTimeStatus(1)
'---------------------------------
'-- Save Buzzer Alert Settings ---
'---------- Condition 1 ----------
'---------------------------------
        For LoopX = 0 To 3
            Print #1, AlarmsTimers.BuzzerAlertVariableCondition1(LoopX).Text
            Print #1, AlarmsTimers.Condition1BuzzerAlertVal(LoopX).Text
        Next

        Print #1, AlarmsTimers.Condition1BuzzerOnIfLessThan.Value
        Print #1, AlarmsTimers.Condition1BuzzerOnIfGreaterThan.Value
        Print #1, AlarmsTimers.Condition1BuzzerOffIfLessThan.Value
        Print #1, AlarmsTimers.Condition1BuzzerOffIfGreaterThan.Value
'---------------------------------
'-- Save Buzzer Alert Settings ---
'---------- Condition 2 ----------
'---------------------------------
        For LoopX = 0 To 3
            Print #1, AlarmsTimers.BuzzerAlertVariableCondition2(LoopX).Text
            Print #1, AlarmsTimers.Condition2BuzzerAlertVal(LoopX).Text
        Next

        Print #1, AlarmsTimers.Condition2BuzzerOnIfLessThan.Value
        Print #1, AlarmsTimers.Condition2BuzzerOnIfGreaterThan.Value
        Print #1, AlarmsTimers.Condition2BuzzerOffIfLessThan.Value
        Print #1, AlarmsTimers.Condition2BuzzerOffIfGreaterThan.Value
'---------------------------------
'-- Save Buzzer Alert Settings ---
'---------- Condition 3 ----------
'---------------------------------
        For LoopX = 0 To 3
            Print #1, AlarmsTimers.BuzzerAlertVariableCondition3(LoopX).Text
            Print #1, AlarmsTimers.Condition3BuzzerAlertVal(LoopX).Text
        Next

        Print #1, AlarmsTimers.Condition3BuzzerOnIfLessThan.Value
        Print #1, AlarmsTimers.Condition3BuzzerOnIfGreaterThan.Value
        Print #1, AlarmsTimers.Condition3BuzzerOffIfLessThan.Value
        Print #1, AlarmsTimers.Condition3BuzzerOffIfGreaterThan.Value
'---------------------------------
'Save Calibration Offset Variables
'---------------------------------
        Print #1, CalElements.ShowTempOffset.Text
        Print #1, CalElements.ShowLDROffset.Text
        Print #1, CalElements.ShowAN1Offset.Text
        Print #1, CalElements.ShowAN2Offset.Text
'---------------------------------
'----- Save Comm Port Number -----
'---------------------------------
        Print #1, MSComm1.CommPort
'---------------------------------
'----- Save Logger Settings  -----
'---------------------------------
        Print #1, DataLogging.LogUpdateInterval.Text
        Print #1, DataLogging.AutoSaveUpdateInterval.Text
        Print #1, DataLogging.EnableLogDate.Value
        Print #1, DataLogging.EnableLogTime.Value
        Print #1, DataLogging.AutoClearLog.Value
        Print #1, DataLogging.EnableAutoLogSave.Value
        Print #1, DataLogging.EnableLog.Value
'---------------------------------
'----- Save Plotter Settings  ----
'---------------------------------
        Print #1, PlotUpdateInterval.Text
        Print #1, EnablePlotter.Value
'---------------------------------
'----- Save IO Logic Settings ----
'---------------------------------
        Print #1, IOLogic.LatchIOLogicOuputs.Value
        Print #1, IOLogic.XORIOLogic.Value
        Print #1, IOLogic.InvertIOLogic.Value

   Close #1

   If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
   For LoopX = Forms.Count - 1 To 0 Step -1
       Unload Forms(LoopX)
   Next
   End
End Sub

Private Sub LogTimer_Timer()
   If LogTimerCount <> 0 Then
      LogTimerCount = LogTimerCount - 1
   Else
      If OkToLog = True Then
         Call LoggingProc
         OkToLog = False
      End If
      LogTimerCount = LogTimerLoop
   End If
End Sub

Private Sub PlotTimer_Timer()
   On Error Resume Next
   If PlotTimerCount <> 0 Then
      PlotTimerCount = PlotTimerCount - 1
   Else
      If OkToPlot = True Then
         Call UpdatePlotter
         OkToPlot = False
      End If
      PlotTimerCount = PlotTimerLoop
   End If
End Sub

Private Sub SampleUpdateInterval_Change()
   On Error Resume Next
   UpdateInterval = Val(SampleUpdateInterval.Text)
End Sub

Private Sub MenuAbout_Click()
   Splash.Show
   For LoopX = 0 To 8
       Splash.DSE(LoopX).Visible = False
   Next
   ViewSplashTime = 0
   DSELogo = 0
   FadeOutDSE = False
End Sub

Private Sub StatusBar_Timer()
   On Error Resume Next
   If Connected = False Then
      CurrentStatus = "   Not Connected"
   End If
   StatusBar1.SimpleText = CurrentStatus
   
   If ViewSplashTime < 255 Then
      ViewSplashTime = ViewSplashTime + 1
      ToggleDSELogo = ToggleDSELogo + 1
      If ToggleDSELogo = 4 Then
         If FadeOutDSE = False Then
            DSELogo = DSELogo + 1: ToggleDSELogo = 0
            If DSELogo = 9 Then
               DSELogo = 8
               FadeOutDSE = True
            End If
            Splash.DSE(DSELogo).Visible = True
            Splash.DSE(DSELogo - 1).Visible = False
         Else
            DSELogo = DSELogo - 1
            ToggleDSELogo = 0
            If DSELogo = 0 Then FadeOutDSE = False
            Splash.DSE(DSELogo).Visible = True
            Splash.DSE(DSELogo + 1).Visible = False
         End If
      End If
   End If
'hide splash and show main gui
   If ViewSplashTime = 254 Then
      GUI.Show
      Splash.Hide
   End If
End Sub

Private Sub SystemConnect_Click()
   Connected = True
   Call SerialDataController
End Sub

Private Sub Connect_Click()
   Connected = True
   Call SerialDataController
End Sub

Private Sub BuzzerON_Click()
   RequestToSoundBuzzer = True
   BuzzerStatus = 1
End Sub

Private Sub BuzzerOFF_Click()
   RequestToSoundBuzzer = True
   BuzzerStatus = 0
End Sub

Private Sub Form_Resize()
   On Error Resume Next
   If GUI.Width > 10200 Then GUI.Width = 10200
   If GUI.Height > 8400 Then GUI.Height = 8400
End Sub

Private Sub CommPort_Click(Index As Integer)
   For LoopX = 0 To 7
       CommPort(LoopX).Checked = False
   Next
   CommPort(Index).Checked = True
   CommPortSelection.ListIndex = Index
End Sub

Public Sub LoadConfiguration()
'Open & load settings from configuration file
   On Error GoTo NoConfigFile
   Open App.Path & "\System.config" For Input As #1
        Do Until EOF(1)
'---------------------------------
'Open Closed Loop Control Settings
'------------ Relay 1 ------------
'---------------------------------
            For LoopX = 0 To 3
                Line Input #1, StrBuffer
                Relay1ClosedLoopControlVariable(LoopX).Text = StrBuffer
                Line Input #1, StrBuffer
                Relay1ClosedLoopControlVal(LoopX).Text = StrBuffer
            Next

            Line Input #1, StrBuffer
            Relay1ClosedLoopControlOnIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            Relay1ClosedLoopControlOnIfGreaterThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            Relay1ClosedLoopControlOffIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            Relay1ClosedLoopControlOffIfGreaterThan.Value = StrBuffer
'---------------------------------
'Open Closed Loop Control Settings
'------------ Relay 2 ------------
'---------------------------------
            For LoopX = 0 To 3
                Line Input #1, StrBuffer
                Relay2ClosedLoopControlVariable(LoopX).Text = StrBuffer
                Line Input #1, StrBuffer
                Relay2ClosedLoopControlVal(LoopX).Text = StrBuffer
            Next

            Line Input #1, StrBuffer
            Relay2ClosedLoopControlOnIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            Relay2ClosedLoopControlOnIfGreaterThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            Relay2ClosedLoopControlOffIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            Relay2ClosedLoopControlOffIfGreaterThan.Value = StrBuffer
'---------------------------------
'Open Timer Settings  Events 1 & 2
'------------ Relay 1 ------------
'---------------------------------
            For LoopZ = 0 To 1
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StartDay(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StartMonth(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StartYear(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StartHR(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StartMin(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StartSec(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StopDay(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StopMonth(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StopYear(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StopHR(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StopMin(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay1StopSec(LoopZ).Text = StrBuffer
            Next

            Line Input #1, StrBuffer
            AlarmsTimers.Relay1EnableEvent1.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay1EnableEvent2.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay1UseDate(0).Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay1UseDate(1).Value = Val(StrBuffer)

            Line Input #1, StrBuffer
            AlarmsTimers.Relay1StartTimeStatus(0).Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay1StartTimeStatus(1).Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay1StopTimeStatus(0).Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay1StopTimeStatus(1).Value = StrBuffer
'---------------------------------
'Open Timer Settings  Events 1 & 2
'------------ Relay 2 ------------
'---------------------------------
            For LoopZ = 0 To 1
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StartDay(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StartMonth(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StartYear(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StartHR(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StartMin(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StartSec(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StopDay(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StopMonth(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StopYear(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StopHR(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StopMin(LoopZ).Text = StrBuffer
            
                Line Input #1, StrBuffer
                AlarmsTimers.Relay2StopSec(LoopZ).Text = StrBuffer
            Next

            Line Input #1, StrBuffer
            AlarmsTimers.Relay2EnableEvent1.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay2EnableEvent2.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay2UseDate(0).Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay2UseDate(1).Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay2StartTimeStatus(0).Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay2StartTimeStatus(1).Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay2StopTimeStatus(0).Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Relay2StopTimeStatus(1).Value = StrBuffer
'---------------------------------
'-- Open Buzzer  Alert Settings --
'---------- Condition 1 ----------
'---------------------------------
            For LoopZ = 0 To 3
                Line Input #1, StrBuffer
                AlarmsTimers.BuzzerAlertVariableCondition1(LoopZ).Text = StrBuffer
                Line Input #1, StrBuffer
                AlarmsTimers.Condition1BuzzerAlertVal(LoopZ).Text = StrBuffer
            Next

            Line Input #1, StrBuffer
            AlarmsTimers.Condition1BuzzerOnIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition1BuzzerOnIfGreaterThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition1BuzzerOffIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition1BuzzerOffIfGreaterThan.Value = StrBuffer
'---------------------------------
'-- Open Buzzer  Alert Settings --
'---------- Condition 2 ----------
'---------------------------------
            For LoopZ = 0 To 3
                Line Input #1, StrBuffer
                AlarmsTimers.BuzzerAlertVariableCondition2(LoopZ).Text = StrBuffer
                Line Input #1, StrBuffer
                AlarmsTimers.Condition2BuzzerAlertVal(LoopZ).Text = StrBuffer
            Next

            Line Input #1, StrBuffer
            AlarmsTimers.Condition2BuzzerOnIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition2BuzzerOnIfGreaterThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition2BuzzerOffIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition2BuzzerOffIfGreaterThan.Value = StrBuffer
'---------------------------------
'-- Open Buzzer  Alert Settings --
'---------- Condition 2 ----------
'---------------------------------
            For LoopZ = 0 To 3
                Line Input #1, StrBuffer
                AlarmsTimers.BuzzerAlertVariableCondition3(LoopZ).Text = StrBuffer
                Line Input #1, StrBuffer
                AlarmsTimers.Condition3BuzzerAlertVal(LoopZ).Text = StrBuffer
            Next

            Line Input #1, StrBuffer
            AlarmsTimers.Condition3BuzzerOnIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition3BuzzerOnIfGreaterThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition3BuzzerOffIfLessThan.Value = StrBuffer
            
            Line Input #1, StrBuffer
            AlarmsTimers.Condition3BuzzerOffIfGreaterThan.Value = StrBuffer
'---------------------------------
'Load Offset Calibration Variables
'---------------------------------
            Line Input #1, StrBuffer
            CalElements.ShowTempOffset.Text = StrBuffer
            TempCal = Val(StrBuffer)
            TempOffset = TempCal

            Line Input #1, StrBuffer
            CalElements.ShowLDROffset.Text = StrBuffer
            LDRCal = Val(StrBuffer)
            LDROffset = LDRCal

            Line Input #1, StrBuffer
            CalElements.ShowAN1Offset.Text = StrBuffer
            AN1Cal = Val(StrBuffer)
            AN1Offset = AN1Cal

            Line Input #1, StrBuffer
            CalElements.ShowAN2Offset.Text = StrBuffer
            An2Cal = Val(StrBuffer)
            An2Offset = An2Cal

'---------------------------------
'----- Open Comm Port Number -----
'---------------------------------
            Line Input #1, StrBuffer
            CommPortSelection.ListIndex = Val(StrBuffer - 1)

'---------------------------------
'----- Open Logger Settings ------
'---------------------------------
            Line Input #1, StrBuffer
            DataLogging.LogUpdateInterval.Text = StrBuffer
            
            Line Input #1, StrBuffer
            DataLogging.AutoSaveUpdateInterval.Text = StrBuffer
            
            Line Input #1, StrBuffer
            DataLogging.EnableLogDate.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            DataLogging.EnableLogTime.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            DataLogging.AutoClearLog.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            DataLogging.EnableAutoLogSave.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            DataLogging.EnableLog.Value = Val(StrBuffer)
            
'---------------------------------
'----- Open Plotter Settings -----
'---------------------------------
            Line Input #1, StrBuffer
            PlotUpdateInterval.Text = StrBuffer
            
            Line Input #1, StrBuffer
            EnablePlotter.Value = Val(StrBuffer)

'---------------------------------
'----- Open IO Logic Settings ----
'---------------------------------
            Line Input #1, StrBuffer
            IOLogic.LatchIOLogicOuputs.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            IOLogic.XORIOLogic.Value = Val(StrBuffer)
            
            Line Input #1, StrBuffer
            IOLogic.InvertIOLogic.Value = Val(StrBuffer)
     Loop

'Load plotter update variable
      PlotTimerLoop = Val(PlotUpdateInterval.Text) - 1
      PlotTimerCount = PlotTimerLoop
'Load auto log update variable
      AutoLogTimerLoop = Val(AutoSaveUpdateInterval.Text) - 1
      AutoLogTimerCount = AutoLogTimerLoop
'Load logger update variable with val
      LogTimerLoop = Val(LogUpdateInterval.Text) - 1
      LogTimerCount = LogTimerLoop
'Enable logging if set
      If DataLogging.EnableLog.Value = 1 Then
         GUI.LogTimer.Enabled = True
      Else
         GUI.LogTimer.Enabled = False
      End If
'Enable auto save logging if set
      If DataLogging.EnableAutoLogSave.Value = 1 Then
         AutoLog.Enabled = True
      Else
         AutoLog.Enabled = False
      End If
'============
NoConfigFile:
'============
   Close #1
End Sub

Private Sub SystemExit_Click()
   Unload Me
End Sub

Private Sub SystemReset_Click()
   Call ResetPorts
End Sub

Private Sub Calibration_Click()
   CalElements.Show
End Sub

Private Sub AlarmsAndTimers_Click()
   AlarmsTimers.Show
End Sub

Private Sub MenuAlarmsAndTimers_Click()
   AlarmsTimers.Show
End Sub

Private Sub MenuDataLogging_Click()
   DataLogging.Show
End Sub

Private Sub MenuIOLogic_Click()
   IOLogic.Show
End Sub

Public Sub UpdateStatusBar()
   StatusBar1.SimpleText = CurrentStatus
End Sub

Private Sub RefreshOutputPort_Click()
   RequestToSend10BitData = True
End Sub

Private Sub RLY1_Click()
   RequestToToggleRLY1 = True
End Sub

Private Sub RLY2_Click()
   RequestToToggleRLY2 = True
End Sub

Private Sub SystemDisconnect_Click()
   Connected = False
End Sub

Private Sub CombinationIOLogic_Click()
   IOLogic.Show
End Sub

Private Sub ShowDataLogging_Click()
   DataLogging.Show
End Sub

Private Sub ResetSys_Click()
   Call ResetPorts
End Sub

Private Sub SystemCalibration_Click()
   CalElements.Show
End Sub

