ActiveWire
Technical Note

 

 

Last Updated: 28-Jan-03



  Index

  1. Hardware
    1. Interface with Switch input
    2. Interface with MOSFET output
    3. Interface with Optoisolator output
  2. Software
    1. Windows-95 Support
    2. Windows 2000 Support
    3. DLL in MSVC++
    4. Application in Visual Basic
    5. DLL in Borland C++
    6. DLL in Delphi

  3. Others
    1. Compatibility issue with USB Host Controller

  4. Revision History




  1. Hardware

    1. Interface with Switch input

      To detect state of Switch, either Open of Close, you can connect wires like below.

      SwInput.jpg (18189 bytes)



      You can know if switch is open or closed by simply calling InPort() function of ActiveWire API.
      In above  Pull Down wiring, the InPort() function reads binary 0 when the switch is open, 1 when it is closed.
      In above  Pull Up wiring, the InPort() function reads binary 1 when the switch is open, 0 when it is closed.


    2. Interface with MOSFET output

      Output pins of ActiveWire USB board is rated as 2.4V at 1.6mA Source, or 0.8V at 1.6mA Sink. 
      There is a 47ohm resistor in series in each pin to protect from excessive current.
      According to my experiments, each output pin of ActiveWire USB board can drive 1 LED directly.

      To turn on and off more bigger load, such as relay or motor, you can use a MOSFET.

      MOSFETOut.jpg (24576 bytes)


      Please note that load has to be connected at Drain side and Source has to be grounded because of required Vgs to turn on the MOSFET.

      In this example, the relay is On when output pin is logical High, the relay is Off when the pin is logical Low.

      2N7000 used in this example can drive up to 60V 200mA continuous, or 500mA pulsed.



    3. Interface with Optoisolator output

      Using optoisolator, you can connect ActiveWire USB board and your device in two electrically isolated circuits,  so it can be more robust with noise and flexible in voltage and current requirement. 

      OptoOut.jpg (28672 bytes)


      NEC's optoisolator PS2501 used in this example can drive up to 60V 50mA.


      Back to Index


    1. Software

      1. Windows-95 Support

        All of the current ActiveWire USB software have been tested and verified on Windows-95 with the USB Supplement released from Microsoft in April 1997.  

        Please check if your USB host controller is recognized by Windows-95 correctly.
        From Start menu, choose Settings, Control Panel, then double click on System icon.  Choose Device Manager tab, then scroll window and find Universal serial bus controller item.  Click on + sign in the beginning of the line, then if you see USB Host Controller and USB Root Hub, your system has a very good chance to work with ActiveWire USB board.

        If you do not see any of above in the Device Manager, and/or if you have any difficulties in using ActiveWire USB software, please try installing the USB Supplement for Windows-95 (click here to download).

        If you still have problem, please contact technical support of the vendor of your USB host controller for any known compatibility issues, and/or contact our technical support, tech_support@ActiveWireInc.com.

        ActiveWire will continue to support Windows-95 as best as possible.   However, since Microsoft will no longer provide any enhancement on Windows-95 product,  it may not be able to fix when a problem is found in future.   It is suggested for all customers to migrate to the latest Windows-98 environment.


      2. Windows 2000 Support

        Windows 2000 is supported with ActiveWire USB driver ver.1.04 and newer. 
        Since Windows 2000 is not officially released from Microsoft yet, ActiveWire only supports as Beta version.

        Following issues are currently known.   These will be fixed in future versions of ActiveWire USB driver.
        1. Windows 2000 has a feature that it saves the driver information file (.INF) in the hidden system folder, C:\WINNT\INF,  when the first time a new hardware is installed.  Next time when user tries to update the driver, Windows 2000 system uses the saved INF file to install updated driver.    This feature prevents proper install of updated driver if the INF file itself is updated.
          If you experienced difficulty installing ActiveWire driver in Windows 2000 environment, please try either of followings ;
          1. With Windows Explorer, search the file containing text "ActiveWire" in  C:\WINNT\INF folder.  You may need to set option to actually view the folder since it is hidden system folder.   The file is usually named such as "oem#.inf", where # is a 1digit number like 0,1,2, ....  If you can find it, delete the file, and try update the driver using Hardware Wizard.
          2. Download RegClear.exe utility and run in Windows 2000.   Because of extra security feature of  Windows 2000 system, the utility cannot clear all the registry information.  You have to manually update/uninstall driver using Hardware Wizard.   This utility removes the saved INF file in C:\WINNT\INF folder, so tht when you try updating  driver, it will not use the saved old INF file.

        2. After the ActiveWire USB driver software is successfully installed in Windows 2000, an error occurs with the message in blue screen like ;
                  *** STOP 0x0000009F (0x00000100, 0xFFAD3AD0, 0xFFAD3AD0, 0xFFAD3AD0)
                  DRIVER_POWER_STATE_FAILURE
          This happens only when Windows 2000 tries to shutdown/restart and  the ActiveWire USB board is still plugged in to the host USB port.    
          This is a problem of the current ActiveWire USB driver.  It will be fixed in future version.

          NOTE: This problem has been fixed with ActiveWire USB driver set ver.1.04B.


      3. DLL in MSVC++

        There are 2 ways to use ActiveWire DLL in Microsoft Visual C++ ;
        1. Statically load DLL
        2. Dynamically load DLL


        Please refer to the source code of sample application for example of statically load DLL.   (available for download as AwusbIOSrc.exe, click here to download now.)

        To statically load DLL, you need to link your application with awusb.lib file, which is included in lib\ directory of the sample application source code.    From the menu bar,  choose Project, Settings, then click on Link tab.  Type in "..\lib\awusb.lib" in the window right below Object/library modules.
        In your C++ source code, include AwusbApi.h file, call LoadLibrary() function with the name of DLL.  The name of ActiveWire USB API DLL, awusb.lib, is defined as a macro, AWUSB_DLL_NAME, in the header file.

        ex)        #include "AwusbApi.h"
                     .....

                             // Load DLL library
                             LoadLibrary (AWUSB_DLL_NAME);

                     .....


        Then, you are free to call any of the DLL functions anywhere in your C++ code.

        Please note that you have to at least re-link your application with awusb.lib when awusb.dll has been updated.  awusb.lib and awusb.dll will be always updated together.

        To avoid re-linking with awusb.lib, you can choose to dynamically load DLL, calling GetProcAddress() function.  Please refer to Microsoft Visual C++ Reference Manual for more detail.


      4. Application in Visual Basic

        There are 2 ways to write an ActiveWire application in Microsoft Visual Basic.
        1. Use DLL
        2. Use OCX


        Please refer to the sample Visual Basic projects. (available for download as VBSampleDLL.exe or VBSampleOCX.exe, click here to download now.)

        Because the calling convention of functions in C/C++ and Basic is different, there is a separate DLL specifically for Visual Basic users.    It has been named as awusbvb.dll as opposed to the one for MCVC++.   It provides the exactly same functionality.

        Instead of using DLL, using OCX  may provide more convenient and versatile interface to ActiveWire products in Visual Basic application.   OCX, or often called ActiveX Control, is another form of library module in Microsoft Windows environment.    OCX provides common interface to most of popular programming language, such as Visual Basic and C++,  and scripting language recently introduced, such as JavaScript.   As same effort as writing an application in Visual Basic, you can write HTML file that can be browsed by Internet browser and still you can use functionality of ActiveWire products using  JavaScript and OCX.  

        This idea of using Internet browser as a programming platform saves your time and effort of trial and error in application development.

        If you like the idea,  please use OCX as ActiveWire interface!!


      5. DLL in Borland C++

        You may refer to this sample source code written in MSVC++.   This sample runs in DOS propmt, and uses no Microsoft specific library.   Also it demonstrate how to explicitly call DLL function from application.  Explicit call of DLL allows no need to link with Awusb.lib file so that the source code can be compiled and link with development tools other than MSVC++.

        Following is found in the Borland C++ 3's Online Help.

        A Windows DLL can be used by a C++Builder application just as it would be by any C++ application.
        To statically load a DLL when your C++Builder application is loaded, link the import library file for that DLL into your C++Builder application at link time. To add an import library to a C++Builder application, open the make file (.BPR) for the application and add the import library name to the library file list assigned to the ALLLIB variable. If necessary, add the path of the import library to the path(s) listed for the -L option of LFLAGS (linker options) variable.

        The exported functions of that DLL then become available for use by your application. Prototype the DLL functions your application uses with __declspec(dllimport) modifier:

        __declspec(dllimport) return_type imported_function_name(parameters);

        To dynamically load a DLL during the run of a C++Builder application use the Windows API function LoadLibrary() to load the DLL, then use the API function GetProcAddress() to obtain pointers to the individual functions you wish to use.

        Additional information on using DLLs can be found in the Microsoft® Win32 SDK Reference.


      6. DLL in Delphi

        Here's a samle source code using Delphi.

        Following is found in the Delphi 4's Online Help.

        Before you can call routines defined in a DLL, you must import them. This can be done in two ways: by declaring an external procedure or function, or by calling the Windows API directly. Whichever method you use, the routines are not linked to your application until runtime. This means that the DLL need not be present when you compile your program. It also means that there is no compile-time validation of attempts to import a routine.

        Object Pascal does not support importing of variables from DLLs.

        Static loading

        The simplest way to import a procedure or function is to declare it using the external directive. For example,

        procedure DoSomething; external 'MYLIB.DLL';

        If you include this declaration in a program, MYLIB.DLL is loaded once, when the program starts. Throughout execution of the program, the identifier DoSomething always refers to the same entry point in the same DLL.

        Declarations of imported routines can be placed directly in the program or unit where they are called. To simplify maintenance, however, you can collect external declarations into a separate “import unit” that also contains any constants and types required for interfacing with the DLL. (Delphi’s Windows unit is a good example.) Other modules that use the import unit can call any routines declared in it.

        For more information about external declarations, see External declarations.
        Dynamic loading through Windows API calls.

                            begin
                            Handle := LoadLibrary('DATETIME.DLL');
                            if Handle <> 0 then
                                begin
                                    @GetTime := GetProcAddress(Handle, 'GetTime');
                                    if @GetTime <> nil then
                                    begin
                                        GetTime(Time);
                                        with Time do
                                        WriteLn('The time is ', Hour, ':', Minute, ':', Second);
                                end;
                                FreeLibrary(Handle);
                             end;
                            end;

    2. Back to Index


    3. Others

      1. Compatibility issue with USB Host Controller

        There are several USB host controller chips reportedly cause problems with any USB devices in certain occasions.
        The problems have been most often observed with systems such as either ;
        1. manufactured sometime between 1997 to early 1998. (including some big-brand laptops)
        2. low cost machines (such as less than $500) that may use out-of-date components


        If your ActiveWire USB board does not work well on your system for any reason, please contact our technical support, tech_support@ActiveWireInc.com.
        Please give us information of your USB host controller when contacting us.
        You can see what kind of USB host controller you have in the system by looking at Control Panel, System, Device Manager, Universal serial bus controller section.



      Back to Index


    4. Revision History


      Created on May 14th, 1999.

      Revised on Jun.22nd, 1999.

      Broken link fixed.
      Corrected figure in section 1-2. MOSFET output.    Aug.23rd, 1999

      Added information about Windows 2000 support.  
      Added information of new sample programs             Oct.20th, 1999

      Revised information about Windows 2000 support.   Feb.24th, 2000



      Back to Index