VERSION 5.00 Begin VB.Form frmServo Caption = "Test Servo" ClientHeight = 7020 ClientLeft = 60 ClientTop = 450 ClientWidth = 15015 LinkTopic = "Form1" ScaleHeight = 7020 ScaleWidth = 15015 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmsSave Caption = "Save Settings" Height = 495 Left = 360 TabIndex = 72 Top = 6360 Width = 1575 End Begin VB.Frame Frame1 Height = 2775 Index = 7 Left = 11400 TabIndex = 63 Top = 3480 Width = 3495 Begin VB.CommandButton cmdClear Caption = "CLR" Height = 255 Index = 7 Left = 2400 TabIndex = 80 Top = 1800 Width = 495 End Begin VB.CommandButton cmdServoOn Caption = "Servo ON" Height = 375 Index = 7 Left = 2160 TabIndex = 69 Top = 360 Width = 1095 End Begin VB.TextBox txtMotor Height = 375 Index = 7 Left = 840 TabIndex = 68 Top = 360 Width = 975 End Begin VB.TextBox txtPos Alignment = 2 'Center BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 7 Left = 1080 MultiLine = -1 'True TabIndex = 67 Top = 1560 Width = 1215 End Begin VB.HScrollBar hsPos Height = 255 Index = 7 LargeChange = 100 Left = 240 Max = 900 Min = -900 SmallChange = 9 TabIndex = 66 Top = 2280 Width = 2895 End Begin VB.TextBox txtSpeed Height = 375 Index = 7 Left = 840 TabIndex = 65 Text = "15" Top = 840 Width = 975 End Begin VB.CommandButton cmdSpeed Caption = "Speed" Height = 375 Index = 7 Left = 2160 TabIndex = 64 Top = 840 Width = 1095 End Begin VB.Label Label1 Caption = "Motor" Height = 255 Index = 7 Left = 120 TabIndex = 71 Top = 360 Width = 615 End Begin VB.Label Label2 Caption = "Speed" Height = 255 Index = 7 Left = 120 TabIndex = 70 Top = 840 Width = 615 End End Begin VB.Frame Frame1 Height = 2775 Index = 6 Left = 7680 TabIndex = 54 Top = 3480 Width = 3495 Begin VB.CommandButton cmdClear Caption = "CLR" Height = 255 Index = 6 Left = 2400 TabIndex = 79 Top = 1800 Width = 495 End Begin VB.CommandButton cmdSpeed Caption = "Speed" Height = 375 Index = 6 Left = 2160 TabIndex = 60 Top = 840 Width = 1095 End Begin VB.TextBox txtSpeed Height = 375 Index = 6 Left = 840 TabIndex = 59 Text = "15" Top = 840 Width = 975 End Begin VB.HScrollBar hsPos Height = 255 Index = 6 LargeChange = 100 Left = 240 Max = 900 Min = -900 SmallChange = 9 TabIndex = 58 Top = 2280 Width = 2895 End Begin VB.TextBox txtPos Alignment = 2 'Center BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 6 Left = 1080 MultiLine = -1 'True TabIndex = 57 Top = 1560 Width = 1215 End Begin VB.TextBox txtMotor Height = 375 Index = 6 Left = 840 TabIndex = 56 Top = 360 Width = 975 End Begin VB.CommandButton cmdServoOn Caption = "Servo ON" Height = 375 Index = 6 Left = 2160 TabIndex = 55 Top = 360 Width = 1095 End Begin VB.Label Label2 Caption = "Speed" Height = 255 Index = 6 Left = 120 TabIndex = 62 Top = 840 Width = 615 End Begin VB.Label Label1 Caption = "Motor" Height = 255 Index = 6 Left = 120 TabIndex = 61 Top = 360 Width = 615 End End Begin VB.Frame Frame1 Height = 2775 Index = 5 Left = 3840 TabIndex = 45 Top = 3480 Width = 3495 Begin VB.CommandButton cmdClear Caption = "CLR" Height = 255 Index = 5 Left = 2400 TabIndex = 78 Top = 1800 Width = 495 End Begin VB.CommandButton cmdSpeed Caption = "Speed" Height = 375 Index = 5 Left = 2160 TabIndex = 51 Top = 840 Width = 1095 End Begin VB.TextBox txtSpeed Height = 375 Index = 5 Left = 840 TabIndex = 50 Text = "15" Top = 840 Width = 975 End Begin VB.HScrollBar hsPos Height = 255 Index = 5 LargeChange = 90 Left = 240 Max = 900 Min = -900 SmallChange = 9 TabIndex = 49 Top = 2280 Width = 2895 End Begin VB.TextBox txtPos Alignment = 2 'Center BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 5 Left = 1080 MultiLine = -1 'True TabIndex = 48 Top = 1560 Width = 1215 End Begin VB.TextBox txtMotor Height = 375 Index = 5 Left = 840 TabIndex = 47 Top = 360 Width = 975 End Begin VB.CommandButton cmdServoOn Caption = "Servo ON" Height = 375 Index = 5 Left = 2160 TabIndex = 46 Top = 360 Width = 1095 End Begin VB.Label Label2 Caption = "Speed" Height = 255 Index = 5 Left = 120 TabIndex = 53 Top = 840 Width = 615 End Begin VB.Label Label1 Caption = "Motor" Height = 255 Index = 5 Left = 120 TabIndex = 52 Top = 360 Width = 615 End End Begin VB.Frame Frame1 Height = 2775 Index = 4 Left = 120 TabIndex = 36 Top = 3480 Width = 3495 Begin VB.CommandButton cmdClear Caption = "CLR" Height = 255 Index = 4 Left = 2400 TabIndex = 77 Top = 1800 Width = 495 End Begin VB.CommandButton cmdSpeed Caption = "Speed" Height = 375 Index = 4 Left = 2160 TabIndex = 42 Top = 840 Width = 1095 End Begin VB.TextBox txtSpeed Height = 375 Index = 4 Left = 840 TabIndex = 41 Text = "15" Top = 840 Width = 975 End Begin VB.HScrollBar hsPos Height = 255 Index = 4 LargeChange = 100 Left = 240 Max = 900 Min = -900 SmallChange = 9 TabIndex = 40 Top = 2280 Width = 2895 End Begin VB.TextBox txtPos Alignment = 2 'Center BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 4 Left = 1080 MultiLine = -1 'True TabIndex = 39 Top = 1560 Width = 1215 End Begin VB.TextBox txtMotor Height = 375 Index = 4 Left = 840 TabIndex = 38 Top = 360 Width = 975 End Begin VB.CommandButton cmdServoOn Caption = "Servo ON" Height = 375 Index = 4 Left = 2160 TabIndex = 37 Top = 360 Width = 1095 End Begin VB.Label Label2 Caption = "Speed" Height = 255 Index = 4 Left = 120 TabIndex = 44 Top = 840 Width = 615 End Begin VB.Label Label1 Caption = "Motor" Height = 255 Index = 4 Left = 120 TabIndex = 43 Top = 360 Width = 615 End End Begin VB.Frame Frame1 Height = 2775 Index = 3 Left = 11400 TabIndex = 27 Top = 480 Width = 3495 Begin VB.CommandButton cmdClear Caption = "CLR" Height = 255 Index = 3 Left = 2400 TabIndex = 76 Top = 1800 Width = 495 End Begin VB.CommandButton cmdServoOn Caption = "Servo ON" Height = 375 Index = 3 Left = 2160 TabIndex = 33 Top = 360 Width = 1095 End Begin VB.TextBox txtMotor Height = 375 Index = 3 Left = 840 TabIndex = 32 Top = 360 Width = 975 End Begin VB.TextBox txtPos Alignment = 2 'Center BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 3 Left = 1080 MultiLine = -1 'True TabIndex = 31 Top = 1560 Width = 1215 End Begin VB.HScrollBar hsPos Height = 255 Index = 3 LargeChange = 100 Left = 240 Max = 900 Min = -900 SmallChange = 9 TabIndex = 30 Top = 2280 Width = 2895 End Begin VB.TextBox txtSpeed Height = 375 Index = 3 Left = 840 TabIndex = 29 Text = "15" Top = 840 Width = 975 End Begin VB.CommandButton cmdSpeed Caption = "Speed" Height = 375 Index = 3 Left = 2160 TabIndex = 28 Top = 840 Width = 1095 End Begin VB.Label Label1 Caption = "Motor" Height = 255 Index = 3 Left = 120 TabIndex = 35 Top = 360 Width = 615 End Begin VB.Label Label2 Caption = "Speed" Height = 255 Index = 3 Left = 120 TabIndex = 34 Top = 840 Width = 615 End End Begin VB.Frame Frame1 Height = 2775 Index = 2 Left = 7680 TabIndex = 18 Top = 480 Width = 3495 Begin VB.CommandButton cmdClear Caption = "CLR" Height = 255 Index = 2 Left = 2520 TabIndex = 75 Top = 1800 Width = 495 End Begin VB.CommandButton cmdServoOn Caption = "Servo ON" Height = 375 Index = 2 Left = 2160 TabIndex = 24 Top = 360 Width = 1095 End Begin VB.TextBox txtMotor Height = 375 Index = 2 Left = 840 TabIndex = 23 Top = 360 Width = 975 End Begin VB.TextBox txtPos Alignment = 2 'Center BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 2 Left = 1080 MultiLine = -1 'True TabIndex = 22 Top = 1560 Width = 1215 End Begin VB.HScrollBar hsPos Height = 255 Index = 2 LargeChange = 100 Left = 240 Max = 900 Min = -900 SmallChange = 9 TabIndex = 21 Top = 2280 Width = 2895 End Begin VB.TextBox txtSpeed Height = 375 Index = 2 Left = 840 TabIndex = 20 Text = "15" Top = 840 Width = 975 End Begin VB.CommandButton cmdSpeed Caption = "Speed" Height = 375 Index = 2 Left = 2160 TabIndex = 19 Top = 840 Width = 1095 End Begin VB.Label Label1 Caption = "Motor" Height = 255 Index = 2 Left = 120 TabIndex = 26 Top = 360 Width = 615 End Begin VB.Label Label2 Caption = "Speed" Height = 255 Index = 2 Left = 120 TabIndex = 25 Top = 840 Width = 615 End End Begin VB.Frame Frame1 Height = 2775 Index = 1 Left = 3840 TabIndex = 9 Top = 480 Width = 3495 Begin VB.CommandButton cmdClear Caption = "CLR" Height = 255 Index = 1 Left = 2520 TabIndex = 74 Top = 1800 Width = 495 End Begin VB.CommandButton cmdServoOn Caption = "Servo ON" Height = 375 Index = 1 Left = 2160 TabIndex = 15 Top = 360 Width = 1095 End Begin VB.TextBox txtMotor Height = 375 Index = 1 Left = 840 TabIndex = 14 Top = 360 Width = 975 End Begin VB.TextBox txtPos Alignment = 2 'Center BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 1 Left = 1080 MultiLine = -1 'True TabIndex = 13 Top = 1560 Width = 1215 End Begin VB.HScrollBar hsPos Height = 255 Index = 1 LargeChange = 100 Left = 240 Max = 900 Min = -900 SmallChange = 9 TabIndex = 12 Top = 2280 Width = 2895 End Begin VB.TextBox txtSpeed Height = 375 Index = 1 Left = 840 TabIndex = 11 Text = "15" Top = 840 Width = 975 End Begin VB.CommandButton cmdSpeed Caption = "Speed" Height = 375 Index = 1 Left = 2160 TabIndex = 10 Top = 840 Width = 1095 End Begin VB.Label Label1 Caption = "Motor" Height = 255 Index = 1 Left = 120 TabIndex = 17 Top = 360 Width = 615 End Begin VB.Label Label2 Caption = "Speed" Height = 255 Index = 1 Left = 120 TabIndex = 16 Top = 840 Width = 615 End End Begin VB.Frame Frame1 Height = 2775 Index = 0 Left = 120 TabIndex = 0 Top = 480 Width = 3495 Begin VB.CommandButton cmdClear Caption = "CLR" Height = 255 Index = 0 Left = 2400 TabIndex = 73 Top = 1800 Width = 495 End Begin VB.CommandButton cmdSpeed Caption = "Speed" Height = 375 Index = 0 Left = 2160 TabIndex = 7 Top = 840 Width = 1095 End Begin VB.TextBox txtSpeed Height = 375 Index = 0 Left = 840 TabIndex = 6 Text = "15" Top = 840 Width = 975 End Begin VB.HScrollBar hsPos Height = 255 Index = 0 LargeChange = 100 Left = 240 Max = 900 Min = -900 SmallChange = 9 TabIndex = 4 Top = 2280 Width = 2895 End Begin VB.TextBox txtPos Alignment = 2 'Center BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Index = 0 Left = 1080 MultiLine = -1 'True TabIndex = 3 Top = 1560 Width = 1215 End Begin VB.TextBox txtMotor Height = 375 Index = 0 Left = 840 TabIndex = 2 Top = 360 Width = 975 End Begin VB.CommandButton cmdServoOn Caption = "Servo ON" Height = 375 Index = 0 Left = 2160 TabIndex = 1 Top = 360 Width = 1095 End Begin VB.Label Label2 Caption = "Speed" Height = 255 Index = 0 Left = 120 TabIndex = 8 Top = 840 Width = 615 End Begin VB.Label Label1 Caption = "Motor" Height = 255 Index = 0 Left = 120 TabIndex = 5 Top = 360 Width = 615 End End End Attribute VB_Name = "frmServo" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub cmdClear_Click(index As Integer) txtPos(index).Text = "0" End Sub Private Sub cmdServoOn_Click(index As Integer) frmMain.Send (Chr(2) + txtMotor(index).Text + "iFF") End Sub Private Sub cmdSpeed_Click(index As Integer) Dim Speed As Integer Speed = Val(txtSpeed(index).Text) Speed = Speed + 128 frmMain.Send (Chr(2) + txtMotor(index).Text + "s" + Hex(Speed)) End Sub Private Sub cmsSave_Click() Dim SFile As Integer Dim i As Integer ' Save settings SFile = FreeFile(0) Open CurrentDir For Output As #SFile For i = 0 To 7 Print #SFile, txtMotor(i).Text Print #SFile, txtSpeed(i).Text Next i Close #SFile End Sub Private Sub Form_Load() Dim i, index As Integer Dim SFile As Integer Dim Basa As String 'Load settings SFile = FreeFile(0) On Error GoTo Bye Open CurrentDir For Input As #SFile For index = 0 To 7 Input #SFile, Basa i = Val(Basa) txtMotor(index).Text = i txtPos(index).Text = MotPos(i) Input #SFile, Basa txtSpeed(index) = Basa Next index Close #SFile Bye: End Sub Private Sub hsPos_Change(index As Integer) Dim Position As Single Dim Mstring As String Position = hsPos(index).Value / 10 txtPos(index).Text = Position 'convert single to raw position Position = (Position * 100 / 90) + 150 Mstring = Right("0" + txtMotor(index).Text, 2) frmMain.Send (Chr(2) + Mstring + "m" + Hex(Position)) End Sub Private Sub txtPos_Change(index As Integer) hsPos(index).Value = Val(txtPos(index).Text) * 10 End Sub