PneuDoor

ftComputing : Programme für die fischertechnik-Interfaces und -konstruktionskästen
  
ftComputing.de
Home
Back
Sitemap
Index
Links
Impressum
Mail
 

Pneumatic Robots : Pneumatic Door

Visual Basic 6 & FishN632.DLL

PneuDoor.MDL is the application for the Modell "Pneumatic Door" of the kitElektromagnetisches 3/2 Ventil "Pneumatic Robots". Here you will find a Visual 6 Version using FishFa50.OCX. The program is constructed like the original LLWin application. Its a simple version to show Visual Basic beginners an alternative programming concept to LLWin. In the following some details are discussed. The complete program is in PneuTuer.ZIP. Additional you need the basis software FishFa50.OCX (FishFa50.ZIP or vbFish20Setup.EXE).

Constants

' --- Constants -----------------------

Const cvTuerAuf = 1, cvTuerZu = 2 ' --- 3/2-way solenoid valve
Const ctTuerZu = 1 ' --- switch
Const cpLichtSchranke = 2 ' --- photoresistor
Const clLichtSchranke = 3 ' --- lamp
Const cmKompressor = 4 ' --- motor

The constants are used within the program to make it more readable.

To be done to start and end

On the form is placed a FishFa50 control named ft

' --- Initialize the program ---

' --- Connection to the interface
If ft.OpenInterface("COM1") = ftiFehler Then ' --- COM1 ---
                                                                        ' or an appropriate value
MsgBox "InterfaceProblem", vbExclamation + vbOKOnly, "PneuTuer"
Unload Me
End If

in Form_Unload : Close the interface connection

ft.CloseInterface

Routines to operate the PneuDoor (like PneuDoor.MDL)

Private Sub TuerMain()
' --- main : endless Do ... Loop which ends with ft.NotHalt = true

  Init                               ' --- to starting position
  Do                                 ' --- Loop until ft.NotHalt
    ft.WaitForInput ctTuerZu, False  ' --- wait until door is
                                     '     opened a bit
    TuerAuf                          ' --- full door opening
    ft.WaitForInput cpLichtSchranke, False ' close door if light
                                     '     barrier is broken
    TuerZu                           ' --- close door
  Loop Until ft.NotHalt
End Sub

Private Sub Init()
' --- Initialize -----------
  ft.SetMotor clLichtSchranke, ftiEin ' --- lamp light barrier on
  ft.SetMotor cmKompressor, ftiEin    ' --- compressor on
  ft.WaitForTime 6000           ' --- wait for pressure
  ft.SetMotor cvTuerAuf, ftiAus ' --- close door
  ft.SetMotor cvTuerZu, ftiEin  ' --- closing valve on
  ft.WaitForInput ctTuerZu      ' --- wait for door closed
  ft.SetMotor cvTuerZu, ftiAus  ' --- closing valve off
End Sub

Private Sub TuerAuf()
' --- open door --------
  ft.SetMotor cvTuerZu, ftiAus   ' --- closing valve off
  ft.SetMotor cvTuerAuf, ftiEin  ' --- opening valve on
  ft.WaitForTime 500             ' --- wait for open
  ft.SetMotor cvTuerAuf, ftiAus  ' --- opening valve off
End Sub

Private Sub TuerZu()
' --- Close door ---
  ft.SetMotor cvTuerAuf, ftiAus ' --- opening valve off
  ft.SetMotor cvTuerZu, ftiEin  ' --- closing valve on
  ft.WaitForInput ctTuerZu      ' --- wait for close
  ft.SetMotor cvTuerZu, ftiAus  ' --- closing valve off
End Sub

Controlling the operations

Private Sub cmdAction_Click()
' --- Start / Ending door control ---
If cmdAction.Caption = "START" Then ' --- Start
  cmdEnde.Enabled = False     ' to prevent ending when loop is 
                              '   running
  cmdAction.Caption = "HALT"  ' --- START changes to HALT (loop)
  ft.NotHalt = False          ' --- reset end request
  TuerMain                    ' --- door control
Else                          ' --- Beenden
  ft.NotHalt = True           ' --- end request 
End If
' --- end
  ft.ClearMotors              ' all M-Outputs off
  cmdEnde.Enabled = True      ' allow ENDE
  cmdAction.Caption = "START" ' allow a new START 
  cmdEnde.SetFocus
End Sub

In this case the LLWin solution is easier : you only must push the Run button.