Electronic Design

  
Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


[Design Application]
Build Com Objects In Visual Basic For Your Embedded System Applications
VB developers can easily deploy COM applications for test and measurement, as well as many other client-server design projects.

Contributing Author  |   ED Online ID #4561  |   July 24, 2000


Due to the highly transparent integration of the Component Object Model (COM) into the Visual Basic (VB) development environment, VB developers are effectively programming and deploying COM applications today. Unlike their C/C++ counterparts, VB programmers build on concepts that they already know. There are no extra tools, such as the Microsoft Interface Definition Language (MIDL) compiler. Plus, there's no need to initialize the COM system or be aware of the COM runtime's existence because that's all simply integrated into the environment.

COM development is a natural fit for the test and measurement domain, as well as for many other embedded-system applications. Interfaces can be made in VB that correspond to the Standard Commands for Programmable instruments (SCPI) hierarchies. These de-fined interfaces combined with VB's development environment In-telliSense capability essentially eliminate the need for programming manuals.

Still, the value proposition of COM doesn't stop there. For instance, COM offers location independence. A COM object client doesn't know if the object is being used in the same process, across processes, or on an entirely different system. With minor changes, objects built in COM can be used in distributed scenarios. For the test and measurement world, the remote system could be an instrument running an embedded Win32 environment that hosts these COM objects.

The VB developer also can create an ActiveX control that encapsulates the programming model and adds visual controls that aid in setting the initial state of the COM object using Graphical User Interface (GUI) controls. That process previously would have taken multiple lines of programming.

Once proficient in the use of COM, the flexibility factor is seemingly limitless. Many Microsoft applications expose their features' programmability using COM technology. For example, the test and measurement developer can easily take measurements from an instrument and quickly insert them into a Microsoft Excel spreadsheet.

Finally, the environment doesn't lock a user's development efforts strictly to VB. Those COM objects developed in VB can either be used from C/C++, or from more traditional test and measurement visual environments, like Agilent Technologies' VEE and National Instruments' LabVIEW.

Start With Interfaces
When starting with COM, a user needs to begin with interfaces. Interfaces allow the programmer to separate the programmatic interface from an object's implementation. This separation allows COM to be characterized as a binary reuse model rather than a source reuse model found in C++ class hierarchies, which combine both implementation and interface.

Interfaces can be made that correspond to the subsystems found in a SCPI hierarchy. Interfaces additionally facilitate an object-oriented feature called "polymorphism," which allows a programmer to define interfaces that can be applied to dissimilar objects while accessing them in a similar manner.

Currently, the Interchangeable Virtual Instrument (IVI) Consortium is developing a standardization process that will define interchangeable instrument-class interfaces. Once IVI completes its work in this area, each manufacturer of a particular class of instrument (like an oscilloscope) will be able to implement the standardized class interface. Instrument users will then develop their test programs with this interface as the "abstraction," and enjoy the freedom of applying different hardware solutions in their test-system deployment.

Consider the development of a hypothetical test system involving a multimeter. The example instrument server defines a small subset of the Configure, Measure, and Trigger subsystems. The server factors in a new polymorphic interface, called the "IIEE488," to implement the standard IEEE-488 SCPI commands, such as reset and identification. To create a VB interface, the programmer creates a class with methods and properties definitions that don't contain any implementation code in their bodies.

The first step toward creating the instrument server entails invoking the VB development tool and selecting the ActiveX DLL icon in the new-project dialog box. After that is accomplished, the project name is changed from the default name of "project1" to "Multimeter," and the default class of "class1" to "Multimeter34401A."

Creating a new interface consists of selecting the "project" menu dropdown and the menu item Add Class Module. In the dialog that's launched from the menu selection, the developer chooses the new tab, the Class Module icon, and clicks on the "open" button. This action will cause the VB development tool to create a default class with the name "class1." Because a convention in COM suggests the prefacing of interfaces with an "I," the name is set to "IMeasure." The next step would be to define two methods—Voltage DC and Voltage AC (Listing 1).

Of interest in this particular interface is the choice of the Variant type. For range values, the SCPI definition allows the programmer to specify the string values "MAX," "MIN," and "DEF," together with a specific numeric value. To enable this interface to accommodate these potential values, one would use the predefined type Variant that could accept string as well as numeric values. The same process would apply to the remaining interfaces—IConfigure, ITrigger, and IIEE488—as would the filling out of their function prototypes.

After defining all the interfaces, the programmer returns to the first class created—"MultiMeter34401A"—and provides the implementation, using the "Implements" keyword in VB:

Implements IMeasure    

Implements IConfigure

Implements ITrigger

Implements IIEEE488

At this point, the VB development environment is set to aid in developing the interface skeletons. As a sample exercise, select the IMeasure object in the object viewer, and select each of the interfaces one by one (Fig. 1).


<-- prev. page     [1] 2 3     next page -->

Reprints   Printer-Friendly  Email this Article  RSS    Font Size   What's This?


  • Network-On-Chip Tools Arrive for The Masses
  • Tackling System Design Challenges Through Early Verification
  • ESL Tools Take Center Stage As Designers Move Up
  • Parasitic Extraction Tool Targets Next-Generation Custom ICs
  • Synopsys Jumps Into ESL-Synthesis Pool
  • Verify Control Systems Before Committing To Hardware
  • You're Using How Many FPGAs?
  • Tool Up For The FPGA Blitz
    1) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (180 views today)
    2) Hot Hands For Some Cool Rock: Motion Sensing Meets Audio Engineering
    (174 views today)
    3) GPS-Derived Grandmaster Clock Delivers Ultra-Precise Time And Frequency Sync
    (90 views today)
    4) What's All This Transimpedance Amplifier Stuff, Anyhow? (Part 1)
    (81 views today)
    5) Science Fiction Meets Science Fact In Today's Robot Research
    (75 views today)
    ALL TOP 20



    POST YOUR COMMENTS HERE
    Name:

    Email:
    Your Comments:

    Enter the text from the image below


    Please refresh the page if you have trouble reading this text.

    Search Electronic Design
         
      
     
    Web Seminar
    Sponsored By:
    Title: Read Pacing: A Performance Enhancing Feature of PCI Express Gen 2 Switch Devices
    Speakers: 
    Date: 07/01/08
    Register: 

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources