Docsity

Lecture 1: Introduction to Graphical User Interfaces and Visual Basic, Study notes of Mechanical Engineering

Toggle sidebar
bg1
Lecture 1
1
Lecture 1 - Graphical User Interfaces
History
• BASIC (Beginner’s All-purpose Symbolic Instruction Code) mid-1960’s,
Kemeny and Kurtz Dartmouth
• Text-based languages and Structured Programming
• Graphical User Interfaces: Xerox, Apple and Microsoft mid-1980’s
• Graphical-based languages: late 80s and early 90s
Visual Basic
• First introduced in 1991 by Microsoft
• Integrated Development Environment (IDE) allows high-level programming
• Access to low-level Application Programming Interface (API)
• Recyclable code with ActiveX technologies – Distributed Computing
(controls, documents and components) due to COM (Common Object
Model) – Arguably similar to Java
• Object-Oriented Programming
• Winsock client/server
• Advantages: short learning curve, rapid deployment, front-end
development, large programming base, databases, ActiveX/COM
integration with other Microsoft products (VBA), VBScript, Windows CE for
embedded/portables
• Disadvantages: slow, large executables, run-time, interpreted language,
no (immediately) available port-mapped I/O capability
Alternatives
• Microsoft VC++: low-level API and high-level MFC, fast, longer learning
curve
• Java: program once-run anywhere paradigm, promising, C/C++
programming base, embedded applications, client/server, JavaScript
• Xwindows: Sun-based widgets
• TCL/TK: portable, interpreted language, rapid front-end development
• Delphi and Borland C++
pf3
pf4
pf5

Partial preview of the text

Download Lecture 1: Introduction to Graphical User Interfaces and Visual Basic and more Study notes Mechanical Engineering in PDF only on Docsity!

Lecture 1 - Graphical User Interfaces

History

  • BASIC (Beginner’s All-purpose Symbolic Instruction Code) mid-1960’s, Kemeny and Kurtz Dartmouth
  • Text-based languages and Structured Programming
  • Graphical User Interfaces: Xerox, Apple and Microsoft mid-1980’s
  • Graphical-based languages: late 80s and early 90s

Visual Basic

  • First introduced in 1991 by Microsoft
  • Integrated Development Environment (IDE) allows high-level programming
  • Access to low-level Application Programming Interface (API)
  • Recyclable code with ActiveX technologies – Distributed Computing (controls, documents and components) due to COM (Common Object Model) – Arguably similar to Java
  • Object-Oriented Programming
  • Winsock client/server
  • Advantages: short learning curve, rapid deployment, front-end development, large programming base, databases, ActiveX/COM integration with other Microsoft products (VBA), VBScript, Windows CE for embedded/portables
  • Disadvantages: slow, large executables, run-time, interpreted language, no (immediately) available port-mapped I/O capability

Alternatives

  • Microsoft VC++: low-level API and high-level MFC, fast, longer learning curve
  • Java: program once-run anywhere paradigm, promising, C/C++ programming base, embedded applications, client/server, JavaScript
  • Xwindows: Sun-based widgets
  • TCL/TK: portable, interpreted language, rapid front-end development
  • Delphi and Borland C++

Visual Basic Fundamentals:

  • Visual programming step: use VB’s visual tools for developing GUI and its components
  • Code programming step: define events for each component (e.g. Exit button)

Integrated Development Environment:

  • VB tool box: common components like buttons, labels, images, textboxes
  • Property box to define each component e.g. color, variable name, size
  • Code programming with built-in text editor
  • Executing and debug

Integrated Development Environment (IDE)

Naming Conventions

Typical Presentation of a VB Program:

  • Objects:

COMPONENT PREFIX Form frm Check box chk Combo box cbo Command button cmd Directory list dir Drive list drv File list fil Frame fra Grid grd Horizontal scrollbar hsb Image img Label lbl Line lin List box lst Menu mnu Option button opt Picture box pic Shape shp Text box txt Timer tmr Vertical scrollbar vsb

Object Property Setting

Form Name frmHelloWorld BackColor Blue Caption Hello World Program

Command Button Name cmdExit Caption E&xit

Command Button Name cmdClear Caption Clear

Command Button Name cmdDisplay Caption Display Hello World

Text Box Name txtHelloWorld Alignment 2-Center FontName System FontSize 10 Multiline True

  • Code

Option Explicit Private Sub cmdClear_Click() txtHelloWorld.Text = "" ' clear up display box End Sub

Private Sub cmdDisplay_Click() frmHelloWorld.BackColor = RGB(0, 255, 0)’Turn form green txtHelloWorld.Text = "Hello World!" End Sub

Private Sub cmdExit_Click() End End Sub

Stepper Motors

  • Shaft rotates a fixed amount for every voltage step (called resolution)
  • Shaft acceleration is ideally instantaneous
  • Shaft velocity proportional to step frequency
  • Typically used when shaft must rotate to a fixed angle/amount
  • Examples: hard drives, robot arms, pan-tilt units

Operation

  • Requires that voltage pulses be applied to each phase in sequence
  • Direction is reversed by reversing sequence
  • Requires knowing which lead corresponds to which phase. Ohmmeter used to identify phases:

Implementation

  • Naïve approach: use a 4 digital I/O lines and pulse in sequence
  • Typical: use logic sequencer chip e.g. Allegro 5804 that takes a single square wave input line.
  • L/R (pronounced L-over-R) uses pulse-width-modulation (PWM) also called a chopper: Higher voltage and hence higher current without burning motor coils.

Phase 1

Phase 2

Phase 4

Phase 3

Ground

Ground

or Voltage

or Voltage

Phase 1 Phase 2 Phase 3 Phase 4

+Stepper Rated Voltage Supply or GND line

Point A Point B Resistance Phase 1 Supply/GND line R Phase 1 Phase 2 2R Phase 2 Supply/GND line R Phase 2 Phase 3 Infinite Phase 1 Phase 3 Infinite Phase 3 Supply/GND line R Phase 3 Phase 4 2R Phase 4 Supply/GND line R