Fom Driver
Fom Driver
iber ptic
Version 1.2
ultiplexer
Avantes bv Oude Apeldoornseweg 28 NL-7333 NS Apeldoorn The Netherlands Tel: +31-313-670170 Fax: +31-313-670179 Web: www.avantes.com Email: [email protected]
02-03-12 Avantes
FOMdriver.doc www.avantes.com
Microsoft, Visual C++, Visual Basic, Excel, Windows, Windows 95/98/Me, Windows NT/2000/XP and Microsoft Office are registered trademarks of the Microsoft Corporation. Borland and Borland C++ are registered trademarks and C++Builder and Delphi are trademarks of Borland International, Inc.
02-03-12 Avantes
FOMdriver.doc www.avantes.com
Software License
THE INFORMATION AND CODE PROVIDED HEREUNDER (COLLECTIVELY REFERRED TO AS SOFTWARE) IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL AVANTES BV OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF AVANTES BV OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. This Software gives you the ability to write applications to acquire and process data from Avantes equipment. You have the right to redistribute the libraries contained in the Software, subject to the following conditions: 1. You are developing applications to control Avantes equipment. If you use the code contained herein to develop applications for other purposes, you MUST obtain a separate software license . 2. You distribute only the drivers necessary to support your application. 3. You place all copyright notices and other protective disclaimers and notices contained on the Software on all copies of the Software and your software product. 4. You or your company provides technical support to the users of your application. Avantes bv will not provide software support to these customers. 5. You agree to indemnify, hold harmless, and defend Avantes bv and its suppliers from and against any claims or lawsuits, including attorneys fees that arise or result from the use or distribution of your software product and any modifications to the Software.
02-03-12 Avantes
FOMdriver.doc www.avantes.com
Contents Overview.................................................................................................................................................................. 5 Installation ............................................................................................................................................................... 5 Basics ....................................................................................................................................................................... 5 Data Structures......................................................................................................................................................... 6 Windows Message sent to application ..................................................................................................................... 6 Description of Functions .......................................................................................................................................... 7
02-03-12 Avantes
FOMdriver.doc www.avantes.com
Overview
The FOM Interface Package for 32 bit Windows Applications is a software driver package for Windows 95/98/Me and Windows NT/2000/XP/Vista/7 that allows you to easily write custom software solutions for the FiberOptic Multiplexer. The package supports all necessary calls to the FOM. The driver uses Windows messages to signal the occurrence of a power failure, thereby allowing the program to prevent damage to your equipment.
Installation
The driver does not use the Windows registry or specific files that must be copied to the Windows directory tree. Just copy all files to your working directory. In principle, all you need is MUX.DLL and SUPERCOM.DLL. Delphi users need the interface file MUX.PAS, C++ users need MUX.H and MUX.LIB. Versions of these files for Borland C++ Builder and Microsoft Visual C++ are supplied.
Basics
You must have the following other items before you can develop your own software for the FiberOptic Multiplexer. - The multiplexer - A programming environment that supports calling 32 bit Dynamic Link Libraries (DLLs). This includes most major programming environments (e.g. Microsoft Visual C++, Borland C++, Borland Delphi, Borland C++ Builder). National Instruments LabVIEW and Microsoft Visual Basic do not directly support responding to Windows messages. Therefore, the power detection feature cannot be used with these programming environments. The multiplexer can, however, be normally operated. The driver was developed in Borland Delphi. Sample programs in Borland Delphi 6, Borland C++ Builder 5, Microsoft Visual C++ 6 and National Instruments LabVIEW 8.2 are provided. These sample programs are not commercial grade programs. They are not hardened against user error and provide very limited error checking. The purpose of these programs is to illustrate how to call the various driver functions. The driver uses the Supercom.dll communications library (by Adontec Computer Systems Ltd.) to interface with the serial port. The step motor controller is operated by monitoring three hardware signals through the serial port: The Motor running signal is connected to the DSR line. The Position reached signal is connected to the DCD line. The Power signal is connected to the CTS line. As there is no continuous feedback on the current position, the computer does not know where the multiplexer is positioned in case the power or the data connection is (temporarily) lost. To prevent problems, the power can be monitored. If there is a problem, a windows message will be sent to the host application. Your program can then take appropriate action, such as moving the multiplexer to the reference position or stopping altogether.
02-03-12 Avantes
FOMdriver.doc www.avantes.com
Data Structures
Structures used: The multiplexers status is transmitted as a structure: Pascal style: PStatus=^Status; Status=record MR:byte; PR:byte; PWR:byte; end; C style: typedef struct { unsigned char MR; unsigned char PR; unsigned char PWR; } StatusType; Abbreviations used: MR : Motor Running PR : Position Reached PWR: Power
02-03-12 Avantes
FOMdriver.doc www.avantes.com
Description of Functions
function MPX_Init(h:THANDLE; port:DWord; PowerDetection:byte):integer;stdcall; Initialises the multiplexer control. Input -> Windows Handle of host application -> the serial port to be opened, starting with 0 for COM1 PowerDetection -> If true=1, power failure is signaled to the host application. Return : 0 -> success -1 -> failure function MPX_Close:integer;stdcall; Closes the connection to the multiplexer. Return : 0 -1 -> success -> failure : h port
function MPX_Goto(position:byte;F,L,U:word):integer;stdcall; Positions the multiplexer at the desired position. Input : position F L U -> -> -> -> Multiplexer position (116) Positioning frequency (1-16000) Acceleration (1-250) Start/Stop frequency (1-2000)
Please consult the supplied Elstep manual, pages 50-54 for more information about the last three parameters. Valid default values are 3000/20/500. Especially the values for F and U are interconnected! Not every combination yields good multiplexer operation! Tests are mandatory! Return : 0 -1 -> success -> failure
function MPX_GotoStep(position,F,L,U:word):integer;stdcall; Positions the multiplexer at the desired steppermotor position. Input : position F L U -> -> -> -> Steppermotor position (6381) Positioning frequency (1-16000) Acceleration (1-250) Start/Stop frequency (1-2000)
Comparing both goto functions, the steppermotor positions are calculated from the multiplexer positions with the following formula: Y=(X-1)*25+6 where Y is the steppermotor position, and X is the multiplexer position.
02-03-12 Avantes
FOMdriver.doc www.avantes.com
Please consult the supplied Elstep manual, pages 50-54 for more information about the last three parameters. Valid default values are 3000/20/500. Especially the values for F and U are interconnected! Not every combination yields good multiplexer operation! Tests are mandatory! Return : 0 -1 -> success -> failure
function MPX_Stop:integer;stdcall; Immediate software stop. Return : always returns 0. function MPX_GotoReference:integer;stdcall; Positions the multiplexer at the reference position. Return : always returns 0. function MPX_Status(stat:PStatus):integer;stdcall; Queries the three hardware signals that are monitored: Motor Running, Position Reached and Power. Input/Output : stat -> Pointer to the status record Return : always returns 0. function MPX_MotorStatus:integer;stdcall; Returns the status of the stepper motor that is built in the multiplexer. Return value: Positive return values indicate the position of the stepper motor. This is a value between 0 (reference position) and 381 (position 16) Negative return values indicate an error condition. The values correspond with the error values from the Elstep manual: -1 -2 -3 -4 -5 -6 -10 -11 -12 Limit switch approached in positive direction. Limit switch approached in negative direction. Low level at stop input. Position greater than setpoint range (software limit switch). Position less than setpoint range (software limit switch). Excess temperature. Range of the parameter exceeded. Start command while the motor is running. Command unknown.
02-03-12 Avantes
FOMdriver.doc www.avantes.com