Home
downloading
Contents
1. Type Value Description ADS _EVT_INTERRUPT 0x1 Device generates a hardware interrupt ADS _EVT_BUFCHANGE 0x2 Buffer changes ADS _EVT_TERMINATED 0x4 1 O operation is terminated ADS EVT_OVERRUN 0x8 Analog input data buffer is overrun ADS_EVT_WATCHDOG 0x10 Analog input with watchdog triggering is activated ADS_EVT_PORTO 0x80 Interrupt generated from counter port ADS _EVT_PORT1 0x100 Interrupt generated from counter port1 ADS _EVT_PATTERNMATCH 0x200 Pattern matched for digital input ADS _EVT_COUNTER 0x201 Interrupt for counter ADS_EVT_COUNTERMATCH 0x202 Count matched for counter ADS _EVT_COUNTEROVERFLOW 0x203 Counter overflow ADS _EVT_STATUSCHANGE 0x204 Status change ADS _EVT_FILTER 0x205 Filter Table 4 5 Supported Event Types Enabled Data type Unsigned short Size 2 bytes Set 1 to enable event function or O to disable it Count Data type Unsigned short Size 2 bytes Specifies how many counts to generate an event Notice ADS_EVT_PORTO and ADS_EVT_PORT1 are for PCI 1750 and PCI 1751 CheckEvent You can use the CheckEvent function to monitor the event status The CheckEvent function is a synchronous method to check the event You have to specify a period for the time out When an event occurs it returns the event type immediately If no event occurs in this period it Chapter 4 Function Overview 129 returns a time out error The CheckEvent function is different from the DRV_FAICheck or DRV_FAOCheck function
2. 75 4 2 2 Other Device FUNCTIONS cooooccnnnoccccnononcnonononnconanoncnnn 77 4 3 Analog Input Function Group ccsccsssssssscssssscsseccsseee 78 4 3 1 Software Triggering ocoocnonnnncconnconnnnnnnnannnnccnncnnnccnnacns 78 4 3 2 Waveform Data Reading ooncconnconocinoconoccnonoconoconananannss 81 43 3 PerlOrmanCe A A Retain E ess 92 4 4 Analog Output Function Group cccsscsssscessesssseecsees 93 4 4 1 Single Point Output cooconcnnocnnoncnnnconnconncnnnonnnononcnncconecnns 93 4 4 2 Multiple Channel Synchronous Output 00 95 4 4 3 Waveform Analog Output ee eeeeseesecneeneeees 96 4 5 Digital Input Output Function Group sssccssseeees 101 4 5 1 Digital Input Functions oconccnnnconocnnoncnoncnoncconanancnnnos 101 4 5 2 Digital Output Functions oooonccoccconnconnnacnnonncnnnonnn ns 106 4 6 Counter Function Group ssccscscssssccsssssssssssscssssssees 107 4 6 1 Event Counting seirler isinin atens eieae eiai 107 4 6 2 P lseQutput e eese a a eE 114 4 6 3 Frequency Measurement oooooccnocononcnoccnnnnnnnnnnnnonncnnne ns 117 4 7 Temperature Measurement Function Group mooomooo 119 4 8 Alarm Function Group cscsssscssssccsssccssssssssssssescssssenes 124 4 9 Port Function Group cccoccononcononooroncinnccconocono coco cocrocccnoccnes 125 4 10 Communication Function Group c moooomm 126 4 11 Event Function Group occcoccconoccnnocconacccnoccononoonococronccinccns
3. 0 c ccccceceeeeeeeeeeteeeeeeeeeeeees 318 PT_FAODmaStart Member Description c ccecceeceeeeeeeeeeeeeteeeeeees 319 PT_FAOScale Member Description 0 cc cceceeeeeeeeeeeeeeeeeeeeeeeeees 320 PT_FAOLoad Member Description 0 0 00 ceceeceeceseeeeeeeeeeeeeeeeeeeeeeeeaeeaee 321 PT_FAOCheck Member Description c cccceeeceeeeeeeeeeeeeeeeeeneeeaeeeee 322 PT_EnableEvent Member Description cccceeeeeeeeeeeeeeeeeeeeeeeeneeeees 323 PT_CheckEvent Member Description c cccccecceeeeeeeeeeeeeeteeeeeeees 324 PT_AllocateDMABuffer Member Description ccceceeeeeeeeeeeeeeeeee 325 PT_EnableEventEx Member Description ccccceceseeeeeeeeeeeeteeeeneeees 326 PT_DIFilter Member Description 0 0 cece eee eeee sees sees eee eeeeeaeeeee 327 PT_DIPattern Member Description 000 0 ee eee cece eee sees eeneeeeeeees 328 PT_DIStatus Member Description PT_FDITransfer Member Description ooooocnccnnncnnoninoccnananacncanncnnnananano 330 xxii Advantech DLL Drivers User s Manual Preface xxiii xxiv Advantech DLL Drivers User s Manual CHAPTER 1 Introduction to the 32 bit Windows 95 98 NT DLL Drivers 1 1 About the Advantech DLL Driver Software The Advantech DLL driver software provides complete hardware functions and maximum performance It is freely bundled with all Advantech plug in I O cards With the Advantech DLL driver you d
4. Advantech DLL Drivers User s Manual and Programmer s Reference 1st Edition Copyright Notice This document is copyrighted 1999 by Advantech Co Ltd All rights are reserved Advantech Co Ltd reserves the right to make improve ments to the products described in this manual at any time without notice No part of this manual may be reproduced copied translated or transmitted in any form or by any means without the prior written permission of Advantech Co Ltd Information provided in this manual is intended to be accurate and reliable However Advantech Co Ltd assumes no responsibility for its use nor for any in fringements upon the rights of third parties which may result from its use Acknowledgements IBM and PC are trademarks of International Business Machines Corporation Intel is a trademark of Intel Corporation MS DOS is a trademark of Microsoft Corporation ActiveX Visual Basic and Visual C are trademarks of Microsoft Corporation Borland C Builder and Delphi are trademarks of Inprise Corpora tion Adobe Acrobat is a trademark of Adobe Corporation All other product names or trademarks are the properties of their respective owners Advantech DLL Drivers User s Manual Advantech Customer Services Each and every Advantech product is built to the most exacting specifications to ensure reliable performance in the harsh and demanding conditions typical of industrial environments Whether y
5. ErrorStop amp lDriverHandle dwErrCde return main OOOO IO IOI OOOO OOOO OOOO IOI I II Function ErrorHandler Show the error message for the corresponding error code input dwErrCde IN Error code return none FOI OGIO IOI OIC OOOO OOOO CII IOI IOI OCI 54 Advantech DLL Drivers User s Manual void ErrorHandler DWORD dwErrCde 1 char szErrMsg 180 DRV_GetErrorMessage dwErrCde szErrMsg printf nError d s n dwErrCde Oxffff szErrMsg ErrorHandler OIC ICICI OIC CICS IIIS ICICI ICI ICICI ICI ICI ICICI ICI Ck Function ErrorStop Release all resource and terminate program if error occurs Paramaters pDrvHandle IN OUT pointer to Driver handle dwErrCde IN Error code return none FI FIFA AI II III II II II II III I III I III III II III II I I k k k S void ErrorStop long pDrvHandle DWORD dwErrCde Error message ErrorHandler dwErrCde printf Program terminated n Close device DRV_DeviceClose pDrvHandle exit 0 ErrorStop Step 3 Test Your Program Click on Compile under the Build menu to compile your code 2 Run it under a DOS Prompt Enter 0 for the device number and 0 for the input channel The result is shown below Chapter 3 Tutorial 55 Figure 3 11 Running Your Sample Win32 Console Program 56 Advantech DLL Drivers User s Manual 3 3 DLL Driver Tutorial for Visual Basic Application Step 1 Add Dem
6. Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Note If the cascade mode of PCI device is configured to be Yes in Device Installation Utility then the high word of the Count is set to counter and the low word of the Count is set to counter0 Chapter 5 Functions Reference 249 DRV_ClearOverrun status DRV_ClearOverrun DriverHandle Purpose Clear overrun flag Parameters e ion long default assigned by DRV_DeviceOpen Table 5 102 DRV_ClearOverrun Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL function 250 Advantech DLL Drivers User s Manual 5 3 Data Structures GAINLIST typedef struct tagGAINLIST USHORT usGainCde FLOAT fMaxGainVal FLOAT fMinGainVal CHAR szGainStr 16 GAINLIST GAINLIST is used by DRV_DeviceGetFeatures function Member Description Name Direction Type Range Description usGainCde output unsigned short default the gain code for each voltage output range which you may also refer to User Manual fMaxGainVal output floating point default gain code fMinGainVal floating point default the minimum gain code szGainStr array of char the voltage output range for the range code Table 5 103 GAINLIST Member Description Chapter 5 Functions
7. Figure 1 18 Installed Device Configuration Window 5 After you configure the device click the OK button and the device will be shown in the Installed Devices field as below di A Figure 1 19 Newly Installed Device Note The device number of the installed device is 001 that is the prefix of D01 PCI 1751 l O d000H You must pass the device number to the driver to specify the device that you wish to operate 14 Advantech DLL Drivers User s Manual 1 4 Device Test Utility After configuring your hardware with the Device Installation Utility you can use the testing utility to verify the hardware functions The test utility provides analog input analog output digital input digital output and counter functions You can launch it in the Device Installa tion Utility by highlighting the device that you want to test in the O Device Installation window and then clicking the Test button Alterna tively you can load it by clicking on the Test Utility shortcut in the Advantech DLL driver folder on your Windows Start menu Click on the Analog input tab in the test utility and you can see the analog input test panel as below Select the input range for each channel in the Input range field Configure the sampling rate in the scroll bar Switch the channels with the up or down arrow E EE Ey EE A S AN Figure 1 20 Advantech Device Test Utility Analog input tab Click on the Analog output tab to switch to the
8. Figure 4 17 General Counter Intel 8254 AMD 9513A Function Call Flow The DRV_CounterEventStart function starts the counter operation When the counter is running you can use the DRV_CounterEventRead function to read the count value repeatedly You can then call the DRV_CounterReset function to stop the counter operation when it is complete 108 Advantech DLL Drivers User s Manual Notice a The programming method depends on the counter timer chip on the board There are two kinds of chips that are used in DA amp C cards Intel 8254 and AMD Am9513A For Am9513A counter channels 0 9 can all function as a rising edge event counter Connect your external event generator to the clock input of the desired counter If hardware gating in which the counter may be started by a separate external hardware input is desired choose a gating type and use an external device to trigger the gate input of the counter b Both of the above counter timer chips are 16 bit However the function supports a 32 bit counter i e it counts up to 2 It will check if the counter is overflowing and converts it to 32 bits by calculation c Intel 8254 hardware counter needs 2 cycle times to reload the counter settings so the counter pro gram has to wait for 2 external triggers cycle time to read the correct counter value At the first time of calling the DRV_CounterEventStart function Intel 8254 hardware uses a default value to initialize its
9. Note 1 Configuring the PCL 779 PCLD 770 and PCLD 789 889 Amplifier Multiplexer Boards The PCLD 789 Amplifier Multiplexer allows up to 16 differential analog input channels to be multiplexed into one analog input A D channel of a DAS card The PCLD 779 and PCLD 770 allow for total isolation of up to eight multiplexed channels When used with multi plexer boards the first four D O channels of the DAS card are used for scanning selecting analog input channels of the PCLD 770 PCLD 779 or PCLD 789 one channel at a time Because of the digital output allocation when using these expansion boards the first byte of D O channels 0 7 on the DAS card are no longer available for standard digital output Each PCLD 770 779 789 889 must occupy its own A D channel Advantech DLL Drivers User s Manual When using mux cards the input range of the DAS cards should be set for 5 to 5V You should select the desired gain that is suitable for your signals on the PCLD 779 or PCLD 789 2 Cascading PCL 770s PCLD 779s or PCLD 789s for expansion You may use just one PCLD 770 PCLD 779 or PCLD 789 in a stand alone configuration or you can cascade up to 8 PCLD 789s for 128 channels 8 PCLD 770s for 64 channels or Y connect up to four PCLD 779s for 32 channels using the optional PCLD 774 Analog Expansion Board in a system Jumpers are used on the multiplexed boards to identify the DAS interface card channel to which they will be connected Eac
10. NumChans StartChan Input unsigned short unsigned short 0 n n depends on the available channels on 0 n n depends on hardware number of channels start channel of the scan channel GainList buffer count Output long pointer to unsigned short array with NumChans entries long pointer to unsigned short arra unsigned long depends on input range on hardware depends on I O register format on hardware 1 65536 gain code array for the scan channel data buffer allocated by user conversion count cyclic IntrCount Note unsigned short 0 1 cyclic mode cyclic 1 non cyclic 0 unsigned short count to interrupt hardware Table 5 156 PT_FAlIntScanStart Member Description The IntrCount value for PCL 818HD and PCL818HG can be set to 1 or FIFO_SIZE 512 the IntrCount value for PCL 1800 is varied gt 1 But the IntrCount value for other cards which has no FIFO on board should be set to 1 only The IntrCount value for PCI 1710 can be set to 1 or FIFO_SIZE 2048 the IntrCount value for PCI 1710 is varied gt 1 But the IntrCount value for other cards which has no FIFO on board should be set to 1 only Chapter 5 Functions Reference 307 PT_FAlDmaStart typedef struct tagPT_FAIDmaStart 1 USHORT TrigSrc DWORD SampleRate USHORT chan USHORT gain USHORT far buffer ULONG Count PT_FAIDmaStart FAR LPT_FAIDmaStart PT_FAIDmaStart i
11. Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpCounterFregStart Input Output long pointer to default the storage address for 196 PT_CounterFreqStart counter GatePeriod and GateMode Table 5 54 DRV_CounterFreqStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Operations 1 The programming method depends on the counter timer chip on the board There are two kinds of chips that are used in DASCards Intel 8254 and AMD Am9513A Since the AMD Am9513A chip uses two counter timer channels a highly accurate frequency measurement device can be attained Channels 0 8 function as possible input sources for frequency mea surement from 1 Hz to 65535 Hz Channel 9 the last channel on the chip is reserved and used as a gate period counter For frequency measurement the on board time base is used and divided by the gate period counter channel Since a long gating period is generally desirable choosing F5 100 Hz will allow for longer gating periods You must connect a jumper between the gate period counter output and the gate input of the desired frequency measurement counter Advantech DLL Drivers User s Manual Connect your external frequency gener
12. V Ni y y y y y V Ni y l l l I l l I I Ny V V Ni 4 y V V V Ni Table 5 10 DLL Driver Support for Advantech Hardware Chapter 5 Functions Reference 149 Function ADAM40 60 5056 5060 Device functions DRV_DeviceOpen DRV_DeviceClose DRV_DeviceGetFeatures Digital input output DRV_DioGetConfig DRV_DioSetPortMode V_DioReadPortByte _DioWritePortByte _DioReadBit _DioWriteBit DRV_DioGetCurrentDOByte DRV_DioGetCurrentDOBit Counter functions DRV_CounterEventStart DRV_CounterEventRead DRV_CounterReset Alarm functions DRV_AlarmConfig DRV_AlarmEnable DRV_AlarmCheck DRV_AlarmReset Comm port functions COMOpen COMClose COMGetConfig COMSetConfig COMRead COMWrite COMWrite232 COMWrite485 COMWrite85 COMEscape Table 5 11 DLL Driver Support for Advantech Hardware Note PCL 818HD doesn t support external trigger function 150 Advantech DLL Drivers User s Manual 5 2 Function Description The function groups can be analog input analog output digital input digital output etc Every Advantech DLL function is of the following form status FUNCTION_Name parameter 1 parameter 2 parameter n where n 0 Each function returns a value in the status variable that indicates the success or failure of the function as follows Status Value po Resat UNSUCCESS gt 0 Function failed due to error SUCCESS 0
13. ee Delphi Project Manager Form Design in the Sample Program Testing the Sample Program wie Driver System OvervieW ceceesceeseeeeeseeseeeeaeeeeeeeeeneeaeeaeeseeeeesaetaeeaeeeeeeaeeae DLL Driver Common Call FIOW oooooonconnniconnnnnoncnocnncnncnncnnrccncnnrn nr canonncnnn Device Installation Utility Configuration Window Single Point Reading Call Flow Diagram Multiple Channel Scan Function Call Flow Single Channel Reading Function Call Flow Single Channel Reading Call Flow sais Watchdog Triggering Call FIOW ooonocnnninncnnnnnnonnococancnnccnccnn rn nr rnccarcnnnn Single Point Output Call FIOW 0 0 cee eeeeeeceeeeeeseeeeeeeeeeaeeaeseseeeeaeeaeeeeeeeees Multiple Channel Synchronous Output Call Flow Interrupt Triggering Function Call Flow DMA Triggering Function Call Flow DI Software Triggering Call Flow Interrupt Triggering Call FIOW eeeeeeseeceeseeteeeeceeeeeeneeeeeeeeeeeaes Pattern Matched Status Change Counter Filter Function Call Flow 105 Digital Output Function Call FIOW oononnninnnincninnaninnicnnanacanicinanananicis 106 General Counter Intel 8254 AMD 9513A Function Call Flow 108 Interrupt Triggering Function Call FIOW c ccccceeeseeseeeeeeeeeeeeeeeneeenaes 111 Quadratic Counting Function Call FIOW 0 0 eeeeeeeeeereeteeeeeeeeeeeneeeees 113 P
14. example printf Before running this example please n printf use the device installation utility to add the device n Step 2 Input parameters printf nPlease input parameters printf nDevice Number check the device installation utility scanf 3d amp 1lDevNum printf Input Channel scanf 3d usChan Chapter 3 Tutorial 53 Step 3 Open device dwErrCde DRV_DeviceOpen 1DevNum amp 1DriverHandle if dwErrCde SUCCESS 1 ErrorHandler dwErrCde printf Program terminated n return Step 4 Configure input range ptAIConfig DasChan usChan channel 0 ptAIConfig DasGain 0 gain code 0 dwErrCde DRV_AIConfig lDriverHandle amp ptAIConfig if dwErrCde SUCCESS ErrorStop amp lDriverHandle dwErrCde return Step 5 Read one data ptAIVoltageIn chan usChan input channel ptAlVoltageln gain 0 gain code refer to manual for range ptAIVoltageIn TrigMode 0 0 internal trigger 1 external trigger ptAIVoltageIn voltage amp fVoltage Voltage retrieved dwErrCde DRV_AIVoltageIn lDriverHandle amp ptAIVoltageIn if dwErrCde SUCCESS ErrorStop amp lDriverHandle dwErrCde return Step 6 Display reading data printf Reading data 10 6f n fVoltage Step 7 Close device dwErrCde DRV_DeviceClose amp lDriverHandle if dwErrCde SUCCESS
15. o DRV_FAIDmaWatchdogStart DRV_CheckEvent NT Buffer Full complete Yes y DRV_FAITransfer DRV_FAIStop y DRV_FreeDMA Buffer Figure 4 30 Analog Input with DMA and Watchdog Triggering Chapter 4 Function Overview 135 Analog Output y DRV_EnableEvent y DRV_FAOScale y DRV_FAOLoad y DRV_FAODmaStart y DRV_CheckEvent ad Buffer Empty complete Yes y DRV_FAOScale Yes y DRV_FAOLoad No y DRV_FAOStop Figure 4 31 Event Call Flow for Analog Output with DMA Triggering 136 Advantech DLL Drivers User s Manual Analog Output DRV_FAOScale DRV_EnableEvent DRV_FAOIntStart DRV_CheckEvent Buffer Empty complete Yes Yes DRV_FAOScale DRV_FAOLoad Repeated No DRV_FAOStop Figure 4 32 Event Call Flow for Analog Output with Interrupt Triggering Chapter 4 Function Overview 137 138 DRV_TimerCountSetting DRV_EnableEvent DRV_CheckEvent Repeat DRV_EnableEvent Figure 4 33 Event Call Flow for Counter with Interrupt Triggering Examples Directory Advantech Adsapi Examples VB addma adint cdadint cdaddma dipattn Advantech Adsapi Examples Delphi addma adint cdadint cdaddma dipattn Advantech Adsapi Examples V C addma adint cdadint cda
16. 276 Advantech DLL Drivers User s Manual PT_AOCurrentOut typedef struct tagPT_AOCurrentOut USHORT chan AO Out channel FLOAT OutputValue Output Current value PT_AOCurrentOut FAR LPT_AOCurrentOut PT_AOCurrentOut is used by DRV_AOCurrentOut function Member Description unsigned short 0 n n depends the output on hardware channel floating Min DA Ref lt floating value to voltage lt Max be scaled DA Ref Table 5 127 PT_AOCurrentOut Member Description Chapter 5 Functions Reference 277 PT_DioSetPortMode typedef struct tagPT_DioSetPortMode SHORT port USHORT dir PT_DioSetPortMode FAR LPT_DioSetPortMode PT_DioSetPortMode is used by DRV_DioSetPortMode function Member Description Name Direction Type Range Description ort Input unsigned short 0 n n depends the digital port on hardware number 0 or output 1 Table 5 128 PT_DioSetPortMode Member Description 278 Advantech DLL Drivers User s Manual PT_DioGetConfig typedef struct tagPT_DioGetConfig 1 SHORT far PortArray USHORT NumOfPorts PT_DioGetConfig FAR LPT_DioGetConfig PT_DioGetConfig is used by DRV_DioGetConfig function Member Description Name Direction Type Range Description PortArray Output short pointer Default the storage address of port direction NumOfPorts_ input_________ unsignedshort_ Default_ number of ports Table 5 129 PT_DioGetConfig Member Description Chapt
17. ConfigDataLost if Registry is missing or invalid Chapter 5 Functions Reference 155 DRV_GetErrorMessage status DRV_GetErrorMessage ErrorCode ErrorMsg Purpose Retrieves the message of error according to the error code and returns 1t in the message buffer Parameters Name Direction Type Range Description ErrorCode Input unsigned long default error code returned by the driver ErrorMsg Output long pointer to default the storage for string error message You have to allocate a minimum of 80 bytes space for the returned error message Table 5 17 DRV_GetErrorMessage Parameter Table Return 1 SUCCESS if successful 2 Fail to Get Error Message if allocate buffer failed 3 Invalid Error Code if error code out of range Parameter Details ErrorCode and ErrorMsg refer to Appendix Error Codes 156 Advantech DLL Drivers User s Manual DRV_DeviceOpen status DRV_DeviceOpen DeviceNum DriverHandle Purpose Retrieves parameters pertaining to the device s operation from the Registry or configuration file and allocate memory to store it for quick reference This function must be called before any other functions Parameters Name Direction Description DeviceNum In device number put DriverHandle Output l default a pointer to the configuration data for the device Table 5 18 DRV_DeviceOpen Parameter Table Return 1 SUCCESS if successful 2 MemoryAllocateFailed if memory allo
18. DRV lt CounterReset cost a a e ea aei eii i es 200 DRV_QCountterConfig eeeeeeseeeereeeeeseeresreeresrreserresresresreses 201 DRV_QCounterConfigSys occococccoccnonononoconaconaconacanacannnnancnnnoo 202 DRV_QCounterStart ccccooooccnnnocnncnoonnnnnonononcnnnnnncnnnonnnonnnnnnnnnns 203 DRV_QCounterRead ccooooooccnonocnconoonnncnonnnncnnnnnnncnonnnnccnnonnncnnns 204 DRV_DICounterReset ooccncncncnninnnnnnnnncnananananananananana cnn nono nonon 205 DRV_CounterPWMSetting cccocccnocnnoncnoncnoncnoncnnncnnnanananannnn noo 206 DRV_CounterPWMEnable oocnnnnnnnnnnnnncnononanananananananannn canon 207 DRY TOMUXREAd E a a iaa 208 DRV_AlarmConfig eecuonc nocnidonosoniacononidcanos deso nono d nn co niranincenes 213 DRV AlarmEnable iaa 214 INN AAA A ieai aas 215 DRV Alar MRESE tonic 216 COMODO essa ictericia 217 COMIGO a ea A as 218 COMGetContiS cts lei R ENE ETR 219 COMSetConiig i he honear nenii Sa Eae 220 COMR ead aor aS eh hal cami TE 221 COMMA E ita Ah a 222 COMWrIite2 32 etane atenir trascender 223 Advantech DLL Drivers User s Manual COMES Cape circa di 224 DRVFA Ti Stadt o kee 225 DRV_FAIDmasStart eorne e iei eii ioa 226 DRV_FATIntScanStart coccncncnnnnnnininnnnnananananananancn nn no nonnnnnnononos 227 DRV_FAIDmaScanStart occccnnnnnnnnnnnnnnononononancnnonononnnncnononononos 228 DRY BAT Trader rs 229 DRVEATCNECK sissies essicsistiassedocieeesabece vabaccwatdeadsbscacaeesioaacess 230 DRV FAIS OD iaa lan 231 DRV_FAI
19. DRV_FAOIntStart Parameter Table cccccececeseeeseeeceeeeeeeeeeeeeeeeeeeeeeee 241 DRV_FAODmasStart Parameter Table cc ccescecceeeeeeeseeeeeeeeeeeeeeeneeeaes DRV_FAOScale Parameter Table DRV_FAOLoad Parameter Table DRV_FAOCheck Parameter Table cccccccccsececeeeceeeeeeseseaeseeeeaeeeaeeeee DRV_FAOStop Parameter Table cecseceecesseeeeeeeceeeeeeeeeereeseeeeeaeeneeeees DRV_EnableEvent Parameter Table DRV_CheckEvent Parameter Table 0 0 cecccesseceseceeeseeeeeeeeeeeeeeneees 248 DRV_TimerCountSetting Parameter Table aseene 249 DRV_ClearOverrun Parameter Table GAINLIST Member Description DEVFEATURES Member Description AOSET Member Description DAUGHTERSET Member Description DEVCONFIG_AI Member Description cceceeceeceeeeeeeeeeereeeeeeeeeeeeaee DEVCONFIG_COM Member Description ccceeceeseeseeeeeeeeeeeeeeeeeee 258 TRIGLEVEL Member Description ccceeceecceceeeeeeeeeeeeeeneeeeeeeeeaeeeeaees 259 PT_EVLIST DEVLIST Member Description c cceeeseeeeeeeeeeeeeees 260 PT_DeviceGetFeatures Member Description c cccseeeeeeseeteeeees 261 PT_AIConfig Member Description c eeceeceeceeeeeeeeeeeeneeetereeeeeaeeteeees 262 PT_AlGetConfig Member Description ececeeseeseeereeeeteeereeteeeeeeeaees 263 PT_AIBinaryln Member Description oonnnccicnnnni
20. Define the type of new project as Win32 Application define the platform to be Win32 and assign a project file directory 22 Advantech DLL Drivers User s Manual Figure 2 2 Defining the Application Type and Assigning a Project Directory 3 In order to develop DA amp C applications with Advantech DLL drivers you have to first include the Advantech DLL driver for Visual C header files filename H The way to include the header file into your project is to select Project Add to Project Files from the Visual C main menu Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 23 Figure 2 3 Including the DLL Drivers Header File in Your Project 4 After adding the header file for DLL functions you will see a filename i e Driver h listed under your project directory 24 Advantech DLL Drivers User s Manual CECI OS CO i Figure 2 4 Including Driver h DLL Driver Header File in the Project Directory Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 25 hi Cc IQ E Boule Ame DANNA A Pepa thr declaration of function deta eiructures id A a ris PELAR didnt live ES include HLH lider dis dde PLAT Figure 2 5 Driver h DLL Driver Header File in the Project Directory 5 After adding the header file you can view the DA amp C constant definition parameter declaration and DLL function calls that are defined in this header file These definitions ca
21. Devie i Yo Y Y DRV_DeviceClose Lje je DRV_AlBinaryln DRV_AlVoltagelnExp DRV_MAIBinaryln DRV_MAIVoltageln DRV_MAlVoltagelnExp Analog output DRV_AOBinaryOut DRV_AOScale i y i y y Port I O functions ss i Y y Analog input DRV_AlConfig Y DRV_WritePortByte Nv DRV_WritePortWord DRV_ReadPortWord DRV_DioGetConfig DRV_DioReadPortByte DRV_DioWritePortByte Y Y Y Y a DRV_DioWriteBit y T nS DRV_DioGetCurrentDOBit y Temperature DRV_TCMuxRead_____ ___ ___ Table 5 4 DLL Driver Functions Supported By PCI 1710 1713 1711 1731 q 21212 Lje 2212 ele Chapter 5 Functions Reference 143 O TE 77 Function PCI 1710 PCI 1713 PCI 1711 PCI 1731 High speed functions DRV_FAIIntStart a a DRV_FAIDmaStart po DRV_FAIIntScanStart tt oo DRV_FAIDualDmaStart AA DRV_FAlTransfer DRV_FAICheck i DRV_FAICheckEvent E E A DRV_FAlintWatchdogStat o en DRV_FAIWatchdogCheck mat DRV_AllocateDMABuffer DRV_FreeDMABuffer DRV_FAOIntStart IE a DRV_FAODmaStart DRV_FAOScale A DRV_FAOStop DRV CheckEvent si O DRV _ClearOverrun ra E E E DRV_CounterEventStart O DRV_CounterFregStart DRV_CounterFreqRead A Sescu DRV _CounterReset_ e DRV_QCounterConfigSys DRV_QCounterStat a PREIS PR Table 5 5
22. Direction DataType Input Unsigned short Indicate raw data 0 and float data 1 ActiveBuf Output long pointer to A return value from the unsigned short function to indicate which buffer is being filled during high speed data transfer 0 buffer A or single buffer 1 buffer B Triggered long pointer to 0 1 indicates if the unsigned short watchdog is triggered 1 or not 0 TrigChan long pointer to scan riggered channel if igned short channels triggered is 1 TrigIndex Long pointer to default Specifies the TrigData unsigned long value index in buffer hat matchs the monitoring condition TrigData long pointer to 0 65535 he location of the unsigned float or data in the buffer long pointer to riggers the watchdog unsigned short Table 5 166 PT_FAlWathchdogCheck Member Description Chapter 5 Functions Reference 317 PT_FAOIntStart typedef struct tagPT_FAOIntStart 1 USHORT TrigSrc DWORD SampleRate USHORT chan LONG far buffer ULONG count USHORT cyclic PT_FAOIntStart FAR LPT_FAOIntStart PT_FAOIntStart is used by DRV_FAOIntStart function Member Description Name Direction Type Description TrigSrc Input unsigned short triggering source external 1 internal 0 SampleRate floating point depends on sampling rate in hardware second chan unsigned short 0 n n depends the sampled channel on hardware long pointer to depends on data buffer allocated unsigned short hardware
23. Function completed successfully Table 5 12 General form of every Advantech DLL Driver Function Status is a 4 byte integer and is defined in DRIVER H file For more information about the error code please refer to Appendix A Chapter 5 Functions Reference 151 DRV_SelectDevice status DRV_SelectDevice hCaller GetModule DeviceNum Description Purpose Showing device list tree dialog box for select device s number Parameters Name Direction Type Range Description hCaller Input HWND windows Default Specify the Windows handle handle that is calling this function GetModule Input BOOL TRUE Specify the function to FALSE select module from registry list or not TRUE to select module from registry list DeviceNum Output pointer to 0 65535 Return the device unsigned long number that was get by this function Description Output pointer to Default Return the description unsigned char of the device Table 5 13 DRV_SelectDevice Parameter Table Return 1 If successful then return 0 2 If unsuccessful then return 1 152 Advantech DLL Drivers User s Manual DRV_DeviceGetNumOfList status DRV_DeviceGetNumOfList NumOfDevices Purpose Gets number of the installed devices Parameters Name Direction Type Range Description NumOfDevices Output pointer to short default driver Table 5 14 DRV_DeviceGetNumOfList Parameter Table Return 1 SUCCESS if successful 2 Inva
24. IllegalSpeed if SampleRate is out of range Chapter 5 Functions Reference 233 10 InvalidEventCount if EventCount is zero 11 ChanConflict if interrupt channel is conflict 12 OpenEventFailed if event name opens failure 13 KelInsufficientResources if resource is conflict with another driver 14 KeConInterruptFailure if connects interrupt failure 234 Advantech DLL Drivers User s Manual DRV_FAIWatchdogConfig status DRV_FAIWatchdogConfig DriverHandle lpFAIWatchdogConfig Purpose Configures the hardware to acquire data before before and after or after the signal triggers a analog watchdog It also configures the condition and level of the analog watchdog for each channel This function only supports PCL 1800 Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpFAlWatchdog Input Output long pointer to default the storage address Config PT_FAlWatchdo for TrigMode gConfig NumChans StartChan GainList CondList LevelList Table 5 87 DRV_FAIWatchdogConfig Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if GainList NULL CondList NULL or LevelList NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidGain if gain code is incorrect 6 InvalidChannel if chan is out of range Chapter 5 Functions Reference 235 DRV_FAlIntWatchdo
25. USHORT TrigSrc DWORD SampleRate USHORT far BufferA USHORT far BufferB ULONG BufferSize ULONG count PT_FAIDmaWatchdogStart FAR LPT_FAIDmaWatchdogStart PT_FAIDmaWatchdogStart is used by DRV_FAIDmaWatchdogStart function Member Description Name Direction Type Description TrigSrc Input unsigned short 0 1 triggering source external 1 internal 0 SampleRate Input floating point depends on the pacer on hardware sampling rate in second BufferA BufferB Output Output long pointer to unsigned short array long pointer to unsigned short array depends on I O register format on hardware depends on I O register format on hardware data buffer A assigned by AllocateDMABu ffer or user data buffer B assigned by AllocateDMABu ffer or user BufferSize unsigned long 1 65536 buffer size count unsigned short 1 65535 number of points in the source buffer to be copied to the data buffer Table 5 165 PT_FAlDmaWathchdogStart Member Description 316 Advantech DLL Drivers User s Manual PT_FAlWathchdogCheck typedef struct tagPT_FAIWatchdogCheck 1 USHORT DataType USHORT far ActiveBuf USHORT far triggered USHORT far TrigChan ULONG far TrigIndex LPVOID TrigData PT_FAIWatchdogCheck FAR LPT_FAIWatchdogCheck PT_FAIWahchdogCheck is used by DRV_FAIWahtchdogCheck function Member Description
26. why DLL drivers are packaged with functional prototype files for different Windows development tools The installation utility copies the appropriate prototype files for the development tools that you choose If you are not using any of the development tools that Advantech DLL drivers support you must create your own functional prototype file Advantech DLL Drivers User s Manual 2 2 Using the Win32 Console This section assumes that you will be using the Microsoft Visual Workbench to manage your code development Advantech DLL drivers support Microsoft Visual C version 2 0 and above To use the DA amp C functions you must use the DLL routines Follow this procedure 1 Create your source files as you would for other Windows pro grams written in C by calling DLL functions as typical function calls 2 Prototype any DLL routines used in your application Include the DLL header file which prototypes all DLL routines as shown in the following example include driver h 3 Add the DLL import library for example ADSAPI32 LIB to the project module For a general outline of creating a Visual C Windows programs complete the following procedure 1 Click File New from the main menu to create your application project and source code as you would for any other Visual C program Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 21 Figure 2 1 Creating a New Visual C Application 2
27. 10 Shap li ead valis aj i E Figure 2 14 Writing the Source Code The DLL driver for Windows 95 98 NT function library includes a DLL and a Windows 95 98 NT kernel device driver SYS files Most of the functions are built into the kernel mode device driver The DLL provides a portable programming interface for DA amp C applications The DLL driver for Windows 95 98 NT ADSAPI32 DLL is located in your Windows 95 98 System directory or your Windows NT System32 directory The kernel device driver ADSIO SYS is found in the Windows Drivers directory In addition to the system files the DLL Driver for Windows 95 98 NT is shipped with other files to help you develop DA amp C applications These files are in the directory you select when installing the DLL Drivers for Windows 95 98 NT Note Driver bas is an include file that contains all DLL function prototypes You should include this file in your source files when you build your DA amp C applica tions Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 35 2 4 Using Borland Delphi To use the DA amp C functions you must use the DA amp C DLL Follow this procedure 1 Select File New Application option from the Borland Delphi main menu to create your forms and code as you would for any Borland Delphi application program Figure 2 15 Creating a New Borland Delphi Application 2 After creating a new project choose the View menu and select the
28. 11 InterruptProcessFailed if interrupt proces is failure 12 KeInsufficientResources if resource is conflict with another driver 13 KeConInterruptFailure if connects interrupt failure Chapter 5 Functions Reference 241 DRV_FAODmaStart status DRV_FAODmaStart DriverHandle lpFAODmaStart Purpose Initiates an asynchronous analog output operation with DMA transfer Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen LpFAODmaStar Input Output long pointer to default the storage address t PT_FAODmaStart for StartChan StopChan buffer count cyclic Table 5 94 DRV_FAODmaStart Parameter Table 242 Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if buffer NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidChannel if chan is out of range 6 InvalidCountNumber have these conditions count is zero count is not even counter is less than 2048 When you do analog input with DMA transfer conversion number must be bigger than 2048 The size of Data must be bigger than PAGE_SIZE 4K 7 MlegalSpeed if SampleRate is out of range 8 InvalidEventCount if EventCount is zero 9 ChanConflict if interrupt channel is conflict 10 OpenEventFailed if event name opens failure 11 KeInsufficientResources if resource is conflict with another driver 12 Ke
29. 11 Digital Input With Interrupt Triggering Directory Advantech Adsapi Examples Console diint Advantech Adsapi Examples VC diint 3 5 12 Digital Input With Pattern Match Counter Overflow Status Change Directory Advantech Adsapi Examples Console dipattn Advantech Adsapi Examples VB dipattn Advantech Adsapi Examples Delphi dipattn Advantech Adsapi Examples VC dipattn 3 5 13 Digital Output Directory Advantech Adsapi Examples Console digout Advantech Adsapi Examples VB digout Advantech Adsapi Examples Delphi digout Advantech Adsapi Examples VC digout 3 5 14 Event Counting Directory Advantech Adsapi Examples Console counter Advantech Adsapi Examples VB counter Advantech Adsapi Examples Delphi counter Advantech Adsapi Examples VC counter 3 5 15 Event Counting With Interrupt Triggering Directory Advantech Adsapi Examples Console cntint Advantech Adsapi Examples vC cntint 3 5 16 Event Counting With Interrupt Triggering Directory Advantech Adsapi Examples VC qcounter Advantech DLL Drivers User s Manual 3 5 17 Pulse Output Directory Advantech Adsapi Examples Console pulse Advantech Adsapi Examples VB pulse Advantech Adsapi Examples Delphi pulse Advantech Adsapi Examples VC pulse 3 5 18 PWM Output Directory Advantech Adsapi Examples Console pulsepwm Advantech Adsapi Examples VB pulsepwm Advantech Adsapi Examples Delphi pulsepwm Advantech Adsapi Examples VC pulsepwm 3 5 1
30. 317 PT BAO Int tatiana e e E a AE E iie 318 PE FAODm aS tart aii a a n 319 PF FAO calentita 320 PEMA O oad o dd dt eh 321 PT FAOCHECK ad 322 PT Enable Vent ii slit a r a aa 323 PT Check vents ia ii daa 324 PT_AllocateDMABuffet occcncncnnnnnnnnnnnononananananann nono no nonononnnnos 325 PT EnableEvemtEX di 326 PTODIE ter Ee S 327 O A ee EE E E 328 PP DY o in E KEAT E N RIE 329 PT FDIIransfe in aen a E EN REN 330 Appendix A DLL Driver Error Codes ccomomooccccccccooo 331 status cod 32 bit ai A 332 Preface XV Figure 1 1 Figure 1 2 Figure 1 3 Figure 1 4 Figure 1 5 Figure 1 6 Figure 1 7 Figure 1 8 Figure 1 9 Figures DLL Drivers Programming Environment and Hardware oooocicnncccnicnnicncnnnos 3 Steps to Start Programming with Advantech s DLL Drivers 008 4 Advantech s Automation Software Installation Program i DLL Drivers Installation Program Welcome Screen ecceceeteeeeteeeeenteeee Information Screen with Latest Release Notes oooooconconicnoccocnonccoccnccanccnnonos Enter Your Name and Company Name Choose Destination Location Dialog Window Select the Kind of Installation You Want to Perform oooonocccnnniccinnncncnnnns Select the Program Folder for the Program Shortcut Figure 1 10 Copying the Files 0 cee ecessseeeeeeeeceeeeceeeeaesaecseseeeeaesaesseeeeeeeesaeeaetseeeees Figure 1 11 Figure 1 12 Advantech DLL Driver Start Menu Program Shortcuts Figure 1 13 Wind
31. 5 KeTooManyCmds if the logic commands have created an apparent endless loop for kernel mode driver 6 KelnvalidHandle if the handle for kernel mode driver is not a valid handle 7 KelnvalidParameter if the parameter passed to kernel mode driver is incorrect 8 KeNoAccess if an attempt to access a port or memory address which has not been defined in the Registry for this device 190 Advantech DLL Drivers User s Manual DRV_ReadPortByte status DRV_ReadPortByte DriverHandle lpReadPortByte Purpose Reads an 8 bit data from the specified I O port The port address is an T O port address on the PC Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpReadPortByte Input Output long pointer to default the storage address PT_ReadPortByte for port and ByteData Table 5 50 DRV_ReadPortByte Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 KelInvalidHandleValue if the kernel mode driver cannot be opened 4 KeFileNotFound if an attempt was made to open kernel mode driver while the driver was not running 5 KeTooManyCmads if the logic commands have created an apparent endless loop for kernel mode driver 6 KelnvalidHandle if the handle for kernel mode driver is not a valid handle 7 KelnvalidParameter if the parameter passed to kernel mode driver is incorrect 8 KeNoAccess if an attempt to access a p
32. 64 Advantech DLL Drivers User s Manual Step 5 close device ErrCde DRV_DeviceClose DeviceHandle If ErrCde lt gt 0 Then begin DRV_GetErrorMessage ErrCde pszErrMsg Response Application MessageBox pszErrMsg Error MB_OK DRV_DeviceClose DeviceHandle Exit end end end Step 3 Test Your Program 1 Press F9 to run the program Then press the Read button The data will appear as below Figure 3 20 Testing the Sample Program Chapter 3 Tutorial 65 3 5 Advantech DLL Driver Example Programs The Advantech DLL driver provides the following examples You can use them to create your own applications easily Please refer to Chapter 4 Function Overview for detailed information such as function description and call flow 3 5 1 Analog Input With Software Triggering Directory Advantech Adsapi Examples Console adsoft Advantech Adsapi Examples VB adsoft Advantech Adsapi Examples Delphi adsoft Advantech Adsapi Examples VC adsoft 3 5 2 Multiple Channel Al With Software Triggering Directory Advantech Adsapi Examples VB madsoft Advantech Adsapi Examples Delphi madsoft Advantech Adsapi Examples VC madsoft 3 5 3 Analog Input With Interrupt Triggering Directory Advantech Adsapi Examples Console adint Advantech Adsapi Examples VB adint Advantech Adsapi Examples Delphi adint Advantech Adsapi Examples VC adint 3 5 4 Analog Input with DMA Triggering Directory Ad
33. AlScaleFailed if failure 164 Advantech DLL Drivers User s Manual DRV_AlVoltageln status DRV_AlVoltageln DriverHandle l1pAlVoltageln Purpose Reads an analog input channel and returns the result scaled to a voltage units volts Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen IpVoltageln Input Output long pointer to default the storage PT_AlVoltageln address for chan gain TrigMode and voltag Table 5 25 DRV_AlVoltageln Function Table Return SUCCESS if successful InvalidDriverHandle if DriverHandle NULL AIConversionFailed if A D conversion failed DataNotReady if TrigMode 1 and data is not ready AlScale return code Chapter 5 Functions Reference 165 DRV_AlVoltagelnExp status DRV_AIVoltageInExp DriverHandle lpAIVoltageInExp Purpose Reads an analog input channel with expansion board and returns the result scaled to a voltage units volts This function supports the expansion boards PCLD 770 779 789 789D 788 Direction Type Range Description scat ao Input E default assigned by DRV_DeviceOpen IpAlVoltagelnExp Input Output pes pointer to default the storage address PT_AlVoltagelnExp for DasChan DasGain ExpChan and voltage Table 5 26 DRV_AlVoltagelnExp Parameter Table 166 Return SUCCESS if successful InvalidDriverHandle if DriverHandle NULL AlVoltageln return code AIConfig return code
34. Elcbal CRAC MAI MENICE MARE LEN 84 El bal CRAL MAT CATER WIRE LEN 18 Elbl CAL ET HIIEETER Wem Ja Elche CAL ELI MIG PORT an Elbl Coral ET AC RUE 14 Elbl Coral FPERCTE 1 Elida CEAL WONFECS E Elicia Coral Dib Pit INTERNAL E Figure 2 13 Constants Parameters and DLL Function Calls A Papas Ci dsd dE Deli dels ica isis aid IA AAA AI AAA AAA E AAA Plb Chit Esas UeaeLs 4 Stigma d ddi Eib Coie FERCTET FERETE 1 Fad PEL KIIL JPT oF Elbl CRAL FERCTEZ FERETEJ 1 Fad FEL MIEL JPT S369 Ing of ceils har a 6 Create your application source code and add DA amp C function calls into your application source code as below 34 Advantech DLL Drivers User s Manual Ll Ez i P o 0 DE yes ceed Fmd Geigy ba mh pih rd pie Ceol de T FE Be pe NPS BS i re ee EG K Dim ECES Le Lio Rice suis Dim RARCC et Y ME eer Dim CU da Loi Cim 1pLICe Eg Le TWICE Cim Wed da PTO eget Dim LILLE Ri ds Tee Dim Phage ds Tag Tap li opi viis ECCCES DEN DANITEDPED D Devin 1E Hcccas lt gt Dp Tht DEX_ESCECCOo Esas ECE MALL CESA ee a sg LOGIA ot 117 Teak du ma E Shep la aiii pe rii LpLicia lg raakaan E chad E pict pce E E eli idee D RECO BEY LICR ede Baillie 1p Cee 1E Exccas lt gt Ej Tii EEN ESCECOc Recreo EXcCds BORE Ray Peapor s Esglica s liiEag FLO ETIR 7 Hail mL ma
35. Falied on COM d Checksum Error from COM d Address XH InitError Initialization Failure On 1 O XH The Sample Rate Exceeds the Upper Limit On l O XH ChanConflict Background Operation Is Still Running On l O XH BoardIDNotSupported Board ID Is Not Supported On I O XH FreqMeasurementFailed Time Interval For Frequency Measurement Is Too Small On 1 O XH CreateFileFailed Call CreateFile Failed FunctionNotSupported Function Not Supported Error Code alo o oo N NI GetProcAddressFailed Call GetProcAddress Failed InvalidDriverHandle Invalid Driver Handle InvalidModuleType Invalid Windows Handle of Destination on l O XH InvalidCountNumber Invalid Numver of Conversion On l O XH Invalid Number of Interrupt Count On 1 O XH Invalid Number of Event Count On I O XH OpenEventFailed Create or Open Event Failed On I O XH Interrupt Process Failed On 1 O XH InvalidDOSetting Invalid digital output direction setting COM d Address Y XH InvalidEventType Invalid Event Type On I O XH EventTimeOut The Time out Interval Elapsed in Milliseconds Parameter On I O XH Table A 2 Status Code Summary 2 2 2 2 2 2 2 2 2 3 3 0 1 2 3 4 5 6 8 9 0 1 wo al 32 33 34 6 8 9 0 3 3 3 4 N Appendix A DLL Driver Error Codes 333 Note means that the status code only includes error code Error Code 100 101 Error ID KelnvalidHandl
36. Flow You only have to call the DRV_AOVoltageOut function for single point analog output Chapter 4 Function Overview 93 DRV_AOVoltageOut Figure 4 9 Single Point Output Call Flow The DRV_AOVoltageOut function accepts a floating point voltage value scales it to the proper binary number and writes that number to an analog output channel to change the output voltage The output range is based on the settings of the DA Reference Voltage in the Device Installation Utility You can change the output range by using the DRV_AOConfig function at runtime The DLL driver also provides a binary data output function DRV_AOBinaryOut It accepts a binary value and writes it to an analog output channel You can use DRV_AOScale function to convert the desired analog output value into a binary value You can then use DRV_AOBinaryOut function to output the value Examples Directory Advantech Adsapi Examples Console dasoft Advantech Adsapi Examples V B dasoft Advantech Adsapi Examples Delphi dasoft Advantech Adsapi Examples V C dasoft Function Description Demo program for analog output function with software triggering 94 Advantech DLL Drivers User s Manual 4 4 2 Multiple Channel Synchronous Output These functions are only supported in the PCI 1720 Call Flow The call flow of multiple channel synchronous output is shown below DRV_EnableSyncAO gt y Another Channel DRV_AOVoltag
37. Manual PT_CounterEventStart typedef struct tagPT_CounterEventStart 1 USHORT counter USHORT GateMode PT_CounterEventStart FAR LPT_CounterEventStart PT_CounterEventStart is used by DRV_CounterEventStart function Member Description Name Direction Type Range Description counter Input unsigned short 0 n n depends counter number on hardware GateMode Input unsigned short 0 1 2 3 4 gating mode to be used for AMD Am9513A Table 5 140 PT_CounterEventStart Member Description Chapter 5 Functions Reference 291 PT_CounterEventRead typedef struct tagPT_CounterEventRead 1 USHORT counter USHORT far overflow ULONG far count PT_CounterEventRead FAR LPT_CounterEventRead PT_CounterEventRead is used by DRV_CounterEventRead function Member Description Name Direction Type Description counter Input unsigned short counter number overflow Output long pointer to overflow state of the unsigned short counter 1 means overflow otherwise 0 long pointer to current total of the unsigned long specified counter Table 5 141 PT_CounterEventRead Member Description 292 Advantech DLL Drivers User s Manual PT_CounterFreqStart typedef struct tagPT_CounterFregStart 1 USHORT counter USHORT GatePeriod USHORT GateMode PT_CounterFregStart FAR LPT_CounterFregStart PT_CounterFreqStart is used by DRV_CounterFreqStart function Member Description Name Direction Type De
38. Multiple Channel Scan The functions for multiple channel sampling are similar to that of single data reading except the input channel is not limited to one The function call flow is shown below Channels GainList TriggerMode y DRV_MAIConfig Y DRV_MAIVoltageln _ _ another reading Repeat No Exit Figure 4 5 Multiple Channel Scan Function Call Flow The DRV_MAIConfig function configures the input ranges for the specified channels The DRV_MATIVoltageln function returns voltage data Alternately DRV_MAIBinaryln returns binary data You can also use the DRV_AlScale function repeatedly to convert them 4 3 1 3 Other Functions DRV_AlVoltagelnExp Reads from an analog input channel that is attached to an expansion board and returns the voltage DRV_MAIVoltageInExp Performs multiple channel analog inputs on the expansion board and returns the voltages Advantech DLL Drivers User s Manual Examples Directory Advantech Adsapi Examples V Blmadsoft Advantech Adsapi Examples Delphi madsoft Advantech Adsapi Examples V C madsoft Function Description Demo program for multiple channel analog input function with software triggering 4 3 2 Waveform Data Reading The analog input function group provides three kinds of waveform data acquisition They are interrupt triggering DMA triggering and watchdog triggering For single point data reading functions it samples data by software
39. Parameter Table DRV_DioSetPortMode Parameter Table DRV_DioReadPortByte Parameter Table DRV_DioWritePortByte Parameter Table DRV_DioReadBit Parameter Table DRV_DioWriteBit Parameter Table DRV_DioGetCurrentDOByte eee DRV_DioGetCurrentDOBit Parameter Table c cccceeseesteeseeeeeeees DRV_WritePortByte Parameter Table DRV_WritePortWord Parameter Table DRV_ReadPortByte Parameter Table DRV_ReadPortWord Parameter Table DRV_CounterEventStart Parameter Table cceceecceeeeeeeeteeeeeeeeereeeees 193 DRV_CounterEventRead Parameter Table s 195 DRV_CounterFreqStart Parameter Table DRV_CounterFreqRead Parameter Table DRV_CounterPulseStart Parameter Table DRV_CounterReset Parameter Table DRV_QcounterConfig Parameter Table DRV_QcounterConfigSys Parameter Table cecceceeeeeeeeeeeeeteeneeneees 202 DRV_QcounterStart Parameter Table ccceeceeeeeeneeeeeeeeeeeeeeeareneeeeees 203 DRV_QcounterRead Parameter Table c ccccceeceeeeeeeeeeeeeeeeeeeeeeeeeeeee 204 DRV_DICounterReset Parameter Table c cccceeeceeseeeeeeeeeeeeeeeeeeeeees 205 DRV_CounterPWMSetting Parameter Table ceceeeeeeeeeeeeeeeeeeeeeeees 206 DRV_CounterPWMEnable Parameter Table c ccccecseeeeeeeteeeeeees 207 DRV_TCMuxRead Parameter Table ccccceceseceeeseeeeeeeeeeeeeeeseeeeeeeaes 208 DRV_AlarmConfig P
40. Reference 251 DEVFEATURES typedef struct tagDEVFEATURES 1 CHAR szDriverVer 8 CHAR szDriverName MAX_DRIVER_NAME_LEN DWORD dwBoardID USHORT usMaxAIDiffChl USHORT usMaxAISiglChl USHORT usMaxAOChl USHORT usMaxDOCh1 USHORT usMaxDIChl USHORT usDIOPort USHORT usMaxTimerChl USHORT usMaxAlarmChl USHORT usNumADBit USHORT usNumADByte USHORT usNumDABit USHORT usNumDAByte USHORT usNumGain GAINLIST glGainList 16 DWORD dwPermutation 4 DEVFEATURES FAR LPDEVFEATURES DEVFEATURES is used by DRV_DeviceGetFeatures function 252 Advantech DLL Drivers User s Manual Member Description Direction Type Description Name szDriverVer output szDriverName array of char array of char Device driver version device driver name dwBoardID double word board ID usMaxAIDIffChI unsigned short Max number of differential channel depends on hardware usMaxAlSigIChl usMaxAOChl output unsigned short depends on hardware usMaxDOChI output unsigned short depends on hardware usMaxDIChl unsigned short unsigned short Max number of single end channel Max number of analog out channel Max number of digital out channel Max number of digital input channel depends on hardware depends on hardware usMaxTimerChl unsigned short Max number of Counter Timer channel depends on hardware usMaxAlarmChl usNumADBit unsigned short u
41. an asynchronous data acquisition operation with analog watchdog by DMA transfer and stores its input in an array Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen IpFAIDmaWatch Input Output long pointer to default the storage address dogStart PT_FAIDmaWat for TrigSrc chdogStart SampleRate BufferA BufferB BufferSize buffer count cyclic Table 5 89 DRV_FAIDmaWatchdogStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if BufferA NULL or BufferB NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidDmaChannel if DMA channel isn t set to dual DMA mode in device installation utility 6 InvalidCountNumber have these conditions count is zero count is not even counter is less than 2048 When you do analog input with DMA transfer conversion number must be bigger than 2048 The size of data must be bigger than PAGE_SIZE 4K 7 MlegalSpeed if SampleRate is out of range 8 InvalidEventCount if EventCount is zero 9 ChanConflict if interrupt channel is conflict 10 OpenEventFailed if event name opens failure 11 KeInsufficientResources if resource is conflict with another driver 12 KeConInterruptFailure if connects interrupt failure Chapter 5 Functions Reference 237 DRV_FAICheckWatchdog status DRV_FAICheckWatchdog DriverHan
42. frequency is then derived from the time period and count increment Advantech DLL Drivers User s Manual 4 7 Examples Directory Advantech Adsapi Examples Console freq Advantech Adsapi Examples V B freq Advantech Adsapi Examples V C freq Function Description Demo program for frequency measurement function Temperature Measurement Function Group The temperature measurement function group measures the tempera ture with expansion boards such as PCLD 788 789 789D 8 1 15 770 Parameters DasChan Type Unsigned short Size 2 bytes It specifies the input channel on the DA amp C card ExpChan Type Unsigned short Size 2 bytes It specifies the input channel on the expansion board DasGain Type Unsigned short Size 2 bytes It specifies the input range or gain on the DA amp C card TCType Type Unsigned short Size 2 bytes It specifies thermocouple type J 0 K 1 S 2 T 3 B 4 R 5 and E 6 TempScale Type Unsigned short Size 2 bytes It specifies the temperature unit Celsius 0 Fahrenheit 1 Rankie 2 Kelvin 3 Chapter 4 Function Overview 119 Call Flow You only have to call DRV_TcMuxRead function to read temperature value Port Bit t DRV_TcMuxRead Figure 4 23 Temperature Measurement Function Group Function Call Flow Expansion Boards PCLD 770 PCLD 779 or PCLD 789 Follow the procedure to perform thermocouple measurement 1 Connect the t
43. function Member Description Name Direction Type Range Description DasChan Input unsigned short 0 n n depends the sampled on hardware channel Input unsigned short refer to gain list gain code in hardware manual Table 5 112 PT_AlConfig Member Description 262 Advantech DLL Drivers User s Manual PT_AlGetConfig typedef struct tagPT_AIGetConfig 1 LPDEVCONFIG_AI buffer USHORT size PT_AIGetConfig FAR LPT_AIGetConfig PT_AIGetConfig is used by DRV_AIGetConfig function Member Description Direction Type Description Output long pointer to the storage DEVCONFIG_AI address of the Al configuration size input unsignedshort_ __________ buffersize Table 5 113 PT_AlGetConfig Member Description Chapter 5 Functions Reference 263 PT_AlBinaryin typedef struct tagPT_AIBinaryIn 1 USHORT chan USHORT TrigMode USHORT far reading PT_AIBinaryIn FAR LPT_AIBinaryIn PT_AIBinaryIn is used by DRV_AIBinaryIn function Member Description Name Direction Type Range Description chan Input unsigned short 0 n n depends the sampled on hardware channel TrigMode Input unsigned short 0 normal trigger mode software 1 external reading Output long pointer to depends on raw data reading unsigned short hardware from the sampled channel Table 5 114 PT_AlBinaryIn Member Description 264 Advantech DLL Drivers User s Manual PT_AlScale typedef struct tagPT_AlScale 1 USHORT read
44. look similar to the one shown below Figure 3 19 Form Design in the Sample Program 4 Write your code for the cmdRead button as below Chapter 3 Tutorial 63 procedure TForml cmdReadClick Sender TObject var voltage Single DeviceHandle Longint ErrCde Longint szErrMsg string pszErrMsg Pchar AiVoliIn PT_AlVoltageln ptAlConfig PT_AIConfig Response Integer begin pszErrMsg szErrMsg Step 1 open device ErrCde DRV_DeviceOpen 0 DeviceHandle device number 0 If ErrCde lt gt 0 Then begin DRV_GetErrorMessage ErrCde pszErrMsg Response Application MessageBox pszErrMsg Error MB_OK Exit end Step 2 configure input range ptAIConfig DasChan 0 channel 0 ptAIConfig DasGain 0 gain code 0 ErrCde DRV_AIConfig DeviceHandle ptAlConfig If ErrCde lt gt 0 Then begin DRV_GetErrorMessage ErrCde pszErrMsg Response Application MessageBox pszErrMsg Error MB_OK Exit end Step 3 read value AiVolIn chan ptAIConfig DasChan AiVolIn gain ptAIConfig DasGain AiVolIn TrigMode 0 AiVolIn voltage voltage ErrCde DRV_AlVoltageln DeviceHandle AiVolIn If ErrCde lt gt 0 Then begin DRV_GetErrorMessage ErrCde pszErrMsg Response Application MessageBox pszErrMsg Error MB_OK Exit end Step 4 display value txtAlValue Text FloatToStrF voltage ffFixed 5 2
45. only supports ADAM modules Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpAlarmEnable Input Output long pointer to default the storage address PT_AlarmEnab le for chan LatchMode and enabled Table 5 67 DRV_AlarmEnable Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidChannel if chan is out of range 4 CommTransmitFailed if COMWrite failed 5 CommReadFailed if there is no response 6 CommReceiveFailed if the response string is incorrect 214 Advantech DLL Drivers User s Manual DRV_AlarmCheck status DRV_AlarmCheck DriverHandle lpAlarmCheck Purpose Checks the alarm status of the specified channel Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpAlarmCheck Input Output long pointer to default the storage address PT_AlarmCheck for chan LoState and HiState Table 5 68 DRV_AlarmCheck Parameter Table Return SUCCESS if successful InvalidDriverHandle if DriverHandle NULL InvalidChannel if chan is out of range CommTransmitFailed if COMWrite failed CommReadFailed if there is no response DL E A AS CommReceiveFailed if the response string is incorrect Chapter 5 Functions Reference 215 DRV_AlarmReset status DRV_AlarmReset DriverHandle chan Purpose Resets the alarm monitoring of the specif
46. operation is started by the DRV_FAODmasStart function In addition you must call DRV_AllocateDMABuffer to allocate the DMA buffer and DRV_FreeDMA Buffer to free the DMA buffer Examples Directory Advantech Adsapi Examples Console dadma Advantech Adsapi Examples VB dadma Advantech Adsapi Examples Delphi dadma Advantech Adsapi Examples VC dadma Function Description Demo program for analog output function with DMA triggering Digital Input Output Function Group The Digital Input Output function group performs digital input and output operations The digital input output lines bits on each data acquisition device are grouped into logical units called ports Each port has eight lines or bits For example the port 1 bit 3 specifies the eleventh bit on the data acquisition device The DLL drivers provides bit and port byte functions The digital I O port of some data acquisition devices e g PCL 722 724 731 can be configured for input or output You can use the DRV_DioSetPortMode function to configure the specified port for input or output In addition you can use the DRV_DioGetConfig function to read the configuration 4 5 1 Digital Input Functions The digital input functions perform digital input operations The DLL drivers support digital input with software triggering and digital input with interrupt Chapter 4 Function Overview 101 4 5 1 1 Software Triggering Call Flow You just call DRV_DioReadBit functio
47. register format on hardware gain code data buffer allocated by user cyclic IntrCount 306 unsigned long unsigned short Unsigned short 1 65536 0 1 depends on hardware conversion count cyclic mode cyclic 1 non cyclic 0 count to interrupt Table 5 155 PT_FAlIntStart Member Description Note The IntrCount value for PCL 818HD and PCL818HG can be set to 1 or FIFO_SIZE 5 12 the IntrCount value for PCL 1800 is varied gt 1 But the IntrCount value for other cards which has no FIFO on board should be set to only The IntrCount value for PCI 1710 can be set to 1 or FIFO_SIZE 2048 the IntrCount value for PCI 1710 is varied gt 1 But the IntrCount value for other cards which has no FIFO on board should be set to only Advantech DLL Drivers User s Manual PT_FAIIntScanStart typedef struct tagPT_FAIIntScanStart USHORT DWORD USHORT USHORT TrigSrc SampleRate NumChans StartChan USHORT far GainList USHORT far ULONG USHORT USHORT buffer count cyclic IntrCount PT_FAIIntScanStart FAR LPT_FAIIntScanStart PT_FAIIntScanStart is used by DRV_FAITIntScanStart function Member Description Name Direction Type Description TrigSrc Input unsigned short 0 1 triggering source external 1 internal 0 SampleRate Input floating point depends on the pacer on hardware sampling rate in second
48. the count and overflow conditions Parameters sin pas aaa assigned by DRV_DeviceOpen Eee EA SA pointer to default the storage address for PT_QCounterRead counter overflow LoCount and HiCount Table 5 61 DRV_QcounterRead Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Note When not in cascade mode the counter is 24 bits The data only returns in LoCount Otherwise when it is in cascade mode the counter is 48 bits The data returns in LoCount and HiCount 204 Advantech DLL Drivers User s Manual DRV_DICounterReset status DRV_DICounterReset DriverHandle counter Purpose Reset the value of specified counter to be reset value Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen counter Input unsignshort default_ reset counter data__ Table 5 62 DRV_DICounterReset Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL Note Chapter 5 Functions Reference 205 DRV_CounterPWMSetting status DRV_CounterPWMSetting DriverHandle lpCounterPWMSetting Purpose Config the setting value of PWM Pulse Width Modulation output Parameters Name Direction Type Range Description DriverHandle long default assigned b
49. 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if Board ID is not supported See Also PT_DeviceGetFeatures Chapter 5 Functions Reference 159 DRV_GetAddress 160 Address DRV_GetAddress variable Purpose This function is only used in Visual Basic It returns a pointer or address of a variable Parameter Variable The variable name Return A pointer or address of the variable Advantech DLL Drivers User s Manual DRV_AIlConfig status DRV_AIConfig DriverHandle lpAIConfig Purpose Configures the gain settings for the specified analog input channel Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpAlConfig Input long pointer to default the storage address PT_AIConfig of the DasChan and DasGain Table 5 21 DRV_AlConfig Parameter Table Return e SUCCESS if successful InvalidDriverHandle if DriverHandle NULL InvalidChannel if DasChan is out of allowable range InvalidGain if the DAS card doesn t support the DasGain BoardIDNotSupported if Board ID is not supported Chapter 5 Functions Reference 161 DRV_AlGetConfig status DRV_AIGetConfig DriverHandle lpAIGetConfig Purpose Retrieves analog input configuration data and returns it in buffer Parameters Direction Type Range Description DeviceHandle Input long pointer assigned by DRV_DeviceOpen IpAlGetConf
50. 1 unipolar usDasGain unsigned short refer to gain list the gain code of in users manual the channel on DAS card usNumExpChan unsigned short depend on DAS channels device attached installation expansion board usCjcChannel unsigned short cold junction channel Table 5 107 DEVCONFIG_AI Member Description Chapter 5 Functions Reference 257 DEVCONFIG_COM typedef struct tagDEVCONFIG_COM 1 USHORT DWORD USHORT USHORT USHORT USHORT USHORT usCommPort dwBaudRate usParity usDataBits usStopBits usTxMode usPortAddress DEVCONFIG_COM FAR LPDEVCONFIG_COM DEVCONFIG_COM is used by COMGetConfig and COMSetCon fig functions Member Description Name Direction Type Range Description usCommPort input unsigned short serial port dwBaudRate input double word actual value baud rate usParit usDataBits input Unsigned short unsigned short parity check data bits usStopBits Unsigned short stop bits usTxMode usPortAddress unsigned short unsigned short transmission mode communication port address Table 5 108 DEVCONFIG_COM Member Description Note For example dwBaudRate 9600 when sets the baud rate of COM port in 9600 BPS Please also refer to DCB Device Control Block structure in Win32 SDK help for more information 258 Advantech DLL Drivers User s Manual TRIGLEVEL typedef struct tagTRIGLEVEL FLOAT fLo
51. 128 Xx Advantech DLL Drivers User s Manual Chapter 5 Functions Reference scssssseeese 139 5 1 Function Support in Advantech Products comooooooooo 140 5 1 1 Function Support Tables onconnccnnncnnnnnnncnncnnnancnncnns 140 5 2 Function Description oocms 151 DRY Select Device Maca E A en 152 DRV_DeviceGetNumOfPList cccccceeeeeseeeseseesesseerereeees 153 DRV_DeviceGetList aene a e TA A 154 DRV_DeviceGetSubList ooooocnnnnnnnnicnononononannnnanananananoncnnnnnnnnn 155 DRV GetErrorMessage coocococcnocncocnnnncnonoconoconccnnnonanonancnnccnna ns 156 DRY DeviceOpen si cacieg tiie aimnin ae aati hace 157 DRV Devices a 158 DRV_DeviceGetFeatures cococccncnonononononononnanananannanoncnnnnnnnnnnos 159 DRY Get AGGreSs cta ida a IAS Cine 160 DRV 2 AIC Oni ee onena a inner spain 161 DRY AlGet ontie eanna ten eerie 162 DRV SAIB inary i necio sisi llei 163 DRY ZATS Cale data dodne 164 DRV_ATVoltageln ocre 165 DRV_AIVoltageInEXp ornnes iiiar 166 DRY MAI Comi cette ds 168 DRV 2MAIB inary Misriicola its Potts 169 DRV MAI Voltage ln osvaldo ig 170 DRV_MATVoltageInEXp cooconocccnoncnncnoncconaconacannnancnnnncnnccnna ns 171 DRV_EnableEventEX ooonnnnncnnnnnnnnnonanonanananancnononononononanananona 172 DRY FDU ran ster ics tudio dd 173 DRV_AOConfgunaiantisa nj cee antl hee 174 DRV_AOVoltageQUt ococonoccococnnocnnocnnnnnonncconaconcconornn nono nonancnne ns 175 DRV AO Scale strain 1
52. 310 Advantech DLL Drivers User s Manual PT_FAlDualDmaScanStart typedef struct tagPT_FAIDualDmaScanStart 1 USHORT DWORD USHORT USHORT USHORT USHORT USHORT ULONG TrigSrc SampleRate NumChans StartChan far GainList far BufferA far BufferB count PT_FAIDualDmaScanStart FAR LPT_FAIDualDmaScanStart PT_FAIDualDmaScanStart is used by DRV_FAIDualDmaScanStart function Member Description Name TrigSrc SampleRate Direction Input Type unsigned short floating point depends on the pacer on hardware Description triggering source external 1 internal 0 sampling rate in second NumChans StartChan GainList unsigned short unsigned short long pointer to unsigned short array with NumChans entries 0 n n depends on the available channels on 0 n n depends on hardware depends on input range on hardware number of channels start channel of the scan channel gain code array for the scan channel BufferA Output long pointer to unsigned short array depends on I O register format on hardware data buffer allocated by user BufferB Output long pointer to unsigned short arra unsigned long depends on I O register format on hardware 1 65536 data buffer allocated by user conversion count Table 5 160 PT_FAlDualDmaScanStart Member Description Chapter 5 Functions Reference 311 PT_FAlTransfer t
53. 5 98 or Windows NT depending on the platform that is running your development tool 4 The installation program loads Click the Next button to advance to the following screen A AN ll Figure 1 4 DLL Drivers Installation Program Welcome Screen 5 The Information screen loads and a window will display the latest release notes We highly recommend that you read through the release notes since they contain last minute product information that may not appear in the printed manual or online help When you have finished reading the release notes click the Next button 6 Advantech DLL Drivers User s Manual Figure 1 5 Information Screen with Latest Release Notes The User Information screen loads Enter your name and organiza tion s name to personalize your copy of the DLL Drivers program and click the Next button Figure 1 6 Enter Your Name and Company Name You have to select a location on your hard drive where the files will be copied The default location is c Program Files Advantech ADSAPI If you want to save the files to a different path on your hard disk drive click the Browse button and either select or type the path that you want to use Click the Next button to advance Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Driver 7 Figure 1 7 Choose Destination Location Dialog Window 8 Choose the kind of installation that you want to perform in the Setup Type in the screen You can select Typi
54. 55 Table 5 17 DRV_GetErrorMessage Parameter Table c cccecsceseseeeseeeeeeeeeeees 156 Table 5 18 DRV_DeviceOpen Parameter Table eccecceceseeeseeeeeeeeeeeeseeeeaeeereeeees 157 Table 5 19 DRV_DeviceClose Parameter Table oooocconoccccoccnnccononononanononnononanonnna 158 Table 5 20 DRV_DeviceGetFeatures Parameter Table ooconccccnnoccnccocaconocncononnnonos 159 Table 5 21 DRV_AlConfig Parameter Table cecseceeseesesseeesseeeeeeaeeneeeeeeateesteaes 161 Table 5 22 DRV_AlGetConfig Parameter Table cccceccesseeeeeeeeeeseeeeeeeeeeeeeeeeees 162 Table 5 23 DRV_AIBinaryln Function Table ccc ee cee ceeeeeeceeeeeeeeeeeeeeeeeeeeeeeaes 163 Table 5 24 DRV_AlScale Function Table cccccccececeeeseceseeeeeeeeeeeeeseeeeeeeeeenseeeees 164 Table 5 25 DRV_AlVoltageln Function Table on ooninnonnnnnnconocanacanocananc can c nano nan crac 165 Table 5 26 DRV_AlVoltagelnExp Parameter Table ooooonocccnnncconocccccncccconcncnnncccnanccananos 166 Table 5 27 DRV_MAIConfig Parameter Table csecseceeceeseeeeeeeeeeeeeeeeeeeeaeereaeeeee 168 Table 5 28 DRV_MAIBinaryln Parameter Table 0 cece cies ecee cess eeeeeeeeeeeeaeenees 169 Table 5 29 DRV_MAIVoltageln Parameter Table cccccseseeeceeeeeeeeeeeeeeeeeseeeeaee 170 Table 5 30 DRV_MAIVoltagelnExp Parameter Table o oonnonnnninnonicinicinocnnaracancnnnos 171 Table 5 31 DRV_EnableEventEx Param
55. 76 DRV_AOBinaryOut ooccoconoccnocanocnnoncnoncnonoconaconannnnnnnnonancnnccnne ns 177 DRV_EnableSyncAO sereen ann p eir ii 178 DRV_WriteSyncAO cccicoodocosisontacasticosinda nos teen poca 179 DRV_AOCurrentOut occccncnnnnnnnnnnnnnnanananananananancn nano nono nonnnnnnanos 180 DRV_Di0GetConfig ients naa a 181 DRV _DioSetPortMode cncccccncnnnnnnonanannonanananananannn nono nononononcnnn 182 Preface xi DRV_DioReadPortByte oooncccncccoonnnononoccnoncnnnonnnananananananonnnoon 183 DRV_DioWritePortByte cooooonncnnncnnnnnnoccnonconnconncnnncnnncnnnonnnoo 184 PRV DiGR ead Bit iis css iosale ricino caninas rada adela 185 DRV_DioWriteBit senine nerien a ieai ns 186 DRV_DioGetCurrentDOBYte coonccnnccnnoccoccconcconccannnnnnonononnnoo 187 DRV_DioGetCurrentDOBIt ooccccnnnnnnnnnnanannnnananananananannnnononon 188 DRV WritePortB Vte iicscstciaceesthsicstatescetseelashslaccsdt baleesthaledeas 189 DRV_WritePort Word cccccccccinnncninininnnnnncnanananananananananan ains 190 DRV_ReadPortByte ranerne ias aa ia 191 PRV ReadPortWord irsin ian a 192 DRV_CounterEventStart coconcncnnnnncncnnaninnnananananananananananannnnnna 193 DRV_CounterEventRead 0ooocnnncnnnonononononononnonananananononcnnnnnnnnos 195 DRV_CounterFreqStart ooooonncnoncconncnnncnoncnnnccnnonnncnnncnnncnancnnnno 196 DRV_CounterFreqRead ocoonccnncccnonononononcnoncnnncnnncnnncnnnanancnnnoo 198 DRV_CounterPulseStart oconcncnnnnnnnnnnnnnncnanananananananancn nano nonon 199
56. 8 DRV_FAITransfer Parameter Table DRV_FAICheck Parameter Table ccccceeseeeeceeeceeeeseeeeeeeeeseeeeeeeeeee DRV_FAIStop Parameter Table cccesceeceeceeeeeeeeeeeeseeeeeeeeeenesaeeeeseeeeaees DRV_FAIDualDmaStart Parameter Table DRV_FAIDualDmaScanStart Parameter Table XX Advantech DLL Drivers User s Manual Table 5 87 Table 5 88 Table 5 89 Table 5 90 Table 5 91 Table 5 92 Table 5 93 Table 5 94 Table 5 95 Table 5 96 Table 5 97 Table 5 98 Table 5 99 Table 5 100 Table 5 101 Table 5 102 Table 5 103 Table 5 104 Table 5 105 Table 5 106 Table 5 107 Table 5 108 Table 5 109 Table 5 110 Table 5 111 Table 5 112 Table 5 113 Table 5 114 Table 5 115 Table 5 116 Table 5 117 Table 5 118 Table 5 119 Table 5 120 Table 5 121 Table 5 122 Table 5 123 Table 5 124 Table 5 125 Table 5 126 Table 5 127 Table 5 128 Table 5 129 Table 5 130 Table 5 131 Table 5 132 Table 5 133 Table 5 134 DRV_FAIWatchdogConfig Parameter Table ooocoonnninnnccnnnnonnncocnccnnnnnanono 235 DRV_FAIIntWatchdogStart Parameter Table n 236 DRV_FAIDmaWatchdogStart Parameter Table eceesesseeeteeneeeeeneees 237 DRV_FAICheckWatchdog Parameter Table cecseceeseeeeeeeteeteeneeneees 238 DRV_AllocateDMABuffer Parameter Table cece eee rere eeeeeee 239 DRV_FreeDMABuffer Parameter Table ccsecceeseseeeeeteeeeeteeeeeeeeeee 240
57. 8 Alarm operates the alarm 9 Communication port operates the communication port 10 High speed utilize DMA or Interrupt for data acquisition 11 Hardware supports Advantech I O products The Registry Configuration file stores data about hardware settings This data will be used for the driver during I O access Interface Application drivers provide APIs for applications The application programming interface API is described later in this manual Hardware drivers enable communication between peripheral devices and the computer through I O ports serial ports and memory For hardware configuration please refer to the user s manual that came with your hardware Requirements 1 32 bit operating environment including Windows 95 98 NT 2 Application programming interface supports the following e Microsoft Visual C 4 0 32 bit or higher for Windows 95 98 NT e Microsoft Visual Basic 4 0 32 bit or higher for Windows 95 98 NT e Borland Delphi 2 0 32 bit or higher for Windows 95 98 NT e Borland C 5 0 32 bit or higher for Windows 95 98 NT e Borland C Builder 1 0 32 bit or higher for Windows 95 98 NT Chapter 4 Function Overview 73 The driver provides a set of function calls for applications as shown in the following tables Device Functions DRV_DeviceOpen DRV_DeviceClose DRV_DeviceGetFeatures DRV_GetErrorMessage DRV_SelectDevice DRV_DeviceGetNumOfList DRV_DeviceGetList DRV_DeviceGetSubList DRV
58. 9 Frequency Measurement Directory Advantech Adsapi Examples Console freq Advantech Adsapi Examples VB freq Advantech Adsapi Examples VC freq 3 5 20 Temperature Measurement Directory Advantech Adsapi Examples Console thermo Advantech Adsapi Examples VB thermo Advantech Adsapi Examples Delphi thermo Advantech Adsapi Examples VC thermo 3 5 21 Alarm Directory Advantech Adsapi Examples VB alarm Advantech Adsapi Examples Delphi alarm Advantech Adsapi Examples VC alarm 3 5 22 PortI O Directory Advantech Adsapi Examples VB portio Advantech Adsapi Examples Delphi portio Advantech Adsapi Examples VC portio Chapter 3 Tutorial 69 70 3 5 23 Communication Directory Advantech Adsapi Examples VC comm 3 5 24 Event Function Directory Advantech Adsapi Examples VB addma adint cdadint cdaddma dipattn Advantech Adsapi Examples Delphi addma adint cdadint cdaddma dipattn Advantech Adsapi Examples VC addma adint cdadint cdaddma diint dipattn entint Note We also provide direct I O examples You can access them in the Driver CD ROM disc They locate in the dos directory Advantech DLL Drivers User s Manual CHAPTER Function Overview 4 1 Introduction Advantech s 32 bit DLL driver contains a set of functions and associ ated structures that can be used in various application programs for interfacing with Advantech I O Device Drivers The APIs support ma
59. AIIntWatchdogStart DRV_FAIWatchdogCheck DRV_FAICheck Buffer Full complete Yes y DRV_FAITransfer No Yes DRV_FAIStop Figure 4 8 Watchdog Triggering Call Flow Chapter 4 Function Overview 91 92 The DRV_FAIWatchdogConfig function configures the triggering conditions and levels for each channel The DRV_FAIIntWatchdogStart function starts the watchdog triggering It then runs in the background You can use the DRV_FAIWatchdogCheck function to check if the watchdog condition is matched with the triggered channel After the watchdog condition is matched you can use DRV_FAICheck to check the conversion status and DRV_FAITransfer to retrieve the data The rest is the same as interrupt triggering Note Besides interrupt transfer the driver also provides DRV_FAIDmaWatchdogStart function for DMA transfer Example Directory Advantech Adsapi Examples V B cdaddma Advantech Adsapi Examples Delphi cdaddma Advantech Adsapi Examples VC cdaddma Advantech Adsapi Examples V B cdadint Advantech Adsapi Examples Delphi cdadint Advantech Adsapi Examples V C cdadint Function Description Demo program for analog input function with Watchdog triggering 4 3 3 Performance Interrupt latency in Windows can impose performance limitations on data acquisition Interrupt latency is the delay between the time hardware asserts an interrupt and when the interrupt service routine is activated
60. AN DRV_GetAddress This is only used in Visual Basic In VC or Delphi users can get a pointer or address of a variable However in Visual Basic there is no standard function to get the memory address of a variable The DLL drivers require the address as a parameter when calling most functions Chapter 4 Function Overview 77 4 3 Analog Input Function Group 78 The analog input function group performs analog input functions It can acquire single point data multiple channel data and waveform data with interrupt or DMA triggering The analog input functions provide four kinds of operation according to the triggering mode and data transfer method Parameters Gain Type unsigned short Size 2 bytes and GainList Type a pointer to unsigned short array Size 4 bytes To acquire analog input data from Advantech data acquisition and control DA 8 C cards you must specify the input range s You can specify the input range s through the Gain parameter for single channel or the GainList parameter for multiple channels Gain and GainList represent physical hardware gain code s You can refer to the hardware manual for the mapping of input ranges and gain codes Alternately you can use the DRV_GetDeviceFeatures function to get the mapping TriggerMode Type unsigned short Size 2 bytes The conversion of analog input can be triggered by internal or external sources A TriggerMode parameter equal to zero represents int
61. AR LPT_TCMuxRead PT_TCMuxRead is used by DRV_TCMuxRead function Member Description Name Direction Type Range Description DasChan Input unsigned short 0 n n depends the sampled on hardware channel DasGain Input unsigned short see below gain code of the sampled channel on DASCard ExpChan Input unsigned short see below the thermocouple channel on the expansion board unsigned short 0 1 2 3 4 5 6 thermocouple type J 0 K 1 S 2 T 3 B 4 R 5 E 6 TempScale unsigned short 0 1 2 3 temperature unit Celsius 0 Fahrenheit 1 Rankine 2 Output long pointer to depends on measured floating point hardware temperature Table 5 122 PT_TCMuxRead Member Description 272 Advantech DLL Drivers User s Manual PT_AOConfig typedef struct tagPT_AOConfig 1 USHORT chan USHORT RefSrc FLOAT MaxValue FLOAT MinValue PT_AOConfig FAR LPT_AOConfig PT_AOConfig DRV_AOConfig function Member Description Name Direction Type Range Description chan Input unsigned short 0 n n depends the output on hardware channel Input unsigned short Oor1 reference source internal 0 or external 1 MaxValue Input floating point depends on max reference hardware voltage MinValue Input floating point depends on min reference hardware voltag Table 5 123 PT_AOContfig Member Description Chapter 5 Functions Reference 273 PT_AOBinaryOut typedef struct tagPT_AOBinaryOut 1 USHORT ch
62. COUPLE TYPE in the application software is selected the driver will perform the appropriate linearization for the selected thermocouple type with respect to any selected A D range However the optimum range is the A D range that can handle the entire temperature range for each supported thermocouple type 212 Advantech DLL Drivers User s Manual DRV_AlarmConfig status DRV_AlarmConfig DriverHandle lpAlarmConfig Purpose Configures the high and low limit value of the specified channel for alarm monitoring This function only supports ADAM modules Parameters E CE default assigned by DRV_DeviceOpen Ea 1 SN pointer to default the storage address PT_AlarmConfig for chan Lolimit and HiLimit Table 5 66 DRV_AlarmConfig Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidChannel if chan is out of range 4 CommTransmitFailed if COMWrite failed 5 CommReadFailed if there is no response 6 CommReceiveFailed if the response string is incorrect Note The high and low limit values can be configured either in the ADAM utility or by within this function By using this function the limit values can be changed at run time However this operation would take a maximum of 4 seconds Chapter 5 Functions Reference 213 DRV_AlarmEnable status DRV_AlarmEnable DriverHandle lpAlarmEnable Purpose Enables the alarm in either momentary or latching mode This function
63. ConInterruptFailure if connects interrupt failure Advantech DLL Drivers User s Manual DRV_FAOScale status DRV_FAOScale DriverHandle lpFAOScale Purpose Translates an array of floating point values that represent voltages into an array of binary values that produce those voltages when the driver writes the binary array to one of the boards This function uses the current analog output configuration settings to perform the conver sions Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpFAOScale Input Output long pointer to default the storage address for PT_FAOScale StartChan StopChan count VoltArray BinArray Table 5 95 DRV_FAOScale Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidCountNumber if count is zero Chapter 5 Functions Reference 243 DRV_FAOLoad status DRV_FAOLoad DriverHandle 1pFAOLoad Purpose Transfers the data from the buffer being used for the data acquisition operation to the specified data buffer Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen IpFAOLoad Input Output long pointer to default the storage address PT_FAOLoad for ActiveBuf DataBuffer start count Table 5 96 DRV_FAOLoad Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 Inval
64. DEVCFG INI The DEVCONFIG_COM data structure refers to DRIVER H 220 Advantech DLL Drivers User s Manual COMRead status COMRead DeviceHandle buffer BufferSize TimeOut FinalChar ReadCount Purpose Reads data from the specified serial port Parameters DeviceHandle Input long assigned by DeviceOpen buffer Output long pointer to string data buffer to store the received string TimeOut unsigned short waiting time for response FinalChar char final character ReadCount unsigned short read count in byte Table 5 74 COMRead Parameter Table Return 1 SUCCESS if successful 2 CommReadFailed if failed or no data received Note This function calls Windows API ReadComm to read the communi cation port This function returns if 1 A carriage return lt cr gt has been received The lt cr gt is not guaranteed to be the last character in the string 2 The buffer is full There may be some more data in the receive queue 3 Timeout The string is always null terminated upon returning Chapter 5 Functions Reference 221 COMWrite Name status COMWrite DeviceHandle buffer DataLength Purpose Writes data to the specified serial port Parameters Direction Type Description DeviceHandle Input long assigned by DeviceOpen buffer Input long pointer to string data buffer to store the transmitted string DataLength unsigned short data length in byte 222 Ta
65. DLL Driver Functions Supported By PCI 1710 1713 1711 1731 H aie oa h a 144 Advantech DLL Drivers User s Manual Device Function PCL 71A B 813B 728 MIC272 Device functions DRV_DeviceOpen DRV_DeviceClose y DRV_DeviceGetFeatures Analog input DRV_AIConfig DRV_AlGetConfig DRV_AlBinaryln DRV_AlScale DRV_AlVoltageln DRV_AlVoltagelnExp DRV_MAIConfig DRV_MAlBinaryln DRV_MAlVoltageln DRV_MAIVoltageInExp Analog output Ze ZA DRV_AOConfig DRV_AOBinaryOut DRV_AOVoltageOut DRV_AOScale Port I O functions DRV_WritePortByte DRV_WritePortWord DRV_ReadPortByte DRV_ReadPortWord Digital input output DRV_DioGetConfig DRV_DioSetPortMode DRV_DioReadPortByte DRV_DioWritePortByte DRV_DioReaaBit DRV_DioWriteBit DRV_DioGetCurrentDOByte DRV_DioGetCurrentDOBit Temperature DRV_TCMuxRead High speed functions DRV_CheckEvent DRV_EnableEvent eje 2l2l2l2l lt 21212 2lz ejeje je er 2 Leje He x H l J q alt Table 5 6 DLL Driver Functions Supported by Advantech Hardware Chapter 5 Functions Reference 145 Function PCI 1720 Device functions DRV_DeviceOpen DRV_DeviceClose DRV DeviceGetFeatures DRV_AlConfig DRV_AIBinaryIn DRV_AlVoltageln DRV_MAIBinaryln DRV_MAlVoltagelnExp DRV_AOVoltageOut DRV_AOScale DRV_WriteSyncAO Port I O functions DRV_ReadPortWord Digital in
66. DS836 DL L Support PCL 836 2 ADS841 DL L CAN Devices PCL 841 MIC 2630 PCM 3680 ADSDN5K DLL ADAM 5000 for DeviceNet protocol ADS1750 DLL Support PCI 1750 ADS1751 DLL Support PCI 1751 2 ADS1710 D 2 23 i 25 26 7 LL Support PCI 1710 ADS1720 D LL Support PCI 1720 29 ADS1760 D L Support PCI 1760 30 ADS1713 DLL Support PCI 1713 140 ADS1753 D Table 5 1 Driver File Descriptions LL 5 1 1 Function Support Tables The following table shows DLL functions that are supported by Advantech hardware Advantech DLL Drivers User s Manual Device Device functions PCL 816 PCL 812PG PCM 3718 H 2 a 2 DRV_DeviceGetFeatures Analog input DRV_AlGetConfig DRV_AlVoltageln 2 DRV_MAIConfig 2 L e 2 DRV_DeviceOpen DRV_DeviceClose 2 2 a ae 2l ealelea aleale DRV_MAlBinaryln DRV_MAIVoltagelnExp DRV_AOBinaryOut Port I O functions DRV_ReadPortByte Digital input output DRV_DioReadPortByte DRV_DioWriteBit DRV_DioGetCurrentDOBit Temperatu re DRV_TCMuxRead Table 5 2 DLL Functions Supported By Advantech Hardware f 2 2 ejeje jejejejejeje 14 e jejejejeje jejeje 14 2 4 2 2 2 2 2 2 2 wA 2 a ele 2 2 22 a a a AFA Leje Leje Leje ele 2 2jojojejeje 2 2 lt lt a AA e 2 je ale Leje Eata 2 Chap
67. DriverHandle Input long default assigned by DRV_DeviceOpen IpMAIConfig Input Output long pointer to default the storage PT_MAIConfig address for NumChan StartChan and GainArray Table 5 27 DRV_MAIConfig Parameter Table Return e SUCCESS if successful e InvalidDriverHandle if DriverHandle NULL e InvalidInputParam if GainArray NULL InvalidChannel if NumChan is out of allowable range e AIConfig return code 168 Advantech DLL Drivers User s Manual DRV_MAIBinarylin status DRV_MAIBinaryIn DriverHandle lpMAIBinaryIn Purpose Reads analog input channels and returns the unscaled results Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpMAIBinaryIn Input Output long pointer to default the storage PT_MAIBinaryl address for n NumChan StartChan TrigMode and ReadingArray Table 5 28 DRV_MAIBinaryln Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidInputParam if ReadingArray NULL A AlBinaryln return code Chapter 5 Functions Reference 169 DRV_MAlVoltageln status DRV_MAIVoltageln DriverHandle 1pMAIVoltageln Purpose Reads analog input channels and returns the results scaled to voltages units volts Parameters Direction Description DriverHandle Input long default assigned by DRV_DeviceOpen IpMAIVoltagel Input Output long pointer to default the st
68. DualDmaStart occcnnnnnnnananannonononanannnnnnonnnnnnonononononos 232 DRV_FAIDualDmaScanStatt occcnnnnncnnnononononannonananananoncnnnnnnos 233 DRV_FATWatchdogConfig cccoccnoccnoncnoncnoninonanaccnanccannrnnccnno ns 235 DRV_FAIIntWatchdogStart oooonocnnncnoccconcconncnonannonancnnnc nnoono 236 DRV_FAIDmaWatchdogStart 000 eee eeeeeeeeeereeereeeneeeaeees 237 DRV_FAICheck Watchdog oooccnoccnccconcconcconnconncnnnonancnnncnnncons 238 DRV_AllocateDMABuffer c00ocococononononuonononononananannonononononononos 239 DRV_FreeDMABuffer c ccccccncnnnnnnnncnnnnnanonanananananannn corona no nonnnnn 240 DRV_FAODmaStart e ie itirir or EA VEES EEI EoD raTa 242 DRV FAOScale iia 243 DRY FAOL ados rial dt 244 DRV_FAOCh ck cti a t aae a a a A E e 245 DRV_A_FAO StOpPeiiaismit abs erii 246 DRY EnableEVent ei na a r seateeereeens 247 DRN CGhecKEV Nt iiss sssceseass cocssssacetedsangesvabaderancedsbacataserasnaceys 248 DRV_TimerCountSetting ooconoccnnonconononcconaconacannnnnnonanonancnna ns 249 IBI IEE ATDA a EEE E Ras 250 5 3 Data Steuer sevsssessissvsssesessscaceosssnesessvansdeadecssaneseecsobosesse 251 GAN ST aee dis e eere 251 DEVEEATURES eeano aar ae a a e eT 252 AOSET ica aa illa 255 DAUGHTERSE ee e e Wonca Geen vauavies N 256 DEV CONFIG AL viii iii br 257 DEVCEONETG COM 6 i ciccscodsisscodsisdevvaistavvene eansoutenadecdnantlasent 258 TRIGEEN Bluest ar Gee ek BEA 259 PT EVEIST DEVEIST ern ia ks ble e uN 260 PT_DeviceGetFeatures
69. ErrMsg As String 80 Error string Dim DeviceHandle As Long Dim AiConfig As PT_AIConfig Dim AiVoltageln As PT_AlVoltageln Dim voltage As Single Step 1 open device ErrCde DRV_DeviceOpen 0 DeviceHandle Make sure device number 0 If ErrCde lt gt 0 Then DRV_GetErrorMessage ErrCde szErrMsg Response MsgBox szErrMsg vbOKOnly Error Exit Sub End If Step 2 configure input range AiConfig DasChan 0 channel 0 AiConfig DasGain 0 ErrCde DRV_AIConfig DeviceHandle AiConfig If ErrCde lt gt 0 Then DRV_GetErrorMessage ErrCde szErrMsg gain code 0 Response MsgBox szErrMsg vbOKOnly Error Exit Sub End If Step 3 read value AiVoltageIn chan AiConfig DasChan AiVoltageIn gain AiConfig DasGain AiVoltageIn TrigMode 0 AiVoltageIn voltage DRV_GetAddress voltage ErrCde DRV_AIVoltageIn DeviceHandle AiVoltageln If ErrCde lt gt 0 Then DRV_GetErrorMessage ErrCde szErrMsg Response MsgBox szErrMsg vbOKOnly Error Exit Sub End If Step 4 display value txtAIValue Text Format voltage 0 00 Y Step 5 close device ErrCde DRV_DeviceClose DeviceHandle If ErrCde lt gt 0 Then DRV_GetErrorMessage ErrCde szErrMsg Response MsgBox szErrMsg vbOKOnly Error End If End Sub 60 Advantech DLL Drivers User s Manual Notice The DRV_GetAddress function is for Visual Basic only In VC or Delphi users can get a point
70. ExpChan FLOAT far voltage PT_AIVoltageInExp FAR LPT_AIVoltageInExp PT_AIVoltageInExp is used by DRV_AIVoltageInExp function Member Description Name DasChan DasGain Direction Input Input Type unsigned short unsigned short Range 0 n n depends on hardware refer to gain list in hardware manual Description the sampled channel on the DASCard the gain code of the channel on DAS card ExpChan Input unsigned short see below the sampled channel on the expansion board voltage Output long pointer to floating point depends on input range the measured voltage returned scaled to units of volts Table 5 117 PT_AlVoltagelnExp Member Description Chapter 5 Functions Reference 267 PT_MAIConfig typedef struct tagPT_MAIConfig 1 USHORT NumChan USHORT StartChan USHORT far GainArray PT_MAIConfig FAR LPT_MAIConfig PT_MAIConfig is used by DRV_MAIConfig function Member Description Name Direction Type Range Description NumChan Input unsigned short 1 n n depends number of on hardware channels StartChan unsigned short 0 n n depends the start one of on hardware scan channels GainArray long pointer to refer to gain gain code list unsigned short code list in arra hardware manual Table 5 118 PT_MAIConfig Member Description 268 Advantech DLL Drivers User s Manual PT_MAIBinaryln typedef struct tagPT_MAIBinar
71. Functions Reference 147 Device Function PCI 1753 Device functions DRV_WritePortByte DRV_ReadPortByte Digital input output DRV_DioGetConfig DRV_DioReadPortByte DRV_DioReadBit DRV_DioGetCurrentDOByte DRV_DioGetCurrentDOBit DRV_CounterEventStart DRV_CounterFregStart DRV_QCounterConfig DRV_QCounterConfigSys DRV_QCounterRead DRV_CounterPWMEnable DRV_DICounterReset DRV_CheckEvent y DRV_TimerCountSetting Table 5 9 DLL Driver Support for PCI 1753 148 Advantech DLL Drivers User s Manual Devices ADAM ADAM ADAM ADAM 4012 4014D 4018 4017 4018M 50 4013 5017 18 Device functions DRV_DeviceOpen DRV_DeviceClose DRV_DeviceGetFeatu Analog input DRV_AlGetConfig DRV_AlVoltageln DRV_AlVoltagelnExp DRV_MAIContfig DRV_MAIVoltageln DRV_MAIVoltagelnEx Analog output DRV_AOVoltageOut Digital input output DRV_DioGetConfig DRV_DioSetPortMode DRV_DioReadPortByt DRV_DioWritePortByt DRV_DioReadBit DRV_DioWriteBit DRV_DioGetCurrentD DRV_DioGetCurrentD Temperature DRV_TCMuxRead Counter functions DRV_CounterEventSt DRV_CounterEventRe DRV_CounterReset Alarm functions DRV_AlarmConfig DRV_AlarmEnable DRV_AlarmCheck DRV_AlarmReset y y Ni 2 2 2 y e 2 i HULL THL 2 e e 2 2 J HHE A 2j 2 2 2 2 2l 2 2 T T T T T T y Y X N Ai N y y Y NV N N 2
72. In DOS the interrupt latency is minimal because the hardware transfers control directly to the interrupt service routine In Windows however system software transfers control to the interrupt Advantech DLL Drivers User s Manual 4 4 service routine imposing a software delay The interrupt latency limits the performance of the interrupt data transfer It also can slow data acquisition that uses DMA when DMA reprogramming is required because it can cause significant pauses between data transfer requests from the DMA controller The driver may have to reprogram the DMA controller for a conversion count larger than 64 KB Pauses during high speed input operations can cause acquisition boards to miss or overwrite data points To eliminate the interrupt latency the driver does not reprogram the DMA for a conversion count larger than 64 KB It utilizes the double buffering technique In addition some data acquisition boards provide FIFO interrupt to reduce the frequency of the hardware interrupt The data is stored in FIFO on board After some specified conversion count the input board generates an interrupt to inform the driver to retrieve the data from the FIFO The data retrieving does not disturb the data acquisition Analog Output Function Group The analog output function group performs analog output functions It includes single point data output waveform data output and synchro nous output 4 4 1 Single Point Output Call
73. Introduction to the 32 bit Windows 95 98 NT DLL Driver 11 Figure 1 14 Click OK When the Uninstallation Completes 1 3 Device Installation Utility Configuration Program The configuration utility is a software program that allows you to configure your hardware and store the settings in your Windows registry These settings will be used when you call the APIs of the Advantech 32 bit DLL drivers To set up or configure each I O device within the configuration utility complete the following procedure 1 Select Setup Device from the main menu T Vidrantech Device Inslalaten BEE Figure 1 15 Installing a Device in the Device Installation Utility 2 You can see the installed devices in the O Device Installation window 12 Advantech DLL Drivers User s Manual LT Deve liinaa p cs a COT r EMO E a Addrantech LUM Direc Aaah POL oy et PG Figure 1 16 I O Device Installation Window 3 Scroll down the List of Devices list box and select the device that you want to install Click the Install button Note If there are any existing devices of that type installed on your computer a dialog box will load to display them Select the device that you want to operate from the listing and press the OK button A Mirrors Figure 1 17 Existing Device Found 4 Aconfiguration dialog box will load for the specified device Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Driver 13
74. LL Driver Start Menu Program Shortcuts 1 2 2 File Structure The Advantech DLL Drivers files are installed by default into the c Program Files Advantech ADSAPI This root directory contains the Device Installation Utility DEVINST EXE the Advantech Device Testing Utility and many help files for using the DLL Drivers with specific Advantech hardware products The subdirectories of this folder contain many examples of using the DLL Drivers with Microsoft Visual Basic Microsoft Visual C Borland Delphi and other related documentation that will help you get the most of your development projects for Advantech hardware Advantech DLL Drivers User s Manual 1 2 3 Uninstalling the DLL Drivers The Advantech DLL Drivers include an uninstallation utility to help your remove the software from your computer To uninstall the software complete the following procedure 1 Select Settings Control Panel Add Remove Programs from the Windows Start menu Click the Install Uninstall tab 2 Highlight the item Advantech Driver for Windows 95 98 or Advantech Driver for NT and then click the Add Remove button E j A Figure 1 13 Windows Control Panel Add Remove Programs Dialog Box 3 When the Confirm File Deletion message box loads click the Yes button 4 The files will be removed from your computer When the uninstal lation is complete click the OK button in the Remove Programs From Your Computer dialog window Chapter 1
75. LONG DriverHandle LPT_EnableEventEx IpEnableEventEx Purpose Enable or Disable PCI 1760 Event extension PCI 1760 event exten sion includes Digital Filter Pattern Match Change of Input State Counter Match and Counter Overflow Parameters Direction Description DriverHandle long Default assigned by DRV_DeviceOpen IpEnableEventEx long pointer to Default the storage PT_EnableEvent address for union Ex structure PT_DIFilter PT_DIPattern PT_DIConter and PT_DIStatus Table 5 31 DRV_EnableEventEx Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 172 Advantech DLL Drivers User s Manual DRV_FDITransfer status DRV_FDITransfer LONG DriverHandle LPT_FDITransfer IpFDITransfer Purpose Access hardware data while event interrupt happened The event interrupt includes Digital Filter Pattern Match Change of Input State Counter Match and Counter Overflow Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpFDITransfer Input Output long pointer to default the storage address PT_FDITransfer for usEventType and ulRetData Table 5 32 DRV_FDITransfer Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL Chapter 5 Functions Reference 173 DRV_AOConfig status DRV_AOConfig DriverHandle lpA
76. OConfig Purpose Records the output range and polarity selected for each analog output channel It is optional Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen IpAOConfig Input Output long pointer to default the storage address PT_AOConfig for chan RefSrc MaxValue and MinValue Table 5 33 DRV_AOConfig Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidChan if input channel is out of range 4 BoardIDNotSupported if this function is not supported for this Device Note 1 This function will overwrite the default configuration data 2 By using this function it allows the output range to change at run time 3 These configuration changes are only temporary at run time The configuration data stored in the file or Registry is not modified 174 Advantech DLL Drivers User s Manual DRV_AOVoltageOut status DRV_AOVoltageOut DriverHandle lpAOVoltageOut Purpose Accepts a floating point voltage value scales it to the proper binary number and writes that number to an analog output channel to change the output voltage Parameters Name Direction Pee Pee default assigned by DRV_DeviceOpen sia cae ERRADA pointer to default the storage PT_AOVoltageOut address for chan and OutputValue Table 5 34 DRV_AOVoltageOut Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle
77. Project Manager option to design your application forms and write the code A Project Manager pop up dialog will be shown on the screen 36 Advantech DLL Drivers User s Manual Figure 2 16 Opening the Project Manager 3 You should first add the Advantech 32 bit DLL driver header file into your application project by clicking Project Add to Project from the main menu Borland Delphi will display a search dialog box to select the location of the DLL header file Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 37 Figure 2 17 Adding Header File Into Your Project 38 Advantech DLL Drivers User s Manual 4 Select the DLL header file Driver pas and click the OK button The Project Manager dialog box will show this header file and its location Figure 2 18 Adding the DLL Header File 5 Double click the header file You will find the constant defini tions parameter declarations and DLL function calls that can be used in your DA amp C applications Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 39 40 v She derdaraboas of Fumrbrass daba abrasbar COBBCAECA dey ARPA AE Wace 17 501 I pripe Cade ae 1 Coppedphe ges 55 Ajranteci decp Ltd 1 413 Sipica cid rad Y AAA AAA ARA i Comprgar Eefamerren pes nr aa bar O Bac fe o bee E mar Sesgdh af derim Basins HsaPare LETTI TEET Figure 2 19 Constants Parameters and DLL Function Calls 6 Create your forms and D
78. Purpose Transfers the data from the buffer being used for the data acquisition operation to the specified data buffer Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpFAlTransfer Input Output long pointer to default the storage address PT_FAlTransfer for ActiveBuf DataBuffer DataType start count overrun Table 5 82 DRV_FAITransfer Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidCountNumber has the kinds of condition start point is bigger conversion number count is bigger conversion number or count is zero Chapter 5 Functions Reference 229 DRV_FAICheck status DRV_FAICheck DriverHandle lpFAICheck Purpose Checks if the current data acquisition is complete and return current status Parameters Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpFAICheck Input Output long pointer to default the storage address PT_FAICheck for ActiveBuf stopped retrieved overrun Table 5 83 DRV_FAlCheck Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 230 Advantech DLL Drivers User s Manual DRV_FAIStop status DRV_FAIStop DriverHandle Purpose Cancels the current data acquisition operation and resets the hardware and software Parameters Name Direction Type Ra
79. UnknownResponse Unknown Response On Port d MACID XH 209 DNNotEnoughBuffer Message Length Is Too Long on Port d MACID XH DNFragResponseError Fragment Response Error On Port d MACID XH 211 DNTooMuchDataAck Too Much Data Acknowledge On Port d MACID XH 212 DNFragRequestError DNEnableEventError 214 DNCreateOrOpenEventError Fragment Request Error On Port d MACID XH Event Enable Disable Error On Port d MACID XH Device Net Driver Create Open Event Failed On Port d MACID XH 215 DNIORequestError IO Message Request Error On Port d MACID XH 216 DNGetEventNameError 217 DNTimeQutError Get Event Name From CAN Driver Failed On Port d MACID XH Wait For Message Time Out Error On Port d MACID XH 218 DNOpenFailed Open CAN Card Failed 219 DNCloseFailed DNResetFailed DeviceNet Reset Failed Table A 4 Status Code Summary Close CAN Card Failed Appendix A DLL Driver Error Codes 335 336 Advantech DLL Drivers User s Manual
80. _GetAddress Analog Input DRV_AIConfig DRV_AlGetConfig DRV_AlBinaryln DRV_AlScale DRV_AlVoltageln DRV_AlVoltagelnExp DRV_MAIConfig DRV_MAIBinaryln DRV_MAIVoltageln DRV_MAlVoltagelnExp Analog Output DRV_AOConfig DRV_AOBinaryOut DRV_AOVoltageOut DRV_AOScale Digital Input Output DRV_DioGetConfig DRV_DioSetPortMode DRV_DioReadPortByte DRV_DioWritePortByte DRV_DioReaaBit DRV_DioWriteBit DRV_DioGetCurrentDOByte DRV_DioGetCurrentDOBit Table 4 1 Device Analog Input Output Digital Input Output Function Calls Temp Measure DRV_TCMuxRead DRV_into Port I O Functions DRV_WritePortByte DRV_WritePortWord DRV_ReadPortByte DRV_ReadPortWord DRV_outp DRV_outpw DRV_intpw Alarm Functions DRV_AlarmContfig DRV_AlarmEnable DRV_AlarmCheck DRV_AlarmReset Counter Functions DRV_CounterEventStart DRV_CounterEventRead DRV_CounterFreqStart DRV_CounterFreqRead DRV_CounterPulseStart DRV_CounterReset DRV_QCounterContig DRV_QCounterConfigSys DRV_QCounterStart DRV_QCounterRead Table 4 2 Temp Measurement Port I O Alarm and Counter Function Calls High Speed Function for Analog Input High Speed Function for Analog Output Event Function and Others DRV_FAIIntStart DRV_FAIDmasStart DRV_FAIIntScanStart DRV_FAIDmaScanStart DRV_FAICheck DRV_FAITransfer DRV_FAIStop DRV_FAIDualDmaStart DRV_FAIDualDmaScanStart DRV_FAIWatchdogConfig DRV_FAIIntWatchdogStart DRV_FAIDmaWatchdogStart DRV_FAIWat
81. aStart status DRV_FAIDmaStart DriverHandle lpFAIDmaStart Purpose Initiates an asynchronous single channel data acquisition operation with DMA and stores its input in an array Parameters Mo peon long default assigned by DRV_DeviceOpen IpFAIDmaStart Input Output long pointer to default the storage address PT_FAlDmaStart for TrigSrc SampleRate chan gain buffer count Table 5 79 DRV_FAlDmaStart Parameter Table 226 Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if buffer NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidGain if gain code is incorrect 6 InvalidChannel if chan is out of range 7 InvalidCountNumber have these conditions count is zero count is not even counter is less than 2048 When you do analog input with DMA transfer conversion number must be bigger than 2048 The size of Data must be bigger than PAGE_SIZE 4K 8 IllegalSpeed if SampleRate is out of range 9 InvalidEventCount if EventCount is zero 10 ChanConflict if interrupt channel is conflict 11 OpenEventFailed if event name opens failure 12 KelnsufficientResources if resource is conflict with another driver 13 KeConInterruptFailure if connects interrupt failure Advantech DLL Drivers User s Manual DRV_FAlIniScanStart status DRV_FAIIntScanStart DriverHandle lpFAIIntScanStart Purpose Initiates an async
82. al H n ft e eicnraireriarts coker TET car epi LF ppa Errids WA Blokeoa iernii LET bdo An pido tite 1 frvtxe LTR In_sstrrtagi RL tie top E E E Figure 2 7 Adding the DLL Import Library Into Your Project 8 Select the Link page in the Project Settings pop up dialog box and then set the Category field to be Input Insert adsapi32 lib in Object library modules and click the OK button The DLL driver library will be linked with your application object file and be built into an application execution file through the Build menu 28 Advantech DLL Drivers User s Manual ji D E Soure Fies E PDS ppp E Fsgin cpg Fl gin ee W Arcadio ba E Esdiitc opp E O Headed Files E y Arquer Filme JW Adss pil Eb fragor baten increentaboo fodbe Release Pidi pb nechine Hb jout Pel ree Figo eee midya Figure 2 8 Linking Your DLL Driver Libray to Your Project Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 29 2 3 Using Microsoft Visual Basic To use the DA amp C functions you must use the DA amp C DLL Follow this procedure 1 Select File New Project from the main menu to create your forms and code as you would for any other Visual Basic program Figure 2 9 Creating a New Visual Basic Project 2 In order to develop a DA amp C application with Advantech DLL drivers you have to first include the Advantech DLL driver for Visual Basic header file The way to include the header file into yo
83. an USHORT BinData PT_AOBinaryOut FAR LPT_AOBinaryOut PT_AOBinaryOut is used by DRV_AOBinaryOut function Member Description Name Direction Type Range Description chan Input unsigned short 0 n n depends the output on hardware channel hardware be written Table 5 124 PT_AOBinaryOut Member Description 274 Advantech DLL Drivers User s Manual PT_AOVoltageOut typedef struct tagPT_AOVoltageOut USHORT chan FLOAT OutputValue PT_AOVoltage0ut FAR LPT_AOVoltageOut PT_AOVoltageOut is used by DRV_AOVoltageOut function Member Description Name Direction Type Range Description chan Input unsigned short 0 n n depends the output on hardware channel OutputValue Input floating point Min DA Ref lt floating point voltage lt Max value to be DA Ref scaled and written Table 5 125 PT_AOVoltageOut Member Description Chapter 5 Functions Reference 275 PT_AOScale typedef struct tagPT_AOScale USHORT chan FLOAT OutputValue USHORT far BinData PT_AOScale FAR LPT_AOScale PT_AOScale is used by DRV_AOScale function Member Description Name Direction Type Range Description chan unsigned short 0 n n depends the output on hardware channel OutputValue floating Min DA Ref lt floating value to voltage lt Max be scaled DA Ref Output long pointer to converted binary unsigned short hardware value returned Table 5 126 PT_AOScale Member Description
84. analog output test panel as shown below It allows you to output sine square and triangle waveforms automatically or output a single value manually You can configure the waveform frequency and switch the output channel by using the up or down button Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Driver 15 Figure 1 21 Advantech Device Test Utility Analog output tab Click on the Digital input tab to switch to the digital input test panel as shown below You can use the up or down arrows to switch the digital input channel Figure 1 22 Advantech Device Test Utility Digital input tab Click on the Digital output tab to switch to the digital output test panel as shown below By pressing the buttons on the panel you can output the desired values to the corresponding ports You can use the up or down arrows to switch the digital output channel 16 Advantech DLL Drivers User s Manual Figure 1 23 Advantech Device Test Utility Digital output tab Click on the Counter tab to switch to the counter test panel as shown below It provides event counting and pulse output functions You can configure the pulse frequency by using the scroll bars You can also switch the counter channel by using the up or down arrows Figure 1 24 Advantech Device Test Utility Counter tab Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Driver 17 18 Advantech DLL Drivers User s Manual CHAPTER 2 Creating Wi
85. ange BoardIDNotSupported if this function is not supported for this device Chapter 5 Functions Reference 177 DRV_EnableSyncAO status DRV_EnableSyncAO DriverHandle Enable Purpose Enable or Disable synchronized output operation Note that synchro nized output should be configured using DRV_WriteSyncAO before it 1s enabled or disabled Parameters Direction Type Range Description DriverHandle Input long Default assigned by DRV_DeviceOpen Enable Input unsign short Default Enable channel data Table 5 37 DRV_EnableSyncAO Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidChan if input channel is out of range 4 BoardIDNotSupported if this function is not supported for this device 178 Advantech DLL Drivers User s Manual DRV_WriteSyncAO status DRV_WriteSyncAO DriverHandle Purpose Set the Synchronized output bit for synchronized output operation Parameters Name Direction Type Range Description Table 5 38 DRV_WriteSyncAO Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL Chapter 5 Functions Reference 179 DRV_AOCurrentOut status DRV_AOCurrentOut DriverHandle IpAOCurrentOut Purpose Output value to Current Sink Connections Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen LpAOCurrentO Input Output long point
86. antech DLL Drivers User s Manual PT_DIFilter typedef struct tagPT_DIFilter USHORT usEventType USHORT usEventEnable USHORT usCount USHORT usEnable USHORT far usHiValue USHORT far usLow Value PT_DIFilter FAR LPT_DIFilter PT_DIFilter is used by DRV_EnableEventEx function Member Description usEventType unsigned short default event type usEventEnable unsigned short default event enable disable bit usCount unsigned short default event count usEnable unsigned short default counter0 counter7 enable disable setting For example if bit0 1 counter0 is enabled unsigned short value array pointer unsigned short value array pointer Table 5 176 PT_DIFilter Member Description Chapter 5 Functions Reference 327 PT_DIPattern typedef struct tagPT_DIPattern USHORT usEventType USHORT usEventEnable USHORT usCount USHORT usEnable USHORT us Value PT_DIPattern FAR LPT_DIPattern PT_DIPattern is used by DRV_EnableEventEx function Member Description Name Direction Type Description usEventType Input unsigned short event type usEventEnable unsigned short counterO counter7 enable disable setting For example if bit0 1 counterO is enabled usCount unsigned short default event count usEnable unsigned short default the match function of pattern enable disable setting For example if bit0 1 the match function of pattern is enabled usValue unsigned short patt
87. arameter Table eceesceseseeeeeeeeeeeeeeeeeeeeeeaeeeeeeees 213 DRV_AlarmEnable Parameter Table ccccceeeeeeeeeeeeeeneeseneeeteneeetes 214 DRV_AlarmCheck Parameter Table 0 ccccccceceeeeeeeseeeeeeeeeeeseeseeeeees 215 DRV_AlarmReset Parameter Table ccceececeeeeeeeeeeeeeeseneeeseneeeteneeenes 216 COMOpen Parameter Table oooccocccinccnccnccnocccncconcconnconn cnn anna cnn cnn cnn cnn 217 COMClose Parameter Table oooocnconiccnnconccnnccconcconcnoncconc nono nonn cnn cnanc cnn 218 COMGetConfig Parameter Table ooonociconicnnnccnnccoccnoccconccnncccncccnnncna nono 219 COMSetConfig Parameter Table ecceeeeeceeseeneeeeeeeeeeeeeeeeeeeeseeeeneeaeeees 220 COMRead Parameter Table c ccccceecceeseceeeceeeeeeeeeeeeeaeeeaeeeeeeseeeeeeeees 221 COMWrite Parameter Table ooonccccnncccccoocccoooncconononononononnnononnnonnnnononnno 222 COMWrite232 Parameter Table ooocococccococococacioonnccononononncononnnononnnononnnos 223 COMEscape Parameter Table ccccccceseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeees 224 DRV_FAIIntStart Parameter Table cccccccccccssecessecesssecesseeeesseeessseeeees 225 DRV_FAIDmaStart Parameter Table cccccccsscccssecessseceesseeeesseeeeseeeess 226 DRV_FAIIntScanStart Parameter Table ccccccsseceseeeeeeeeeeseeeteeeeenees 227 DRV_FAIDmaScanStart Parameter Table coooooccccccncccccccoonncnonnnononanonon 22
88. ardware uses default value to initialize its counter setting This initialization will take about 2 external trigger cycle time to finish If DRV_CounterEventRead is called before initialization is finished then the program will get incorrect value So you have to delay 2 external trigger cycle time in program before calling DRV_CounterEventRead to make sure the return value is correct The delay time is dependent of the time of external trigger 194 Advantech DLL Drivers User s Manual DRV_CounterEventRead status DRV_CounterEventRead DriverHandle lpCounterEventRead Purpose Reads the current counter total without disturbing the counting process and returns the count and overflow conditions Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpCounterEventRead Input Output long pointer to default the storage address for PT_CounterEventRead counter overflow and count Table 5 53 DRV_CounterEventRead Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Chapter 5 Functions Reference 195 DRV_CounterFreqStart status DRV_CounterFregStart DriverHandle lpCounterFreqStart Purpose Configures the specified counter for frequency measurement and starts the counter
89. ator to the frequency measure ment counter s clock source input If hardware gating in which the counter may be started by a separate external hardware input is desired choose a gating type and use an external device to trigger the gate input of the gate period counter fixed at channel 9 by this function For Intel 8254 chip there is no gate period counter The function uses the Windows API to get the time period between two samples The frequency is then derived from the time period and count incre ment Chapter 5 Functions Reference 197 DRV_CounterFreqRead status DRV_CounterFreqRead DriverHandle lpCounterFreqRead Purpose Reads the frequency measurement Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpCounterFreqRead Input Output long pointer to default the storage address for PT_CounterFreq counter and freq Table 5 55 DRV_CounterFreqRead Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range FreqMeasurementFailed if the time interval for frequency measurement is too small 198 Advantech DLL Drivers User s Manual DRV_CounterPulseStart status DRV_CounterPulseStart DriverHandle lpCounterPulseStart Purpose Configures the specifie
90. available channels on 0 n n depends on hardware depends on input range on hardware buffer Output long pointer to unsigned short array data buffer allocated by user depends on I O register format on hardware count Input unsigned long 1 65536 conversion count Table 5 158 PT_FAlDmaScanStart Member Description Chapter 5 Functions Reference 309 PT_FAlDualDmaStart typedef struct tagPT_FAIDualDmaStart 1 USHORT DWORD USHORT USHORT USHORT USHORT ULONG TrigSrc SampleRate chan gain far BufferA far BufferB count PT_FAIDualDmaStart FAR LPT_FAIDualDmaStart PT_FAIDualDmaStart is used by DRV_FAIDualDmaStart function Member Description Name Direction Type Description TrigSrc SampleRate chan gain BufferA Input Output unsigned short floating point unsigned short unsigned short long pointer to unsigned short array depends on the pacer on hardware 0 n n depends on hardware depends on input range on hardware depends on I O register format on hardware triggering source external 1 internal 0 sampling rate in second the sampled channel gain code data buffer BufferB Output long pointer to unsigned short arra unsigned long depends on I O register format on hardware 1 65536 data buffer conversion count Table 5 159 PT_FAlDualDmaStart Member Description
91. ber Description Chapter 5 Functions Reference 301 PT_CounterPWMSetting typedef struct tagPT_CounterPWMSetting USHORT Port FLOAT Period FLOAT HiPeriod ULONG OutCount USHORT GateMode PT_CounterPWMSetting FAR LPT_CounterPWMSetting PT_CounterPWMSetting is used by DRV_CounterPWMSetting function Member Description Name Port Input Direction Type unsigned short Description counter port Period HiPeriod Input Input floating point floating point time period upcycle time period OutCount GateMode Input Input long unsigned short stop count gate mode of PWM Table 5 151 PT_CounterPWMSetting Member Description 302 Advantech DLL Drivers User s Manual PT_AlarmConfig typedef struct tagPT_AlarmConfig 1 USHORT chan FLOAT LoLimit FLOAT HiLimit PT_AlarmConfig FAR LPT_AlarmConfig PT_AlarmConfig is used by DRV_AlarmConfig function Member Description Direction____ Type Description Input unsigned short the channel for alarm monitoring Name alarm monitoring alarm monitoring Table 5 152 PT_AlarmConfig Member Description Chapter 5 Functions Reference 303 PT_AlarmEnable typedef struct tagPT_AlarmEnable 1 USHORT chan USHORT LatchMode USHORT enabled PT_AlarmEnable FAR LPT_AlarmEnable PT_AlarmEnable is used by DRV_AlarmEnable function Member Description Name Direction Type Descri
92. ble 5 75 COMWrite Parameter Table Return 1 SUCCESS if successful 2 CommTransmitFailed if the transmission failed Note This function calls COMWrite232 COMWrite485 or COMWrite85 function according to the transmission mode configured by device installation utility Advantech DLL Drivers User s Manual COMWrite232 Name status COMWrite232 DeviceHandle buffer DataLength Purpose Writes data to the specified serial port Parameters Direction Type Description DeviceHandle Input long assigned by DeviceOpen buffer Input long pointer to string data buffer to store the transmitted string DataLength Input data length in bytes Table 5 76 COMWrite232 Parameter Table Return 1 SUCCESS if successful 2 CommTransmitFailed if the transmission failed Note This function calls Windows API WriteComm to write to the communication port Chapter 5 Functions Reference 223 COMEscape status COMEscape DeviceHandle escape Purpose This routine provides scape services to the callers Parameters Name sd Direction Type Description DeviceHandle long assigned by DeviceOpen escape unsigned short the escape service type Table 5 77 COMEscape Parameter Table Return 1 SUCCESS if successful Note The escape service type escape 1 EscapeFlushInput 2 EscapeFlushOutput 3 EscapeSetBreak 4 EscapeClearBreak The communication port settings are store
93. bleEvent to enable message sending The driver will then send messages when the hardware interrupt occurs Please refer to Event Message Functions section for details Parameters Cyclic Type Unsigned Short Size 2 bytes To output waveform data the analog input function group provides non cyclic and continuous cyclic output You can set the Cyclic parameter to 1 for continuous operation or 0 for non cyclic operation Advantech DLL Drivers User s Manual SampleRate Type Floating Point Size 4 bytes The SampeRate parameter specifies the rate to output one data item in Hz The driver uses it to program the on board pacer Count Type Unsigned Long Size 4 bytes The Count parameter specifies the number of outputs It ranges from 1 to 65535 TrigSrc Type unsigned short Size 2 bytes The operation of analog output can be triggered by internal or external sources The TrigSrc parameter equals zero to represent internal and 1 for external 4 4 3 1 Interrupt Triggering Call Flow The call flow for analog output with interrupt triggering is shown below Chapter 4 Function Overview 97 Channel SampleRate Cyclic Count TrigSrc Voltage Data DRV_FAOScale DRV_FAOIntStart DRV_FAOCheck Output Statu complete Yes Yes DRV_FAOScale DRV_FAOLoad Repeated No DRV_FAOStop Figure 4 11 Interrupt Triggering Function Call Flow 98 Advantech DLL Drivers User s Manual The DRV_FAOIntStart function starts
94. by user array unsigned long 1 65536 output count unsigned short cyclic mode cyclic 1 non cyclic 0 Table 5 167 PT_FAOIntStart Member Description 318 Advantech DLL Drivers User s Manual PT_FAODmaStart typedef struct tagPT_FAODmaStart 1 USHORT TrigSrc DWORD SampleRate USHORT chan LONG far buffer ULONG count PT_FAODmaStart FAR LPT_FAODmaStart PT_FAODmaStart is used by DRV_FAODmaStart function Member Description Name Direction Type Description TrigSrc Input SampleRate Chan Buffer Output unsigned short floating point unsigned short long pointer to unsigned short array depends on hardware 0 n n depends on hardware depends on hardware triggering source external 1 internal 0 sampling rate in second the sampled channel data buffer allocated by AllocateDMABu ffer or user unsigned long 1 65536 output count Table 5 168 PT_FAODmaStart Member Description Chapter 5 Functions Reference 319 PT_FAOScale typedef struct tagPT_FAOScale 1 USHORT chan ULONG count FLOAT far VoltArray USHORT far BinArray PT_FAOScale FAR LPT_FAOScale PT_FAOScale is used by DRV_FAOScale function Member Description Direction Type Description Input unsigned short Channel number VoltArray BinArray Input Input Output unsigned long long pointer to floating poi
95. bytes digital output The port number of the board is from 0 to 3 Parameters Direction Type Range Description DriverHandle Input long assigned by DRV_DeviceOpen IpDioWriteBit Input Output long pointer to the storage address PT_DioWriteBit for port bit and state Table 5 45 DRV_DioWriteBit Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range 5 InvalidInputParam if bit number is greater than 7 Note The previous state of the digital port should be stored with the configuration data 186 Advantech DLL Drivers User s Manual DRV_DioGetCurrentDOByte status DRV_DioGetCurrentDOByte DriverHandle lpDioGetCurrentDOByte Purpose Returns digital input data from the specified digital I O port The byte is specified by port number which is from 0 to the maximum byte of the device s digital output For example PCL 722 has up to 18 ports digital output The port number of the board is from 0 to 17 Parameters PESA Input long HR assigned by DRV_DeviceOpen IpDioGetCurrentDOByte Input Output long pointer to default the storage address PT_DioGetCurrentDOByte for port and value Table 5 46 DRV_DioGetCurrentDOByte Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the fun
96. cal Compact or Custom Click the Next button to advance Figure 1 8 Select the Kind of Installation You Want to Perform 9 The installation program will create a shortcut on your Windows Start menu The default is Advantech Driver for 95 and 98 or Advantech Driver for NT If you want to change the name of the shortcut type your selection in the text box Click the Next button to advance 8 Advantech DLL Drivers User s Manual Figure 1 9 Select the Program Folder for the Program Shortcut 10 The installation program will copy the files to your computer A A fer indirr Pat Figure 1 10 Copying the Files 11 The Advantech DLL Drivers are now installed to your computer Click the Finish button to close the installation program Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Driver 9 Lena ben ir ri rd Ae miesies Eee rr eerie AA Figure 1 11 Installation Complete 12 At the end of the installation you will be prompted to install the Adobe Acrobat Reader This software is required to view the online version of the manual Click the Yes button in the message box if you do not yet have this software Note You can always get the latest version of the Adobe Acrobat Reader by going to Abobe s web site at www adobe com 13 You can see the shortcuts that were added to your Windows Start menu by choosing Programs Advantech Driver for 95 and 98 or Advantech Driver for NT Figure 1 12 Advantech D
97. cation failure 3 ConfigDataLost if retrieving configuration data failure 4 CreateFileFailed if low level driver has an opening failure Note 1 All subsequent functions perform the desired I O operations based on configuration data retrieved by the DriverHandle parameter 2 After the I O operations user has to call DRV_DeviceClose to release the memory allocated by DRV_DeviceOpen Chapter 5 Functions Reference 157 DRV_DeviceClose status DRV_DeviceClose DriverHandle Purpose Releases the storage allocated by DRV_DeviceOpen Parameters e in long pointer default assigned by DRV_DriverOpen Table 5 19 DRV_DeviceClose Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL or DriverHandle is not found 158 Advantech DLL Drivers User s Manual DRV_DeviceGetFeatures status DRV_DeviceGetFeatures DriverHandle lpDevFeatures Purpose Retrieves the device specific features and returns them in buffer Parameters Name Direction Type Range Description DriverHandle Input long pointer default assigned by DRV_DriverOpen LpDevFeatures Output long pointer to default the storage address of PT_DEVFEATURES the device features and size of device features Table 5 20 DRV_DeviceGetFeatures Parameter Table Parameter Details IpDevFeatures is the storage address of the device s features and size of device features The storage layout refers to DRIVER H Return
98. chdogCheck DRV_FAOIntStart DRV_FAODmasStart DRV_FAOLoad DRV_FAOCheck DRV_FAOStop DRV_EnableEvent DRV_CheckEvent DRV_AllocateDmaBuffer DRV_FreeDmaBuffer DRV_ClearOverrun DRV_TimerCountSetting Table 4 3 High Speed Analog Input Analog Output Event and Other Function Calls 74 Advantech DLL Drivers User s Manual 4 2 Device Functions 4 2 1 DLL Driver Programming Foundation The following figure describes the common call flow of the DLL Driver Device Number y DRV_DeviceOpen Device Handle y Function Group Device Handle Y DRV_DeviceClose v Figure 4 2 DLL Driver Common Call Flow Device Number Type Unsigned Long Size 4 bytes The Device Number specifies the device that you want to perform the T O operations The Device Number is initially defined through configuration using the Device Installation Utility DEVINST EXE The following is the configuration dialog box of the Device Installa tion Utility It lists the installed devices Chapter 4 Function Overview 75 76 Figure 4 3 Device Installation Utility Configuration Window For the entry of the device 000 Advantech DEMO I O 1H the Device Number is equal to 000 You can use assign the Device Number to the DRV_DeviceOpen function directly Alternatively you can call DRV_SelectDevice function to generate a dialog box for selecting the desired device that is Device Number DRV_DeviceOpen an
99. ck of the digital filter time period for latching and cascade mode This function only supports PCL 833 Parameters A Uan A E aw assigned by DRV_DeviceOpen Esas O PE AM pointer to default the storage address for PT_QCounterConfnigSys SysClock LatchPeriod and CascadeMode Table 5 59 DRV_QcounterConfigSys Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 202 Advantech DLL Drivers User s Manual DRV_QCounterStart status DRV_QCounterStart DriverHandle lpQCounterStart Purpose Configures the specified counter for an event counting operation and starts the counter This function only supports PCL 833 Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpQCounterStart Input Output long pointer to default the storage address for PT_QCounterStart counter and InputMode Table 5 60 DRV_QcounterStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Chapter 5 Functions Reference 203 DRV_QCounterRead status DRV_QCounterRead DriverHandle lpQCounterRead Purpose Reads the current counter total without disturbing the counting process and returns
100. coocncncnnnnnnnnnonononanananannnno nono iinei 261 Preface xiii xiv PT AICODIZ simi pad 262 PT_AIGECON S cuotas de ieee ites estas rial cd aeai 263 PT_AlBiary nadia adi idad darle dake 264 PP OATS cal iodo lit asta a a aae eoe 265 PT AlVoltage lis citas ibi a i 266 PT Al VoltageIn EX pv csc tite eet inca e 267 PP MAIC Oni D ie vc srcctciscaessttsesbouesicebslsiaehchtliees a eiee iaai 268 PT lt MAITB mary ln cuota irene 269 PT MATVoltageln cualidad 270 PT_MATVoltageInEXp ereinen ninna naiiai 271 PF TCM Redd a id daa 272 PT_AOCODTIS tata E A 273 PT AOBinaryOut eorne orere e E E AESA 274 PT AQ Voltage QUt seinieni ae 275 PTA O Scale nasa ii id 276 PLA OC urremtOut eases ii aa aii 277 PT_DioSetPortMode neinir ian ea a nono na canario nn 278 PT Di GetConfig cecilia dali 279 PT_DioReadPortByt8 eerren o oii ie 281 PT DioWtitePortBy tensen nanennni e a 282 PT DioReadBltiniii dci 283 PT DioWiteBitint a a 284 PT_DioGetCurrentDOByte ccooconnccnnoconoccnoncnnncnnncanncnnncnancnn noo 285 PT_DioGetCurrentDOBit c cccnnnnnnnnnnanananannanananananananancn nono nonona 286 PT _WritePortBytes oi ie aa ek 287 PT_WritePort Word occcccinincnnnnncnnncncnnanananananananananana nono nananano 288 PE ReadPortByte metida ri 289 PT ReadPOrtWord veto tit dades 290 PT_CounterEventStart sonnn e 291 PT_CounterEventRead anna n n 292 PT Co nt rFregS tart 1 scc sssccesebecsebotescbestoaseastacedsnsoluassbatscess 293 PT _ CounterPreqRead 2 s0 5 s
101. counter setting This initialization will take about 2 external triggers cycle time to finish If DRV_CounterEventRead function is called before initialization is finished then the program will get an incorrect value You thus have to delay 2 external triggers cycle time in the program before calling the DRV_CounterEventRead function to make sure the return value is correct The delay time is dependent on the time of the external trigger Chapter 4 Function Overview 109 110 Examples Directory Advantech Adsapi Examples Console counter Advantech Adsapi Examples V B counter Advantech Adsapi Examples Delphi counter Advantech Adsapi Examples VC counter Function Description Demo program for counter function 4 6 1 2 Interrupt Triggering The counter operation with interrupt triggering allows you to monitor the background status of the counter operation without polling When the counter reaches a specified count value it will acknowledge the driver through a hardware interrupt These functions are only support ed in the PCI 1750 1751 Advantech DLL Drivers User s Manual Call Flow DRV_TimeCountSetting DRV_EnableEvent DRV_CheckEvent Repeat DRV_EnableEvent Figure 4 18 Interrupt Triggering Function Call Flow The DRV_TimerCountSetting function configures the number of interrupt counts The DRV_EnableEvent function starts the counter operation When it is running
102. couple type 122 Advantech DLL Drivers User s Manual Examples Directory Advantech Adsapi Examples Console thermo Advantech Adsapi Examples V B thermo Advantech Adsapi Examples Delphi thermo Advantech Adsapi Examples VC thermo Function Description Demo program for temperature measurement function Chapter 4 Function Overview 123 4 8 Alarm Function Group The alarm functions support Advantech ADAM modules for alarm features When analog input signal exceeds the range between the pre defined high or low limits it will generate an alarm Call Flow The call flow of alarm function is shown below y DRV_AlarmConfig y DRV_AlarmEnable y DRV_AlarmCheck Another Check v DRV_AlarmReset Figure 4 24 Alarm Function Call Flow 124 Advantech DLL Drivers User s Manual 4 9 The DRV_AlarmConfig function configures the high and low limits for the alarm The DRV_AlarmEnable function starts the alarm monitoring While it is running you can use DRV_AlarmCheck function to check if the alarm occurs repeatedly When it is complete you can call DRV_AlarmReset function to stop the alarm operation Examples Directory Advantech Adsapi Examples VB alarm Advantech Adsapi Examples Delphi alarm Advantech Adsapi Examples VC alarm Function Description Demo program for alarm function Port Function Group The port function group writes or reads b
103. ction is not supported for this device 4 InvalidChannel if the port number is out of range Chapter 5 Functions Reference 187 DRV_DioGetCurrentDOBit status DRV_DioGetCurrentDOBit DriverHandle lpDioGetCurrentDOBit Purpose Returns the bit data of digital input from the specified digital I O port The byte is specified by port number which is from 0 to the maximum byte of the device s digital output For example PCL 722 has up to 18 ports digital output The port number of the board is from 0 to 17 Parameters DriverHandle Input long default assigned by DRV_DeviceOpen IpDioGetCurrentDOBit Input Output long pointer to default the storage address for PT_DioGetCurrentDOBit port bit and state Table 5 47 DRV_DioGetCurrentDOBit Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range 5 InvalidInputParam if bit number is greater than 7 188 Advantech DLL Drivers User s Manual DRV_WritePortByte status DRV_WritePortByte DriverHandle lpWritePortByte Purpose Writes an 8 bit data to the specified I O port The port address is an I O port address on the PC Parameters Name Direction PRES ve SM default assigned by DRV_DeviceOpen pee aes ae pointer to default the storage address PT_WritePortByte for port and ByteData Tab
104. d DRV_DeviceClose Functions DRV_DeviceOpen initializes the device specified by Device Number This function must be called before any other methods that performs I O operations DRV_DeviceClose is the counterpart function of the DRV_DeviceOpen function to close the device Device Handle Type Long Size 4 bytes Device Handle is set and returned by DRV_DeviceOpen The subse quent function calls use Device Handle to represent the desired device instead of Device Number Error Code Type Unsigned Long Size 4 bytes and DRV_GetErrorMessage Each driver function returns an error code that indicates whether the function was performed successfully When a function returns a code that is non zero it means that the function failed to perform You can pass the error code to the DRV_GetErrorMessage function to retrieve its error message Advantech DLL Drivers User s Manual 4 2 2 Other Device Functions DRV_DeviceGetFeatures This function accepts a storage address as a function argument and then returns the device specific features of the location DRV_SelectDevice This function shows the device list tree dialog box to select the device DRV_DeviceGetList Returns the number and type of installed devices not including devices attached to COM ports or CAN DRV_DeviceGetNumOfList Returns the number of installed devices DRV_DeviceGetSubList Returns a list of the installed devices attached to a specified COM port or C
105. d an application using DLL driver from scratch The example makes use of the Analog Input Function Group to read one analog value from an analog input channel A Windows console program Visual Basic and Delphi are used to build the application and demonstrate the step by step procedure The source code for these programs is also provided For information about using other function groups or other develop ment tools please refer to Chapter 2 Creating Windows 95 NT Application with DLL Driver and Chapter 4 Function Overview The source code is located in the advantech adsapi examples tutorial directory on the CD ROM disc The sample program reads an analog input channel from a virtual device and displays the result on the screen The Advantech DLL driver supports the virtual device named DEMO BOARD whose first channel generates a simulated sine wave By following this example you will get an overall view about how to program using the DLL driver This chapter assumes that you are familiar with the basic concepts of using Visual Basic Delphi and Visual C DLL Driver Tutorial for Win32 Console Program 46 Step 1 Add Demo Board With DEVINST EXE 1 Go into the Start menu and click on the Device Installation icon in the Advantech drivers folder Advantech DLL Drivers User s Manual Figure 3 1 Starting the Device Installation Utility 2 The Device Installation Utility will launch as below Figure 3 2 Device Installat
106. d counter for pulse output and starts the counter Parameters Direction Type Range Description DriverHandle long default assigned by DRV_DeviceOpen IpCounterPulseStart long pointer to default the storage address PT_CounterPulseStart for counter period UpCycle and GateMode Table 5 56 DRV_CounterPulseStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Operations 1 The programming method depends on the counter timer chip on the board There are two kinds of chips that are used in DASCards Intel 8254 and AMD Am9513A 2 For the AMD Am9513A chip counter channels 0 9 can all function as an arbitrary duty cycle pulse generator You should select an on board frequency F1 F5 source that is closest to the desired output frequency for pulse output The pulse waveform will then be generated on the output pin of the counter used If hardware gating in which the counter may be started by a separate external hardware input is desired choose a gating type and use an external device to trigger the gate input of the counter The Intel 8254 chip always generates a square wave Hence it does not use the UpCycle Chapter 5 Functions Reference 199 DRV_CounterReset status DRV_CounterReset DriverHandle counter Purpose Turns off th
107. d in GDEVCFG INI The DEVCONFIG_COM data structure refers to DRIVER H 224 Advantech DLL Drivers User s Manual DRV_FAIIntStart status DRV_FAIIntStart DriverHandle lpFAIIntStart Purpose Initiates an asynchronous single channel data acquisition operation with Interrupt and stores its input in an array Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen IpFAlIntStart Input Output long pointer to default the storage address PT_FAlintStart for TrigSrc SampleRate chan gain buffer count cyclic IntrCount Table 5 78 DRV_FAlIntStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if buffer NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidGain if gain code is incorrect 6 InvalidChannel if chan is out of range 7 InvalidCountNumber have these conditions count is zero IntrCount gt count or count is not even 8 IllegalSpeed if SampleRate is out of range 9 InvalidEventCount if EventCount is not IntrCount multiple 10 ChanConflict if interrupt channel is conflict 11 OpenEventFailed if event name opens failure 12 InterruptProcessFailed if interrupt proces is failure 13 KeInsufficientResources if resource is conflict with another driver 14 KeConInterruptFailure if connects interrupt failure Chapter 5 Functions Reference 225 DRV_FAIDm
108. ddma diint dipattn cntint Function Description Demo program for event function Advantech DLL Drivers User s Manual CHAPTER Functions Reference 5 1 Function Support in Advantech Products N File Name ADSAPI32 DLL Uniform driver for Genie or Application 32 BIT E r F O i 1 2 ADS818 D ADS711 DLL Support PCL 711 711B and PCLD 779 788 789D 889 D ADS812 D ADS813 D ADS816 D Support PCL 718 818 818L 818H 818HD 818HG and PCLD 779 788 789D 889 Support PCL 812 and PCLD 779 788 789D 889 PCL 813B 813 PCL 816 814B and PCLD 779 788 789D 889 Suppor Suppor L Support PCL 1800 and PCLD 779 788 789D 889 IN au ojo 2 rc 1 ADS726 ADSDIO ADS4000 DL Support PCL 726 727 728 L Support ADAM 4011 4012 4013 4014D 4017 4018 4021 4050 4052 4060 4080D 4018M 4530 4521 and PCR 420 aloja Oo mp a R ADS833 ADSMIC DL ADSPCM D ADS5000 D is r F Support PCL 833 Support ADAM 5017 5018 5024 5051 5056 5060 for RS 485 protocol LL LL 1 ADSDEMO DEVINST E DLL Demo board 5 16 ADSCOMM DLL Support RS 232 function 17 XE Device installation utility 32 BIT DRIVER H Function declaration constant definition for Microsoft C and Borland C DRIVER BAS Function declaration constant definition for Microsoft Visual Basic 19 20 DRIVER PAS Function declaration constant definition for_Borland Delphi A
109. dle 1pFAICheckWatchdog Purpose Checks if the current data acquisition with watchdog is triggered Parameters Direction Type Range Description DriverHandle Input long assigned by DRV_DeviceOpen LpFAlWatchdog Input Output long pointer to the storage address Check PT_FAlWatchdo for gCheck DataType ActiveBuf triggered TrigChan Trigindex TrigData Table 5 90 DRV_FAICheckWatchdog Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 238 Advantech DLL Drivers User s Manual DRV_AllocateDMABuffer status DRV_AllocateDMABuffer DriverHandle lpAllocateDMABuf fer Purpose Allocates buffer for DMA data acquisition Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpAllocateDMA Input Output long pointer to default the storage address Buffer PT_AllocateDM for CyclicMode ABuffer RequestBufSize ActualBufSize Buffer Table 5 91 DRV_AllocateDMABuffer Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 KelnsufficientResources if kernel mode buffer resources are not enough 4 KeBuferSizeTooSmall if request buffer size is less than PAGE_SIZE 4K 5 KeAllocCommBufFailure if kernel mode buffer allocates failure Please you reduce the buffer size request or re boot the system Chapter 5 Functions Reference 239 DRV_FreeDMABuffer
110. dvantech Adsapi Examples VC diint Function Description Demo program for digital input function with interrupt triggering 4 5 1 3 Pattern Matched Status Change Counter Filter The digital input functions with pattern matched status change counter filter triggering allow you to monitor the status of the digital input lines When one of the conditions is matched it will acknowledge the driver through a hardware interrupt You do not have to periodically poll the digital input line These functions are only supported in PCI 1753 1760 Advantech DLL Drivers User s Manual Call Flow DRV_EnableEventEx DRV_CheckEvent Repeat y DRV_FDITransfer Repeat y DRV_EnableEventEx Figure 4 15 Pattern Matched Status Change Counter Filter Function Call Flow The DRV_EnableEventEx function enables and starts the monitoring of the pattern match status change filter counter operation You can then use the DRV_CheckEvent function to check the background status The DRV_CheckEvent function returns the interrupt event type when one of the conditions is matched You can also use the DRV_FDITransfer function to retrieve the value of the input lines Finally you use the DRV_EnableEventEx function to disable and stop the operation Chapter 4 Function Overview 105 106 Examples Directory Advantech Adsapi Examples Console dipattn Advantech Adsapi Exam
111. e PT_DioGetCurrentDOByte FAR LPT_DioGetCurrentDOByte PT_DioGetCurrentDOByte is used by DRV_DioGetCurrentDOByte function Member Description Direction Type Range Description number Name E EA unsigned short 0 n n depends on hardware AAA long pointer to default 8 bit digital data unsigned short read from the specified port Table 5 134 PT_DioGetCurrentDOByte Member Description Chapter 5 Functions Reference 285 PT_DioGetCurrentDOBit typedef struct tagPT_DioGetCurrentDOBit 1 USHORT port USHORT bit USHORT far state PT_DioGetCurrentDOBit FAR LPT_DioGetCurrentDOBit PT_DioGetCurrentDOBit is used by DRV_DioGetCurrentDOBit function Member Description Name Direction Type Range Description port Input unsigned short 0 n n depends the digital port on hardware number bit Imput unsigned short fo7 the bit number Output long pointer to Oor1 bit data read unsigned short from the specified port Table 5 135 PT_DioGetCurrentDOBit Member Description 286 Advantech DLL Drivers User s Manual PT_WritePortByte typedef struct tagPT_WritePortByte 1 USHORT port USHORT ByteData PT_WritePortByte FAR LPT_WritePortByte PT_WritePortByte is used by DRV_WritePortByte function Member Description Name Direction Type Description pon nt unsigned short I O port address ByteData 8 bit output data Table 5 136 PT_WritePortByte Member Description Re
112. e trigger condition for the scan channel LevelList long pointer to TRIGLEVEL array with NumChans entries depends on input range on hardware level array to specify the low and high limit for scan channels Table 5 163 PT_FAlWatchdogConfig Member Description 314 Advantech DLL Drivers User s Manual PT_FAlIntWatchdogStart typedef struct tagPT_FAIIntWatchdogStart 1 USHORT TrigSrc DWORD SampleRate USHORT far buffer ULONG BufferSize ULONG count USHORT eyelic USHORT IntrCount PT_FAIIntWatchdogStart FAR LPT_FAIIntWatchdogStart PT_FAIIntWatchdogStart is used by DRV_FAIIntWatchdogStart function Member Description Name Direction Type Description TrigSrc Input unsigned short triggering source external 1 internal 0 SampleRate floating point depends on the sampling rate in pacer on second hardware long pointer to depends on I O data buffer A unsigned short register format assigned by array on hardware AllocateDMABu ffer or user BufferSize unsigned long buffer size count unsigned short number of points in the source buffer to be copied to the data buffer cyclic unsigned short 0 1 cyclic mode cyclic 1 non cyclic 0 IntrCount unsigned short depends on count to interrupt hardware Table 5 164 PT_FAlIntWatchdogStart Member Description Chapter 5 Functions Reference 315 PT_FAIDmaWathchdogStart typedef struct tagPT_FAIDmaWatchdogStart 1
113. e specified counter operation This function supports boards with the timer counter chip i e Intel 8254 or AMD Am9513A and PCL 833 Parameters ae rection _ long default assigned by DRV_DeviceOpen counter Input tong default counterchammel_ Table 5 57 DRV_CounterReset Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range 200 Advantech DLL Drivers User s Manual DRV_QCounterConfig status DRV_QCounterConfig DriverHandle lpQCounterConfig Purpose Configures the specified counter for an event counting operation This function only supports PCL 833 Parameters Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpQCounterConfig Input Output long pointer to default the storage address for PT_QCounterConfig counter LatchSrc LatchOverflow ResetOnLatch and ResetValue Table 5 58 DRV_QcounterConfig Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Chapter 5 Functions Reference 201 DRV_QCounterConfigSys status DRV_QCounterConfigSys DriverHandle lpQCounterConfigSys Purpose Configures system clo
114. eOut y DRV_WriteSyncAO Figure 4 10 Multiple Channel Synchronous Output Call Flow The DRV_EnableSyncAO function enables the synchronized output operation You can then call the DRV_AOVoltageOut function repeatedly to set the voltage value for each output channel Finally write the output values to all channels synchronously by using DRV_WriteSyncAO function Besides the DRV_AOVoltageOut function you can use DRV_AOCurrentOut function for current output Chapter 4 Function Overview 95 96 Examples Directory Advantech Adsapi Examples Console dasync Advantech Adsapi Examples VB dasync Advantech Adsapi Examples Delphi dasync Advantech Adsapi Examples VC dasyncc Advantech Adsapi Examples VC dasyncv Function Description Demo program for synchronous analog output function 4 4 3 Waveform Analog Output The analog output function group provides two kinds of waveform data ouput They are interrupt triggering and DMA triggering The waveform analog output uses the on board pacer to trigger the output operation and acknowledge the driver through a hardware interrupt Background Status For analog output a user needs to check the status of the operation and load new data for cyclic mode The user may frequently call the DRV_FAOCheck function to check the status and DRV_FAOLoad to load the new data The driver provides another method to actively inform the user s application The user calls DRV_Ena
115. eValue KeFileNotFound Description Error Message An error occured while starting the device The device has not been created 102 103 104 105 KelnvalidHandle KeTooManyCmds KelnvalidParameter KeNoAccess The handle passed to the function is not a valid The logic commands have created an apparent endless loop Passed to the driver contains an invalid parameter Attempts to access a port which has not been defined in DEVINST 106 KeUnsuccessful The operation was not successful 107 KeConInterruptFailure The driver connects interrupt failure on l O XH 108 KeCreateNoteFailure The driver creates notification event failure On 1 0 XH 109 KelnsufficientResources The system resource is insufficient Onl O XH 110 KeHalGetAdapterFailure KeOpenEventFailure An adapter object could not be created On I O XH The driver opens notification event failure On O XH KeAllocCommBufFailure Allocate DMA buffer failure On l O XH 334 KeAllocMdIFailure KeBufferSizeTooSmall Allocate MDL for DMA buffer failure On I O XH The buffer of requisition must be bigger that PAGE_SIZE On I O XH Table A 3 Status Code Summary Advantech DLL Drivers User s Manual Error Error ID Description Error Message Code 201 DNinitFailed DeviceNet Initialization Failed 202 DNSendMsgFailed Send Message Failed On Port d MACID XH 203 DNRunOutOfMsgID Run Out of Message ID DN
116. ed by these driver functions including the name and description Each driver function returns a status code that indicates whether the function was performed successfully When a function returns a code that is not zero it means that the function performed failed You can pass the error code to DRV_GetErrorMessage function to return its error message The status code is 32 bit Its format is described in Figure A 1 Status code 32 bit Status code 32 bit Bit 31 28 Bit 27 16 Bit 15 0 serial port used base address occupied Error code Table A 1 Status Code Format 332 Advantech DLL Drivers User s Manual A summary of the status codes is listed in Table A 2 Description Error Message MemoryAllocateFailed Not Enough Memory ConfigDataLost Configuration Data Lost InvalidDeviceHanale Invalid Device Handle Section Not Supported On I O XH 7 Invalid Channel On 1 0 XH Invalid Gain Code On 1 O XH DataNotReady Data Not Ready On 1 O XH 10 Invalid Input Parameter On l O XH NoExpansionBoardConfig No Expansion Board Configuration in Registry Configuration File On 1 O XH 12 InvalidAnalogOutValue Invalid Analog Output Value On I O XH 13 ConfigloPortFailed Configure DIO Port Failure On l O XH 14 15 CommTransmitFailed Unable to Transmit to COM d Address XH 16 CommReadFailed Unable to Receive from COM d Address XH 17 CommReceiveFailed Invalid Data Received from COM d Address XH Configure Communication Port
117. ed if the function is not supported for this device 4 InvalidChannel if the port number is out of range Note The previous state of the digital port should be stored with the configuration data 184 Advantech DLL Drivers User s Manual DRV_DioReadBit status DRV_DioReadBit DriverHandle lpDioReadBit Purpose Returns the bit state of digital input from the specified digital I O port The byte is specified by port number which is from 0 to the maximum byte of the device s digital output For example PCL 722 has up to 18 ports digital output The port number of the board is from 0 to 17 Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpDioReadBit Input Output long pointer to default the storage address PT_DioReadBit for port bit and state Table 5 44 DRV_DioReadBit Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range 5 InvalidInputParam if bit number is greater than 7 Chapter 5 Functions Reference 185 DRV_DioWriteBit status DRV_DioWriteBit DriverHandle lpDioWriteBit Purpose Writes digital output data to the specified digital port The byte is specified by the port number which is from 0 to the maximum byte of the device s digital output For example PCL 730 has 4
118. elphi program code You can find lots of example programs and related source code included on the DLL Drivers CD ROM disc After designing the program code click the Run button to test or build the application execution file The DLL driver for the Windows 95 98 NT function library includes a DLL driver and a Windows 95 98 NT kernel device driver SYS files Most of the functionality is built into the kernel mode device driver The DLL provides a portable programming interface for DA amp C applications The DLL driver for Windows 95 98 NT ADSAPI32 DLL is located in your Windows 95 98 NT System or System32 directories The kernel device driver ADSIO SYS can be found in your Windows 95 98 NT Drivers directory Advantech DLL Drivers User s Manual In addition to the system files the DLL Driver for Windows 95 98 NT is shipped with other files to help you develop DA amp C applications These files are in the directory you select when installing the DLL Driver for Windows 95 98 NT Note Driver pas is an include file that contains all DLL function prototypes You should include this file in your source files when you build your DA amp C applica tions Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 41 2 5 Using Borland C or Borland C Builder To use the DA amp C functions you must use the DA amp C DLL Follow this procedure 1 Create a new project using the Class library Do not choose OWL 1f yo
119. emory allocation functions and requires you to allocate all memory through the Windows memory manager In most cases you should use these functions rather than the memory allocation functions normally used by a specific language Please note that the buffer allocated for handling interrupt function can exceed 64 KB but the buffer allocated for DMA functions cannot be less than 4 KB and cannot exceed 64 KB 2 6 2 String Passing When DLLs for Windows routine drivers call for a string that is passed as a parameter the routines expect a pointer to a null terminat ed string Some languages require special string handling to support this type 2 6 3 Parameter Passing You can pass parameters of a procedure or function by value or by reference Different languages have different default settings You must pass certain variables by value or by reference to each DLL for Windows functions Notice The DRV_GetAddress function is for Visual Basic only In VC or Delphi users can get a pointer or address of a variable However in Visual Basic there is no standard function to get the memory address of a variable The DLL driver requires an address as a parameter when calling most functions Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 43 44 Advantech DLL Drivers User s Manual e d31dvVH9 Tutorial 3 1 DLL Driver Introductory Tutorial This chapter provides an example to demonstrate how to buil
120. er 5 Functions Reference 279 Note This structure just supports the board which emulates the digital input output operation in 8255 Mode 0 for examples PCL 722 724 731 PCL 814 DIO 1 The PortArray can be set to below values Input mode 0 Output mode 1 Input Output mode 2 Low nibble PCO PC3 as input mode and High nibble PC4 PC7 as output mode 3 5 Low nibble PCO PC3 as output mode and High nibble PC4 PC7 as input mode 4 RW N Ra 280 Advantech DLL Drivers User s Manual PT_DioReadPortByte typedef struct tagPT_DioReadPortByte USHORT port USHORT far value PT_DioReadPortByte FAR LPT_DioReadPortByte PT_DioReadPortByte is used by DRV_DioReadPortByte function Member Description heme Direction Type Range Description Input unsigned short 0 n n depends the digital port on hardware number Output long pointer to default 8 bit digital data unsigned short read from the specified port Table 5 130 PT_DioReadPortByte Member Description Chapter 5 Functions Reference 281 PT_DioWritePortByte typedef struct tagPT_DioWritePortByte USHORT port USHORT mask USHORT state PT_DioWritePortByte FAR LPT_DioWritePortByte PT_DioWritePortByte is used by DRV_DioWritePortByte function Member Description Direction Type Range Description Input unsigned short unsigned short unsigned short 0 n n depends on hardware the digital po
121. er Table Return 1 SUCCESS if successful 2 InvalidDeviceHandle if DeviceHandle is NULL Note This function calls Windows APIs EscapeCommF unction and CloseComm to disconnect the connection and close the communica tion port 218 Advantech DLL Drivers User s Manual COMGetConfig status COMGetConfig DeviceNum buffer Purpose Retrieves the communication port settings configured by the device installation utility Parameters Name Direction Type Description DeviceNum Input unsigned long device number buffer Output long pointer to data buffer to store DEVCONFIG_COM the communication data structure port settings Table 5 72 COMGetConfig Parameter Table Return 1 SUCCESS if successful 2 InvalidDeviceHandle if DeviceHandle NULL Note The communication port settings are stored in GDEVCFG INI The DEVCONFIG_COM data structure refers to DRIVER H Chapter 5 Functions Reference 219 COMSetConfig status COMSetConfig DeviceHandle buffer Purpose Sets the communication port configuration Parameters Name Direction Type Description DeviceHandle Input long assigned by DeviceOpen buffer Output long pointer to data buffer to store the DEVCONFIG_COM data communication port structure settings Table 5 73 COMSetConfig Parameter Table Return 1 SUCCESS if successful 2 InvalidDeviceHandle if DeviceHandle NULL Note The communication port settings are stored in G
122. er or address of a variable However in Visual Basic there is no standard function to get the memory address of a variable The DLL driver requires an address as a parameter when calling most functions Step 3 Test Your Program 1 Press F5 to run the program Then press the Read button in your sample application The data will appear as below Arabakoa Figure 3 16 Testing the Sample Program Chapter 3 Tutorial 61 3 4 DLL Driver Tutorial for Delphi Applications Step 1 Add Demo Board With DEVINST EXE 1 The same as step 1 for making a Win32 console application Step 2 Write Your Application 1 Go into the Start menu and click on the Delphi 4 icon in the Borland Delphi 4 folder Figure 3 17 Starting Delphi 2 Click on the Project Manager in the View menu Add the declara tion file Driver pas file by clicking the Add to Project button in the Project menu The Driver pas file is located in Advantech Adsapi Include directory Name the adsoft pas unit file for Form1 62 Advantech DLL Drivers User s Manual Figure 3 18 Delphi Project Manager 3 Design your form place a Label control on the Form1 and enter Analog Input as its Caption field Then place an Edit control on the Form1 Switch to the Property Window and enter txtAI Value as its Name property At last place a Button control on the form Enter cmdRead as its Name property and enter Read as the Caption property Your form should
123. er to default the storage ut AOCurrentOut address for usEventType and OutputValue Table 5 39 DRV_AOCurrentOut Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 180 Advantech DLL Drivers User s Manual DRV_DioGetConfig status DRV_DioGetConfig DriverHandle lpDioGetConfig Purpose Retrieves digital input output configuration data and returns it in PortArray Parameters Name Direction DriverHandle Input long default assigned by DRV_DeviceOpen IpDioGetConfig Input Output long pointer to default the storage PT_DioGetCon address for fig PortArray and NumOfPorts Table 5 40 DRV_DioGetConfig Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL Chapter 5 Functions Reference 181 DRV_DioSetPortMode status DRV_DioSetPortMode DriverHandle lpDioSetPortMode Purpose Configures the specified port for input or output This function only supports PCL 722 724 731 Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpDioSetPortMode Input Output long pointer to default the storage PT_DioSetPort address for port Mode and dir Table 5 41 DRV_DioSetPortMode Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if this function is not supported for this device Note 1 By
124. ern match pre setting value Table 5 177 PT_DIPattern Member Description 328 Advantech DLL Drivers User s Manual PT_DiStatus typedef struct tagPT_Status USHORT usEventType USHORT usEventEnable USHORT usCount USHORT usEnable USHORT usRisingedge USHORT usFallingedge PT_DIStatus FAR LPT_DIStatus PT_DIStatus is used by DRV_EnableEventEx function Member Description usEventType Input unsigned short default usEventEnable Input unsigned short default status event enable bit usCount Input unsigned short default usEnable Input unsigned short default status change enable data usRisingedge unsigned short default record Rising edge trigger type usFallingedge unsigned short default record Falling edge trigger type Table 5 178 PT_DIStatus Member Description Chapter 5 Functions Reference 329 PT_FDITransfer typedef struct tagPT_FDITransfer USHORT usEventType ULONG far ulRetData PT_FDITransfer FAR LPT_FDITransfer PT_FDITransfer is used by DRV_EnableEventEx function Member Description Name Direction Type Range Description usEventType Unsigned short _ default event type for DI transfer ulRetData Output Unsigned long default transfer data pointer Table 5 179 PT_FDITransfer Member Description 330 Advantech DLL Drivers User s Manual APPENDIX DLL Driver Error Codes This section lists the status codes return
125. ernal and 1 for external 4 3 1 Software Triggering These functions trigger the data conversion by software The driver provides two kinds of functions One is for single point reading the other one is for multiple channel reading 4 3 1 1 Single Point Reading If you want to sample multiple data periodically by the functions you can create a software timer to call the functions periodically Advantech DLL Drivers User s Manual Call Flow The function call flow is shown below Channel Gain TriggerMode DRV_AIConfig DRV_AlVoltageln 4 one reading No Exit another reading Figure 4 4 Single Point Reading Call Flow Diagram DRV_AIConfig function configures the input range for the specified channel If the input range doesn t change at runtime you just call it once at the beginning Then use the DRV_ATVoltageIn function to get voltage data repeatedly The DLL drivers also provides a binary data reading function DRV_AJBinaryIn In contrast with the DRV_AIVoltageIn function it does not convert binary data into voltage data You can use the DRV_AIScale function to convert it Examples Directory Advantech Adsapi Examples Console adsoft Advantech Adsapi Examples VB adsoft Advantech Adsapi Examples Delphi adsoft Advantech Adsapi Examples V Cladsoft Chapter 4 Function Overview 79 80 Function Description Demo program for analog input function with software triggering 4 3 1 2
126. eter Table ooooooccnnoccccccccnoooooncncononnccnncnanono 172 Table 5 32 DRV_FDITransfer Parameter Table cccceeceeeeeeeeeeeeeeeeeeseneeeeeneeeeeae 173 Table 5 33 DRV_AOConfig Parameter Table ccccceccceseeeseceeeeeeeseeeeeeeenseseseenaes 174 Table 5 34 DRV_AOVoltageOut Parameter Table cccccceeseceseceseeeeeeseeeteeeeeeeees 175 Table 5 35 DRV_AOScale Parameter Table ccccccssccsssccesssecesseecesseeeesseeeeseeeeees 176 Table 5 36 DRV_AOBinaryOut Parameter Table cccceceeseeseeeeeeseeeeeeeeeeeeeeeenees 177 Table 5 37 DRV_EnableSyncAO Parameter Table cc cccsceceeeeeeeeeeeeeeeseeeeeeees 178 Table 5 38 DRV_WriteSyncAO Parameter Table c cccccceceeseeeeeeeeeeeeeeeeeeeeaeeeaes 179 Preface xix Table 5 39 Table 5 40 Table 5 41 Table 5 42 Table 5 43 Table 5 44 Table 5 45 Table 5 46 Table 5 47 Table 5 48 Table 5 49 Table 5 50 Table 5 51 Table 5 52 Table 5 53 Table 5 54 Table 5 55 Table 5 56 Table 5 57 Table 5 58 Table 5 59 Table 5 60 Table 5 61 Table 5 62 Table 5 63 Table 5 64 Table 5 65 Table 5 66 Table 5 67 Table 5 68 Table 5 69 Table 5 70 Table 5 71 Table 5 72 Table 5 73 Table 5 74 Table 5 75 Table 5 76 Table 5 77 Table 5 78 Table 5 79 Table 5 80 Table 5 81 Table 5 82 Table 5 83 Table 5 84 Table 5 85 Table 5 86 DRV_AOCurrentOut Parameter Table DRV_DioGetConfig
127. eturns to the first half buffer and overwrites the old data Users can now copy the second half of the circular buffer to the transfer buffer The data in the transfer buffer is again available for use by the user s application The process can be repeated endlessly to provide a continuous stream of data to user applications The double buffered coordination scheme is not flawless An applica tion might experience two possible problems with double buffered input The first is the possibility of the data acquisition board overwrit ing data before the user copies it to the transfer buffer In this situation the driver returns an overrun warning Subsequent transfers will not Advantech DLL Drivers User s Manual return the warning as long as they keep pace with the data acquisition board The second potential problem occurs when an input board overwrites data that the user is simultaneously copying to the transfer buffer The driver will return an overrun warning Background Status For data acquisition the user needs to check the status of the operation and retrieve the data for avoiding the data overrun Users may call the DRV_AICheck function frequently to check the status and DRV_AITransfer to copy the data The driver provides another method to actively inform the user s application User calls DRV_EnableEvent with enabling message sending The driver will then send messages when the hardware interrupt occurs Please refer to the Even
128. fault the storage address PT_EnableEvent for EventType Enabled Count Table 5 99 DRV_EnableEvent Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidInputParam if Count is zero 4 InvalidEventType if event type is out of range Chapter 5 Functions Reference 247 DRV_CheckEvent status CheckEvent DriverHandle lpCheckEvent Purpose Clear event and read current status Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpCheckEvent Input Output long pointer to default the storage address PT_CheckEvent for EventType Milliseconds Table 5 100 DRV_CheckEvent Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 EventTimeOut if the Time out interval elapsed in milliseconds parameter 248 Advantech DLL Drivers User s Manual DRV_TimerCountSetting status DRV_TimerCountSetting DriverHandle lpTimerCountSetting Purpose For PCI data acquisition and control device the Timer informations are defined from device installation But we provide this API to change the Counter Timer value dynamically Parameters DriverHandle Input long default assigned by DRV_DeviceOpen IpTimerCountSetting Input Output long pointer to default the storage address for PT_TimerCountSetting counter and Count Table 5 101 DRV_TimerCountSetting Parameter Table
129. fig USHORT counter USHORT LatchSrc USHORT LatchOverflow USHORT ResetOnLatch USHORT ResetValue PT_QCounterConfig FAR LPT_QCounterConfig PT_QCounterConfig is used by DRV_QCounterConfig function Member Description Name Direction Type Description LatchSrc unsigned short latch source you can set the following value SWLATCH 0 INDEXINLATCH 1 DIOLACTCH 2 DI1LACTCH 3 TIMERLATCH 4 LatchOverflow unsigned short free run 0 or latch on overflow 1 ResetOnLatch unsigned short reset after counter is latched 1 otherwise 0 ResetValue unsigned short Set reset value to 000000 0 800000 1 Table 5 145 PT_QCounterConfig Member Description 296 Advantech DLL Drivers User s Manual PT_QCounterConfigSys typedef struct tagPT_QCounterConfigSys 1 USHORT SysClock USHORT TimeBase USHORT TimeDivider USHORT CascadeMode PT_QCounterConfigSys FAR LPT_QCounterConfigSys PT_QCounterConfigSys is used by DRV_QCounterConfigSys function Member Description SysClock unsigned short clock frequency for digital filter you can set SYS8MHZ 0 SYS4MHZ 1 SYS2MHZ 2 TimeBase unsigned short 16C54 time base control TPOINT1MS 0 0 1 ms T1MS 1 1ms T10MS 2 10ms T100MS 3 100ms T10000MS 4 1second TimeDivider Input divider control value CascadeMode Input unsigned short cascade mode NOCASCADE 0 CASCADE 1 Table 5 146 PT_QCounterConfigSys Member Description Chapter 5 F
130. g a Win32 Console Application in the VC App Wizard Chapter 3 Tutorial 51 4 Add the adsapi32 lib library file and a new file named adsoft cpp into your project J Figure 3 10 Adding the adsapi32 lib Library File and adsoft cpp to Your Project 5 Write codes for adsoft cpp as follows 52 Advantech DLL Drivers User s Manual PORRO ORO e A E AE e E E E A E AE ROO ROO ROO RIOR ROO ROO k k Program ADSOFT CPP Description Demo program for analog input function with software triggering Boards Supp PCL 818 series 816 1800 812PG 711B MIC 2718 PCM 3718 PCI 1710 1713 PCL 813B Demo board ADAM 4011 4011D 4012 4014D 4018 4018M 5018 4017 4013 5017 4016 APIs used DRV_DeviceOpen DRV_DeviceClose DRV_GetErrorMessage DRV_AIConfig DRV_AlVoltageln Revision 1 00 Date 7 8 1999 Advantech Co Ltd ii include lt windows h gt include lt windef h gt include lt stdio h gt include lt conio h gt define WIN_CONSOLE include include driver h OCI CII IC III ICI ICI I Ik Local function declaration ii void ErrorHandler DWORD dwErrCde void ErrorStop long DWORD void main DWORD dwErrCde ULONG 1DevNum long 1DriverHandle USHORT usChan float fVoltage PT_AlVoltageln ptAlVoltageln PT_AIConfig ptAlConfig Step 1 Display hardware and software settings for running this
131. gStart status DRV_FAIIntWatchdogStart DriverHandle lpFAIIntWatchdogStart Purpose Initiates an asynchronous data acquisition operation with analog watchdog by interrupt transfer and stores its input in an array Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen LpFAlintWatchd Input Output long pointer to default the storage address ogStart PT_FAlIntWatch for TrigSrc dogStart SampleRate buffer BufferSize count cyclic IntrCount 236 Table 5 88 DRV_FAlIntWatchdogStart Parameter Table Return 1 SUCCESS if successful InvalidDriverHandle if DriverHandle NULL Invalid WindowsHandle if buffer NULL BoardIDNotSupported if function doesn t have support in driver NE DS Invalid CountNumber have these conditions count is zero IntrCount gt count or count is not even 6 IllegalSpeed if SampleRate is out of range 7 InvalidEventCount if EventCount is not IntrCount multiple 8 ChanConflict if interrupt channel is conflict 9 OpenEventFailed if event name opens failure 10 InterruptProcessFailed if interrupt proces is failure 11 KeInsufficientResources if resource is conflict with another driver 12 KeConInterruptFailure if connects interrupt failure Advantech DLL Drivers User s Manual DRV_FAIDmaWatchdogStart status FAIDmaWatchdogStart DeviceHandle TrigSrc SampleRate BufferA BufferB BufferSize cyclic Purpose Initiates
132. h multiplex in the cascade or Y connection must be routed jumpered to a different channel on the DAS card Further more the gain selector switch on each multiplexer should be posi tioned to select the desired input range 3 Configuring the PCLD 788 Relay Multiplexer Boards The PCLD 788 Relay Multiplexer allows up to 256 analog input channels to be multiplexed into one analog input A D channel of a DAS card The first eight D O channels of the DAS card are used for addressing each PCLD 788 high nibble and for scanning selecting channels lower nibble of the PCLD 788 one at a time Because of the digital output allocation when using these expansion boards the first byte of D O channels 0 7 on the DAS card are no longer available for standard digital output Because of their unique addressing method and very high impedance when not selected multiple PCLD 788s up to 16 can be connected to a single analog input A D channel Therefore up to 256 channels may be connected to each A D channel of the I O card When using the PCLD 788 the input range of the DAS card should be set for any desired range 4 If there is no expansion board connecting to the DAS channel it calls DRV_AlIVoltageln Chapter 5 Functions Reference 167 DRV_MAIConfig status DRV_MAIConfig DriverHandle lpMAIConfig Purpose Configures the gain settings for the specified analog input channels Parameters Direction Type Range Description
133. hannel AI With Software Triggering 66 3 5 3 Analog Input With Interrupt Triggering 0 66 3 5 4 Analog Input with DMA Triggering eee 66 3 5 5 Analog Input With Watchdog Triggering 0 67 3 5 6 Analog Output mart iria 67 3 5 7 Synchronous Analog Output 0 eee eeeeeeeeeeeeeeee 67 3 5 8 Analog Output with Interrupt Triggering 0 0 0 67 3 5 9 Analog Output with DMA Triggering ee 67 3 93 10 Digital Inputs ico 67 3 5 11 Digital Input With Interrupt Triggering 00 68 3 5 12 Digital Input With Pattern Match Counter Overflow Status Change coooconccnncnnocononcnoncnaninananancnnnos 68 3 3413 Digital OO putita 68 35 14 Event Counting cebras acc tiros 68 3 5 15 Event Counting With Interrupt Triggering 0 00 68 3 5 16 Event Counting With Interrupt Triggering 00 00 68 39 17 Pulse Output lona ads 69 3 39 18 PWM OUtpUt aia a ea 69 Preface 3 5 19 Frequency Measurement coooonocccnncccnonccnnonnnnnonananncnnneninns 69 3 5 20 Temperature Measurement coocccnoccnocononcnonaconnconncnnnannos 69 AS NA 69 313 22 Port Oir ES DA CAR ARS 69 3 5 23 COMMUNICATION eni ir ar E Sa 70 3 5 24 Event FUNGON iaia ea nen eae AE 70 Chapter 4 Function Overview ocoooccccnnnccccccnncnnnnnnnanes 71 4 1 Introduction coocoonooncononnciosnsonconoconosonconccocccncocconcconoannns 72 4 2 Device Functions occonmonnonnonnnconcononioninconconcnoconcconconccononnones 75 4 2 1 DLL Driver Programming Foundation
134. he linearization is performed and the temperature acquired by the thermocouple mux card is available for control strategy use or display in Degrees Celsius The conversion to units other than degrees C Fahrenheit Kelvin etc can be accomplished by using a calcula tion scaling factor To perform thermocouple measurement 1 Properly configure the DAS card 2 Connect the thermocouple s to the PCLD 788 terminals 3 Select the desired input channel on the A D I O card to connect to the CJC cold junction compensation circuit and connect a jumper from the CJC output to the input channel Select the same CJC channel during software configuration of the driver Of course the CJC channel selected cannot be set tot any analog channel being used for another purpose Advantech DLL Drivers User s Manual 4 Select the appropriate configuration in the driver configuration dialog box base address etc 5 Select the input range 0 05V to 0 05V in the application software for all thermocouple types 6 When THERMOCOUPLE TYPE in the application software is selected the driver will perform the appropriate linearization for the selected thermocouple type with respect to any selected A D range However the optimum range is the A D range that can handle the entire temperature range for each supported thermocouple type Configuring the PCLD 8115 CJC Terminal boards The PCLD 8115 is used as a terminal board to allow the user to connect differen
135. hermocouple s to the terminals on the PCLD 770 779 789 889 2 Use a shielded ribbon cable to connect CN1 of the PCLD 770 779 789 889 to the analog input port on the DA amp C card in use 3 Use a ribbon cable to connect CN2 of the PCLD 770 779 789 to the digital output port on the DA amp C card in use 4 Select a proper input range or gain on the PCLD 770 779 789 for the type of thermocouple used as described in the PCLD 770 779 789 hardware manual K type 50 J type 100 T type 200 E type 50 R type 200 S type 200 B type 200 120 Advantech DLL Drivers User s Manual 1 Select the desired input channel on the DA amp C card to correspond with each PCLD 770 779 789 by setting the jumper block JP1 PCLD 770 JP16 PCLD 789 or JP2 PCLD 779 to a proper position Positions 0 9 correspond to analog inputs 0 9 of the DA amp C card in use 2 Select the desired input channel on the DA amp C card for the CJC cold junction compensation circuit on the PCLD 770 by hard wiring the CJC output directly to an A D channel On the PCLD 779 789 select the CJC channel by setting the jumper block JP17 PCLD 789 or JP3 PCLD 779 Positions 0 9 correspond to analog inputs 0 9 of the DA amp C card in use Of course the CJC channel selected cannot be set to any analog channel that is already being used for another purpose 3 Ifyou are cascading or Y connecting more than one PCLD 779 789 for thermocouple measurement norma
136. hows the function call flow for single channel reading Advantech DLL Drivers User s Manual l Channel Gain IntrCount SampleRate Count Cyclic DRV_FAIIntStart DRV_FAICheck Yes DRV_FAITransfer Repeated No DRV_FAIStop Figure 4 6 Single Channel Reading Function Call Flow The DRV_FAIIntStart function starts the analog input operation with interrupt triggering It runs in the background You can use the DRV_FAICheck function to check the status of the operation Mean while you can use DRV_FAITransfer function to retrieve the data Then you can stop the operation by DRV_FAIStop function when the conversion is complete or at any other time Chapter 4 Function Overview 85 86 Note Besides single data reading the driver also provides DRV_FAlIntScanStart function for multiple channel reading For this kind of operation you should set the buffer size that is the Count parameter to be a multiple of the number of channels Otherwise for the cyclic mode the first data in the circular buffer may not be for the start channel Examples Directory Advantech Adsapi Examples Console adint Advantech Adsapi Examples V Bladint Advantech Adsapi Examples Delphi adint Advantech Adsapi Examples VC adint Function Description Demo program for analog input function with Interrupt triggering 4 3 2 3 DMA Triggering There are two kinds of DMA triggering method One is single DMA triggering the other one is dual DMA trigge
137. hronous mutiple channel data acquisition operation with Interrupt and stores its input in an array and the gain codes for the scan channels Parameters Direction Range DriverHandle Input long default assigned by DRV_DeviceOpen LpFAlintScanStart Input Output long pointer to default the storage address PT_FAlintScanStart for TrigSrc SampleRate NumChans StartChan GainList buffer count cyclic IntrCount Table 5 80 DRV_FAlIntScanStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if buffer NULL or GainList NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidGain if gain code is incorrect 6 InvalidChannel if chan is out of range 7 InvalidCountNumber have these conditions count is zero IntrCount gt count or count is not even 8 IllegalSpeed if SampleRate is out of range 9 InvalidEventCount if EventCount is not IntrCount multiple 10 ChanConflict if interrupt channel is conflict 11 OpenEventFailed if event name opens failure 12 InterruptProcessFailed if interrupt proces is failure 13 KelnsufficientResources if resource is conflict with another driver 14 KeConInterruptFailure if connects interrupt failure Chapter 5 Functions Reference 227 DRV_FAlDmaScansStart status DRV_FAIDmaScanStart DriverHandle lpFAIDmaScanStart Purpose Initiates an asynchronous mutiple chan
138. idCountNumber if count is zero or start point is bigger than conversion number 244 Advantech DLL Drivers User s Manual DRV_FAOCheck status DRV_FAOCheck DriverHandle 1pFAOCheck Purpose Checks if the current analog output is complete and return current status Parameters Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen LpFAOCheck Input Output long pointer to default the storage address PT_FAOCheck for ActiveBuf stopped CurrentCount HalfReady Table 5 97 DRV_FAOCheck Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL Chapter 5 Functions Reference 245 DRV_FAOStop status DRV_FAOStop DriverHandle Purpose Cancels the current analog output operation and resets the hardware and software Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen Table 5 98 DRV_FAOStop Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 246 Advantech DLL Drivers User s Manual DRV_EnableEvent status DRV_EnableEvent DriverHandle lpEnableEvent Purpose Enables or disables event This funtion supports with interrupt and DMA features Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpEnableEvent Input Output long pointer to de
139. ied channel PM reeter long default assigned by DRV_DeviceOpen chan input long default Table 5 69 DRV_AlarmReset Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidChannel if chan is out of range 4 CommTransmitFailed if COMWrite failed 5 CommReadFailed if there is no response 6 CommReceiveFailed if the response string is incorrect 216 Advantech DLL Drivers User s Manual COMOpen status COMOpen PortNum CommID DeviceHandle Purpose Opens 1 of 4 serial communication ports 9 serial ports if SuperCom is installed This function must be called before using any other commu nication functions Parameters Name Direction Type Description PortNum Input unsigned short communication port CommiD output long pointer to integer port ID obtained from OpenComm DeviceHandle Input long assigned by DeviceOpen Table 5 70 COMOpen Parameter Table Return 1 SUCCESS if successful 2 ConfigDataLost if configuration data is lost 3 MemoryAllocateFailed if memory is not enough Note This function calls Windows API OpenComm to open communica tion port Chapter 5 Functions Reference 217 COMClose status COMClose DeviceHandle Purpose Closes the serial port that is opened by COMOpen Parameters Direction Type ___ Description Name DeviceHandle Input long pointer assigned by DeviceOpen Table 5 71 COMClose Paramet
140. if DriverHandle NULL 3 InvalidChan if input channel is out of range 4 BoardIDNotSupported if this function is not supported for this Device Chapter 5 Functions Reference 175 DRV_AOScale status DRV_AOScale DriverHandle 1pAOScale Purpose Scales a voltage to a binary value that when written to one of the analog output channels produces the specified voltage Parameters Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpAOScale Input Output long pointer to default the storage PT_AOScale address for chan OutputValue and BinData Table 5 35 DRV_AOScale Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if this function is not supported for this Device 176 Advantech DLL Drivers User s Manual DRV_AOBinaryOut status DRV_AOBinaryOut DriverHandle lpAOBinaryOut Purpose Writes a binary value to one of the analog output channels changing the voltage produced at the channel Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpAOBinaryOut Input Output long pointer to default the storage PT_AOBinaryOut address for chan and BinData Table 5 36 DRV_AOBinaryOut Parameter Table Return 1 2 3 4 SUCCESS if successful InvalidDriverHandle if DriverHandle NULL InvalidChan if input channel is out of r
141. ig Input Output long pointer to the storage address of PT_AlGetConfig the buffer and size Table 5 22 DRV_AlGetConfig Parameter Table Return SUCCESS if successful InvalidDriverHandle if DriverHandle NULL 162 Advantech DLL Drivers User s Manual DRV_AlBinaryln status DRV_AlBinaryIn DriverHandle lpAIBinaryIn Purpose Reads an analog input channel and returns the unscaled result Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpAlBinaryln Input Output long pointer to default the storage address PT_AlBinaryin for chan TrigMode and reading Table 5 23 DRV_AlBinaryln Function Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 DataNotReady if the TrigMode 1 and data is not ready 4 AlConverionFailed if conversion failed 5 BoardIDNotSupported if Board ID is not supported Chapter 5 Functions Reference 163 DRV_AlScale status DRV_AlScale DriverHandle lpAIScale Purpose Converts the binary result from an DRV_AlBinaryln call or DRV_MAIBinaryIn call to the actual input voltage Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen IpAlScale Input Output long pointer to default the storage address PT_AlScale for reading MaxVolt MaxCount offset and Voltag Table 5 24 DRV_AlScale Function Table Return SUCCESS if successful
142. ing FLOAT MaxVolt USHORT offset FLOAT far voltage PT_AIScale FAR LPT_AlScale PT_AlIScale is used by DRV_AlIScale function Member Description Name Direction Type reading Input unsigned short result of AlBinaryin MaxVolt float max voltage MaxCount unsigned short max count offset unsigned short binary offset for zero voltage voltage Output long pointer to MaxVolt to computed floating point MaxVolt floating point voltage Table 5 115 PT_AlScale Member Description Chapter 5 Functions Reference 265 PT_AlVoltageln typedef struct tagPT_AlVoltageln 1 USHORT chan USHORT gain USHORT TrigMode FLOAT far voltage PT_AlVoltageln FAR LPT_AlVoltageln PT_AIVoltageIn is used by DRV_AIVoltageln function Member Description Direction Type Range Description gain Input Input unsigned short unsigned short 0 n n depends on hardware refer to gain list in hardware manual the sampled channel gain code TrigMode Input unsigned short 0 normal software 1 external trigger mode voltage 266 Output long pointer to floating point depends on input range the measured voltage returned scaled to units of volts Table 5 116 PT_AlVoltageln Member Description Advantech DLL Drivers User s Manual PT_AlVoltagelnExp typedef struct tagPT_AIVoltageInExp 1 USHORT DasChan USHORT DasGain USHORT
143. ion Overview 115 116 4 6 2 2 PWM Output PWM output functions perform the pulse width modulation output Call Flow DRV_CounterReset DRV_CounterPWMSetting DRV_CounterPWMEnable DRV_CounterReset Figure 4 21 PWM Output Function Call Flow The DRV_CounterReset function resets the PWM counter The DRV_CounterPWMsSetting function configures the PWM counter The DRV_CounterPWMEnable function enables the PWM pulse output operation When the operation is complete you can call the DRV_CounterReset function to stop and reset the PWM pulse output operation Advantech DLL Drivers User s Manual Examples Directory Advantech Adsapi Examples Console pulsepwm Advantech Adsapi Examples V B pulsepwm Advantech Adsapi Examples Delphi pulsepwm Advantech Adsapi Examples V C pulsepwm Function Description Demo program for PWM pulse output function 4 6 3 Frequency Measurement The frequency measurement functions measure the pulse frequency Call Flow DRV_CounterFreqStart aa DRV_CounterFreqRead Another Reading DRV_CounterReset Figure 4 22 Frequency Measurement Function Call Flow Chapter 4 Function Overview 117 118 The DRV_CounterFreqStart function starts the frequency measure ment When it is running in the background you can call the DRV_CounterFreqRead function to repeatedly measure the frequenc
144. ion Utility Chapter 3 Tutorial 47 3 Select Setup Device from the main menu A dialog box is displayed kl Be Figure 3 3 I O Device Installation Dialog Box 4 Press the Add gt gt button and select the Advantech DEMO Board item in the List of Devices list box et Dame tite aoe Lis EM ima reci ALOAN t Figure 3 4 Selecting the Advantech DEMO Board Device 5 Press the Install button and a configuration dialog box is dis played as below 48 Advantech DLL Drivers User s Manual Figure 3 5 Device Configuration Window 6 Use the default value and press the OK button You will see a new entry in the Installed Devices list in the I O Device Installation window PELIER i Figure 3 6 I O Device Installation Dialog Box 7 Press the Close button and exit and Device Installation Utility Step 2 Write Your Application with DLL Driver 1 Go into the Start menu and click on the Microsoft Visual C 5 0 icon in the Microsoft Visual C 5 0 folder Chapter 3 Tutorial 49 Figure 3 7 Start Microsoft Visual C 2 Select File New from the main menu 50 Advantech DLL Drivers User s Manual Figure 3 8 Creating a New VC Application 3 The following dialog box loads Click on the Win32 Console Application entry in the list and enter Adsoft in the Project name field Then press the OK button This generates some skeleton code for you Figure 3 9 Creatin
145. iseconds Table 5 173 PT_CheckEvent Member Description 324 Advantech DLL Drivers User s Manual PT_AllocateDMABuffer typedef struct tagPT_AllocateDMABuffer USHORT CyclicMode ULONG RequestBufSize ULONG far ActualBufSize LONG far buffer PT_AllocateDMABuffer FAR LPT_AllocateDMABuffer PT_AlarmCheck is used by DRV_AlarmCheck function Member Description ___Name____ Direction Type Range Description CyclicMode default non cyclic 0 and cyclic 1 RequestBufSize Input unsigned long default request buffer size in byte ActualBufSize Output pointer to default actual size can be allocated unsigned long buffer size in byte Buffer Output pointertolong default bufferaddress Table 5 174 PT_AllocateDMABuffer Member Description Chapter 5 Functions Reference 325 PT_EnableEventEx typedef union tagPT_EnableEventEx union type struct PT_DIFilter Filter PT_DIPatternPattern PT_DICounter Counter PT_DIStatus Status PT_EnableEventEx FAR LPT_EnableEventEx PT_EnableEventEx is used by DRV_EnableEventEx function Member Description Name Direction Type Range Description PT_DIFilter Input structure pointer default Structure for Digin Filter PT_DiPattern default Structure for Pattern Match PT_DICounter default Structure for Counter Match PT_DiStatus structure pointer default Structure for Change of Input State Table 5 175 PT_EnableEventEx Member Description 326 Adv
146. ity are introduced to set up and test your Advantech hardware Using DEVINST EXE to configure your hardware must be completed before you can write programs using the DLL Drivers to access your hardware Chapter 2 Creating Windows 95 98 and Windows NT Applica tions with the DLL Drivers briefly explains how to use the DLL Drivers with four popular development environments It also highlights some programming issues such as buffer allocation string passing and parameter passing that you should consider during development vi Advantech DLL Drivers User s Manual Chapter 3 Tutorial gives the new user a walk through in creating a simple application Step by step procedures are given for a Win32 console application and using the Microsoft Visual Basic and Borland Delphi development environments In addition there is a listing of all the sample programs and code that are available on the CD ROM disc Chapter 4 Function Overview introduces the kinds of hardware functions that can be programmed by using the DLL Drivers The functions include device analog input analog output digital input output counter temperature measurement alarm port communication and event Chapter 5 Functions Reference is a listing of all the functions and data structures that are supported by the 32 bit DLL Drivers In addition it shows what functions are supported by each of Advan tech s hardware models Appendix A Error Codes explains the error codes that
147. ity to configure hardware Use testing utility to test hardware Read examples amp driver manual Start to write your application Figure 1 2 Steps to Start Programming with Advantech s DLL Drivers Advantech DLL Drivers User s Manual 1 2 Installing the 32 bit DLL Drivers 1 2 1 Installing the Software The installation CD ROM is shipped with 1 O cards You can use it to install the 32 bit DLL driver Please follow the steps below to install the driver software 1 Insert the driver installation CD ROM disc into your CD ROM drive 2 The installation program will run automatically if you have enabled the Windows auto run feature If auto run is not enabled on your computer use your Windows Explorer or the Windows Run command to execute setup exe on the driver installation CD ROM disc assume d is the letter of your CD ROM disc drive d setup exe fate serca ali bre and ei ai ed Paidet Than ges fee methods io hadal an Hart d Seker che dere berm iror thes CDs hep Pieper ell be leer a Mindo J Les bos Fila Enplains re ld Mie Fre iho CU e oie rca Fem dela al bel CO rr ler dich on the Horas OF Comrie AS a file FEC HTM ae ae LE go niles ne Figure 1 3 Advantech s Automation Software Installation Program Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Driver 5 3 Click the link labeled DLL Drivers and then click either the link labeled Windows 9
148. le 5 142 Table 5 143 Table 5 144 Table 5 145 Table 5 146 Table 5 147 Table 5 148 Table 5 149 Table 5 150 Table 5 151 Table 5 152 Table 5 153 Table 5 154 Table 5 155 Table 5 156 Table 5 157 Table 5 158 Table 5 159 Table 5 160 Table 5 161 Table 5 162 Table 5 163 Table 5 164 Table 5 165 Table 5 166 Table 5 167 Table 5 168 Table 5 169 Table 5 170 Table 5 171 Table 5 172 Table 5 173 Table 5 174 Table 5 175 Table 5 176 Table 5 177 Table 5 178 Table 5 179 PT_DioGetCurrentDOBit Member Description oooniicninnnon cnmcmmmm 286 PT_WritePortByte Member Description ooocinncconnccnnnccconccccnnccccnaccnonno 287 PT_WritePortWord Member Description ooooocnccccinicicinoccconoccconacanonacananos 288 PT_ReadPortByte Member Description ooooonccccinnciconocccnocccconacaninacananos 289 PT_ReadPortWord Member Description coooccconncccnnncccnnnccconcccncnaccnnano 290 PT_CounterEventStart Member Description s e 291 PT_CounterEventRead Member Description oonnconcnnnnnnnnnnncoononcccn 292 PT_CounterFreqStart Member Description oooononioninnnnnnncncononencs 293 PT_CounterFreqRead Member Description 294 PT_CounterPulseStart Member Description cccceeseeteeteeeteeeee 295 PT_QCounterConfig Member Description ceseeceeseeeteeeteeeteeees 296 PT_QCounterConfigSys Member Description c ccceceeseesteeteeees 297 PT_QCou
149. le 5 48 DRV_WritePortByte Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 KelInvalidHandleValue if the kernel mode driver cannot be opened 4 KeFileNotFound if an attempt was made to open kernel mode driver while the driver was not running 5 KeTooManyCmads if the logic commands have created an apparent endless loop for kernel mode driver 6 KelnvalidHandle if the handle for kernel mode driver is not a valid handle 7 KelnvalidParameter if the parameter passed to kernel mode driver is incorrect 8 KeNoAccess if an attempt to access a port or memory address which has not been defined in the Registry for this device Chapter 5 Functions Reference 189 DRV_WritePortWord status DRV_WritePortByte DriverHandle lpWritePortWord Purpose Writes a 16 bit data to the specified I O port The port address is an I O port address on the PC Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpWritePortWord Input Output long pointer to default the storage address PT_WritePortWord for port and WordData Table 5 49 DRV_WritePortWord Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 KelnvalidHandleValue if the kernel mode driver cannot be opened 4 KeFileNotFound if an attempt was made to open kernel mode driver while the driver was not running
150. lidInputParam if NumOfDevice NULL 3 ConfigDataLost if Registry is missing or invalid Chapter 5 Functions Reference 153 DRV_DeviceGetList status DRV_DeviceGetList DeviceList MaxEntries OutEntries Purpose Gets list of the installed devices not including the attached devices on COM port or CAN Parameters Name Direction Type Description DeviceList Output long pointer to DEVLIST list of the installed devices MaxEntries Input OutEntries Output integer long pointer to integer maximum entries output entries Table 5 15 DRV_DeviceGetList Parameter Table Return 1 SUCCESS if successful 2 InvalidInputParam if NumOfDevice NULL 3 ConfigDataLost if Registry is missing or invalid Parameter Details DEVLIST refers to ADAPI H 154 Advantech DLL Drivers User s Manual DRV_DeviceGetSubList status DRV_DeviceGetSubList DeviceNum SubDeviceList MaxEntries OutEntries Purpose Gets list of the installed devices on COM port or CAN Parameters Name Direction Type Description DeviceNum Input unsigned long device number for COM port or CAN SubDeviceList Output long pointer to list of the DEVLIST installed devices MaxEntries Input integer maximum entries OutEntries Output long pointer to output entries integer Table 5 16 DRV_DeviceGetSubList Parameter Table Return 1 SUCCESS if successful 2 InvalidInputParam if NumOfDevice NULL 3
151. lly only one CJC input is required i e only one of the PCLD 770 779 789s has to connect its CJC to the DA amp C card 4 Make sure jumper blocks JP16 and JP17 or JP2 and JP3 are not at the same position They must be set to different input channels on the DA amp C card 5 Select the appropriate configuration in the configuration dialog box of the device installation utility such as DA amp C card expansion board expansion gain and base address etc The driver will perform the appropriate linearization only if the DA amp C card s A D input range is set to 5 V to 5 V PCLD 788 Follow the procedure to perform thermocouple measurement 1 Connect the thermocouple s to the PCLD 788 terminals 2 Select the desired input channel on the A D I O card to connect to the CJC cold junction compensation circuit and connect a jumper from the CJC output to the input channel Select the same CJC channel during software configuration of the driver Of course the CJC channel selected cannot be set to any analog channel being used for another purpose Chapter 4 Function Overview 121 3 Configure the base address and connection in the configuration dialog box of the device installation utility Select the input range 0 05 V to 0 05 V in your application for all thermocouple types When thermocouple type is selected the driver will perform the appropriate linearization for the selected thermocouple type with respect t
152. long pointer to floating point array 270 Advantech DLL Drivers User s Manual depends on input range the measured voltages returned scaled to units of volts Table 5 120 PT_MAIVoltageln Member Description PT_MAIVoltagelnExp typedef struct tagPT_MAIVoltageInExp USHORT NumChan USHORT far DasChanArray USHORT far DasGainArray USHORT far ExpChanArray FLOAT far VoltageArray PT_MAIVoltageInExp FAR LPT_MAIVoltageInExp PT_MAIVoltageInExp is used by DRV_MAIVoltageInExp function Member Description Direction Type NumChan unsigned short 1 n n depends on hardware the number of channels DasChanArray DasGainArray Input long pointer to unsigned short arra long pointer to unsigned short array 0 n n depends on hardware refer to gain list in hardware manual scan channels on DAS card gain array for DAS card ExpChanArray Input long pointer to unsigned short array see below the sampled channels on the expansion board VoltageArray Output long pointer to floating point array depends on input range the measured voltages returned scaled to units of volts Table 5 121 PT_MAIVoltageInExp Member Description Chapter 5 Functions Reference 271 PT_TCMuxRead typedef struct tagPT_TCMuxRead 1 USHORT DasChan USHORT DasGain USHORT ExpChan USHORT TCType USHORT TempScale FLOAT far temp PT_TCMuxRead F
153. marks e Digital I O channel 0 7 3 Port 0 e Digital I O channel 8 15 gt Port 1 e Digital I O channel 9 23 gt Port 2 e Digital I O channel 24 31 Port 3 Chapter 5 Functions Reference 287 PT_WritePortWord typedef struct tagPT_WritePortWord 1 USHORT port USHORT WordData PT_WritePortWord FAR LPT_WritePortWord PT_WritePortWord is used by DRV_WritePortWord function Member Description Neme Direction Type Description I O port address Table 5 137 PT_WritePortWord Member Description 288 Advantech DLL Drivers User s Manual PT_ReadPortByte typedef struct tagPT_ReadPortByte 1 USHORT port USHORT far ByteData PT_ReadPortByte FAR LPT_ReadPortByte PT_ReadPortByte is used by DRV_ReadPortByte function Member Description Name Direction Type Description port Input unsigned short O port address ByteData Output long pointer to 8 bit input data unsigned short Table 5 138 PT_ReadPortByte Member Description Chapter 5 Functions Reference 289 PT_ReadPortWord typedef struct tagPT_ReadPortWord 1 USHORT port USHORT far WordData PT_ReadPortWord FAR LPT_ReadPortWord PT_ReadPortWord is used by DRV_ReadPortWord function Member Description Name Direction Type Description I O port address WordData Output long pointer to 16 bit input data unsigned short Table 5 139 PT_ReadPortWord Member Description 290 Advantech DLL Drivers User s
154. me Direction Type Description Input unsigned short counter number of PCI device For PCI 1750 there are counter0 counter1 and counter2 Timer count setting Table 5 149 PT_TimerCountSetting Member Description 300 Advantech DLL Drivers User s Manual PT_DiCounter typedef struct tagPT_DICounter USHORT usEventType USHORT usEventEnable USHORT usCount USHORT usEnable USHORT usTrigEdge USHORT far usPreset USHORT usMatchEnable USHORT far usValue USHORT usOverflow USHORT usDirection PT_DICounter FAR LPT_DICounter PT_DICounter is used by DRV_EnableEventEx function Member Description Name Direction Type Description Input unsigned short Input unsigned short event enable disable bit usCount Input unsigned short reserved usEnable unsigned short counter0 counter7 enable disable setting For example if bit0 1 counter0 is enabled usTrigEdge unsigned short counter trigger edge 0 rising edge 1 falling edge usPreset long pointer to counter pre_setting unsigned short value usMatchEnable unsigned short the match function of counter0 counter7 enable disable setting For example if bit0 1 the match function of counter0 is enabled usValue long pointer to counter match value unsigned short usOverflow___ Input unsigned short counter overflow data usDirection Input unsigned short up down counter direction but now not available Table 5 150 PT_DICounter Mem
155. might be returned when calling functions provided by the DLL Drivers Refer to this section when debugging your application Preface vii Contents Copyright Notice cui da as 11 Acknowledgement cccccescccsseceeseeceeseeceaeeceeeeeenaeeseaeceeatecsaes 11 Advantech Customer Services cooooooccconocnncnonnnnnnonnnncnonnnnnnnnnnos 111 Technical Supporte cios ici usage caai sagan iii Technical Suppport Offices coooooncconncccnoncconnncononccnnnanananonanccnnos 1v Limited Warranty betta v About This Manual seereis a AR A E vi Organization of This Manual oooocnnnnnccinocononcninonaninnccnnnnonanenonnos vi Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Drivers sici n 1 1 1 About the Advantech DLL Driver Software 000 2 1 1 1 How To Start Programming Advantech Hardware 3 1 2 Installing the 32 bit DLL Drivers omomomomomsmmmm 5 1 2 1 Installing the Software oooconncnnncnnocccoccconnconnnannnannnnnncnnnnns 5 L22 Fie SWucture siish aT 10 1 2 3 Uninstalling the DLL Drivers seeen 11 1 3 Device Installation Utility Configuration Program 12 1 4 Device Test Utility oooooooonooroncconoccononcononooroccncnoccconcconococonoss 15 Chapter 2 Creating Windows 95 98 and Windows NT Applications with the DLL Drivers 19 2 1 Introduction to Programming with the DLL Driver 20 2 2 Using the Win32 Console sscsssccssssccesscsssscessscsssceess 21 2 3 Using Microsof
156. n all be used in your application programs 6 Create your application source code by clicking Project Add to Project New and selecting the C Source File option After you have created the application you can also add the related resources and save them into a rc file and add the rc file to the project For more detailed program development information please refer to the Microsoft Visual C User s Manual 26 Advantech DLL Drivers User s Manual de Tie idd fear contred potifdcacdno bandlar code bere Hiiri ij Biturtite foabieWindew MESE 1 n itoplto Cradle FELIE J coda EFRdgdebig ieldner HIHI mibiuret 4 Lene de Mibi bdd pour ransage bandier code bere and or cail Ai E ensa Firs eee F z JJ Estrinal Dispradeates mput salar e cbantradiariibcs ciales DISAM far Eguialar de dim Erride DEN biokradfurt pim briserbanddr LEA fd ebeadPertigte DinkeadPertigtes bei fetirrorteas ip_Erride gL Palka irrig sli i J Figure 2 6 Creating Your Application Source Code in the App Studio 7 Add the DLL import library for example ADSAPI32 LIB into this project by clicking on the Build menu and choosing the Settings option The Project Setting dialog box will be displayed at the front of the Windows screen Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 27 B Shape Erai POLE T sala gil aTi MIRA E FSO EEA Meba apia ee TU cee i e GAN E T FE dojan vania ce AE
157. n to read the state from the specified bit Port Bit DRV_DioReadBit Figure 4 13 DI Software Triggering Call Flow In addition to the DRV_DioReadBit function the DLL drivers also provide the DRV_DioReadPortByte function to read a byte value from a port Examples Directory Advantech Adsapi Examples Console digin Advantech Adsapi Examples VB digin Advantech Adsapi Examples Delphi digin Advantech Adsapi Examples VC digin Function Description Demo program for digital input function 102 Advantech DLL Drivers User s Manual 4 5 1 2 Interrupt Triggering The digital input functions with interrupt triggering allow you to monitor the status of the digital input line When the state changes from low to high or and from high to low it would acknowledge the driver through a hardware interrupt You don t have to poll the digital input line periodically a DRV_EnableEvent Call Flow DRV_CheckEvent Yes No y Figure 4 14 Interrupt Triggering Call Flow The DRV_EnableEvent function enables and starts digital input with interrupt triggering You can then use the DRV_CheckEvent function to check the background status The DRV_CheckEvent function returns the interrupt event type when the state changes It also allows you to set a time out interval Please refer to the event functions for details Chapter 4 Function Overview 103 104 Examples Directory Advantech Adsapi Examples Console diint A
158. ndows 95 98 and Windows NT Applications with the DLL Drivers 2 1 Introduction to Programming with the DLL Driver 20 This section contains general information about building DA amp C applications It describes the nature of the DLL drivers files used in building DA amp C applications and explains the basics of making DA amp C applications using the following tools e Microsoft Visual C for Windows 95 98 NT version 5 0 e Microsoft Visual Basic for Windows 95 98 NT version 5 0 e Borland Delphi for Windows 95 98 NT version 4 0 e Borland C 5 0 or C Builder version 1 0 If you are not using the tools listed consult your development tool reference documentation for details on creating applications that call DLLs The 32 bit Windows 95 98 NT DLL function libraries are dynamical ly linked which means that DLL routines are not linked into the executable files of applications Information about the DLL routines in the DLL import libraries is stored in the executable files The DLL driver is linked to the application only when DLL functions are called during execution Import libraries LIB contain information about their DLL export functions They indicate the presence and location of the DLL routines Depending on the development tool that you are using you may give the DLL routines information through import libraries or through function declarations Using functional prototypes is good programming practice That is
159. ned short 0 internal 1 external hardware voltage hardware voltage Table 5 105 AOSET Member Description Chapter 5 Functions Reference 255 DAUGHTERSET typedef struct tagDAUGHTERSET 1 DWORD dwBoardID USHORT usNum FLOAT fGain USHORT usCards DAUGHTERSET FAR LPDAUGHTERSET DAUGHTERSET is used by DRV_AIGetConfig function Member Description Name Direction Type Range Description dwBoardID input double word Refer to Driver H expansion board ID usNum input unsigned short depend on available device expansion installation channels fGain input floating point depend on gain for hardware expansion channel usCards input unsigned short depend on number of device expansion cards installation Table 5 106 DAUGHTERSET Member Description 256 Advantech DLL Drivers User s Manual DEVCONFIG_AI typedef struct tagDEVCONFIG_AI 1 DWORD dwBoardID USHORT usChanConfig USHORT usGainCtrMode USHORT usPolarity USHORT usDasGain USHORT usNumExpChan USHORT usCjcChannel DAUGHTERSET Daughter MAX_DAUGHTER_NUM DEVCONFIG_AI FAR LPDEVCONFIG_AI DEVCONFIG_AI is used by DRV_AIGetConfig function Member Description Name Direction Type Range Description dwBoardiD input double word Refer to Driver H board ID code usChanConfig input unsigned short 0 single ended Analog input 1 differential mode usGainCtrMode unsigned short 1 by jumper 0 programmable usPolarity unsigned short 0 bipolar
160. needs two buffers to store the data The data before the watchdog is triggered including the triggering data is stored in the first buffer The data after the watchdog is triggered is stored in the second buffer These modes can be combined in the cyclic mode The relationship is as follows SB ff A Buffer B Transfer Mode Pre trigger circular buffer DMA or Interrupt Post trigger circular buffer or not used DMA or Interrupt linear buffer specified by cyclic mode Position trigger circular buffer circular buffer or DMA only linear buffer specified by cyclic mode Table 4 4 Watchdog Triggering Relationships Parameters CondList Type a Pointer to Unsigned Short Array Size 4 bytes The CondList parameter is a pointer to the condition array It specifies the triggering mode s for the scanning channel s The triggering modes include free run 0 pre trigger 1 post trigger 2 and position trigger 3 LevelList Type a pointer to TRIGLEVEL Structure Array Size 4 bytes The LevelList parameter is a pointer to the level array It specifies low and high limits for the scanning channel s Chapter 4 Function Overview 89 Note The TRIGLEVEL data structure is defined as below typedef struct tagTRIGLEVEL FLOAT fLow FLOAT fHigh TRIGLEVEL 90 Advantech DLL Drivers User s Manual Call Flow Channel Gain Count Cyclic CondList LevelList DRV_FAIWatchdogConfig DRV_F
161. nel data acquisition operation with DMA and stores its input in an array and the gain codes for the scan channels Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpFAIDmaScanStart Input Output long pointer to default the storage address for PT_FAIDmaScaStart TrigSrc SampleRate NumChans StartChan GainList buffer count Table 5 81 DRV_FAlDmaScanStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if buffer NULL or GainList NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidGain if gain code is incorrect 6 InvalidChannel if chan is out of range 7 InvalidCountNumber have these conditions count is zero count is not even counter is less than 2048 When you do analog input with DMA transfer conversion number must be bigger than 2048 The size of data must be bigger than PAGE_SIZE 4K 8 IllegalSpeed if SampleRate is out of range 9 InvalidEventCount if EventCount is zero 10 ChanConflict if interrupt channel is conflict 11 OpenEventFailed if event name opens failure 12 KelnsufficientResources if resource is conflict with another driver 13 KeConInterruptFailure if connects interrupt failure 228 Advantech DLL Drivers User s Manual DRV_FAlTransfer status DRV_FAITransfer DriverHandle lpFAITransfer
162. nge Description DRV_DeviceOpen Table 5 84 DRV_FAIStop Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL Chapter 5 Functions Reference 231 DRV_FAlDualDmaStart status DRV_FAIDualDmaStart DriverHandle lpFAIDualDmaStart Purpose Initiates an asynchronous single channel data acquisition operation with DMA and stores its input in an array Parameters oe ae oe so 8 Lange _ L_ _Peseription sr DRV_DeviceOpen ce PT_FAlDualDmaStart TrigSrc SampleRate chan gain BufferA BufferB count Table 5 85 DRV_FAlDualDmaStart Parameter Table 232 Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if BufferA NULL or BuferB NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidGain if gain code is incorrect 6 InvalidChannel if chan is out of range 7 InvalidDmaChannel if DMA channel isn t set to dual DMA mode in device installation utility 8 InvalidCountNumber have these conditions count is zero count is not even counter is less than 2048 When you do analog input with DMA transfer conversion number must be bigger than 2048 The size of data must be bigger than PAGE_SIZE 4K 9 IllegalSpeed if SampleRate is out of range 10 InvalidEventCount if EventCount is zero 11 ChanConflict if interrupt channel is conflict 12 OpenEventFailed if event name o
163. ngle buffer 1 buffer B stopped Output long pointer to 0 1 indicates the unsigned shori operation is complete 1 or incomplete 0 retrieved long pointer to 0 65536 conversion count unsigned short stored in the buffer overrun Output long pointer to 0 1 indicates the unsigned shor data in the buffer is overrun for cyclic mode HalfReady long pointer to 0 1 2 indicates the unsigned short data in the half buffer is full not ready 0 first half 1 second Table 5 162 PT_FAlCheck Member Description Chapter 5 Functions Reference 313 PT_FAIWatchdogConfig typedef struct tagPT_FAIWatchdogConfig USHORT USHORT USHORT USHORT far TrigMode NumChans StartChan GainList USHORT far CondList TRIGLEVEL far LevelList PT_FAIWatchdogConfig FAR LPT_FAIWatchdogConfig PT_FAIWathchdogConfig is used by DRV_FATWatchdogConfig function Member Description Direction Type Description NumChans StartChan Input unsigned short unsigned short unsigned short 0 n n depends on the available channels on 0 n n depends on hardware iggering mode number of channels start channel of the scan channel GainList CondList long pointer to unsigned short array with NumChans entries long pointer to unsigned short array with NumChans entries depends on input range on hardware 0 1 2 3 4 gain code array for the scan channel condition array to specify th
164. ngle buffer 1 buffer B stopped Output long pointer to indicates the operation is complete unsigned short Or incomplete 0 CurrentCount Output long pointer to current output count unsigned short Overrun Output Long pointer to Indicates the overrun state unsigned short overrun 1 HalfReady long pointer to indicates the data in the next half unsigned short buffer is available for new data not ready 0 first half 1 second half Table 5 171 PT_FAOCheck Member Description 322 Advantech DLL Drivers User s Manual PT_EnableEvent typedef struct tagPT_EnableEvent 1 USHORT EventType USHORT Enabled USHORT Count PT_EnableEvent FAR LPT_EnableEvent PT_EnableEvent is used by DRV_EnableEvent function Member dect a Eer default Enabled ET unsigned short_ 0 or 1 Enabled 1 or Disabled 0 Count Input unsigned short default number of interrupt count will be send event Table 5 172 PT_EnableEvent Member Description Chapter 5 Functions Reference 323 PT_CheckEvent typedef struct tagPT_CheckEvent 1 USHORT far EventType DWORD Milliseconds PT_CheckEvent FAR LPT_CheckEvent PT_CheckEvent is used by DRV_CheckEvent function Member Description Name Direction Type Range Description EventType Output pointer to type of event Return event type from driver unsigned please reference EnableEvent short parameter Milliseconds DWORD 0 65536 Time out interval in mill
165. niccnicnnnonanocanananananananno 264 PT_AlScale Member Description cceceeceeseeeeeeeeeeeeseenesereeseeeeeeeneeeaes 265 PT_AlVoltageln Member Description 00 0 0 eee eee eeee eee eeeeeeneeeeeeee 266 PT_AlVoltagelnExp Member Description oonnonnnnnnnnnnnnnncccnananananananano 267 PT_MAIConfig Member Description ecceceeseseeeeeeeeeeeeteeeeeeeeeeeeneeaees 268 PT_MAIBinaryln Member Description eee cece eee tee eee eeeeeee 269 PT_MAIVoltageln Member Description 0 cee eee eee eeeeteeeeeees 270 PT_MAIVoltagelnExp Member Description 0 cece eee eeeeeeeeneees 271 PT_TCMuxRead Member Description c ccceeceecseceeeeeereeeeeeeeeereeeeens PT_AOConfig Member Description PT_AOBinaryOut Member Description PT_AOVoltageOut Member Description PT_AOScale Member Description PT_AOCurrentOut Member Description PT_DioSetPortMode Member Description e seceeceeseeteeereteeeneeeeees PT_DioGetConfig Member Description ecceceeeceeceeeeeeeeeeeeeeeeeenreaeeeee PT_DioReadPortByte Member Description PT_DioWritePortByte Member Description eee eee ceeeeeeeees PT_DioReadBit Member Description oonoccnncnnnnonocinoncnnacanananancnananancono PT_DioWriteBit Member Description PT_DioGetCurrentDOByte Member Description Preface xxi Table 5 135 Table 5 136 Table 5 137 Table 5 138 Table 5 139 Table 5 140 Table 5 141 Tab
166. nland China American Advantech Corporation 750 East Arques Avenue Sunnyvale CA 94086 Tel 408 245 6678 Fax 408 245 5678 E mail AInfo advantech com Advantech Co LTD Ath Floor 108 3 Min Chuan Road Shing Tien City Taipei County Taiwan ROC Tel 886 2 2218 4567 Fax 886 2 2218 1989 E mail ASupport advantech com tw Advantech Germany Karlsruherstr 11 1 D 70771 Leinf Echterdingen Germany Tel 49 0 711 797 333 60 Fax 49 0 711 797 333 85 Advantech Italy Via Don Verderio 4 B 20060 Cassina de Pecchi MI Italy Tel 39 2 95343054 Fax 39 2 95343067 Beijing office No 7 6th Street Shang Di Zone Haidian District 100085 Beijing China Tel 86 10 62984345 47 62986314 17 Fax 86 1 62984341 42 Shanghai office Room 701 7th Floor Hua Fu Building A 585 Long Hua W Road 200232 Shanghai China Tel 86 21 64696831 64697910 Fax 86 21 64696834 iv Advantech DLL Drivers User s Manual Limited Warranty Advantech Corporation does not warrant that the 32 bit DLL Drivers software package will function properly in every hardware software environment Advantech Corporation makes no representation or warranties of any kinds whatsoever with respect to the contents of this manual and specifically disclaims any implied warranties or fitness for any particular purpose Advantech Corporation shall not be held liable for errors in this manual or for incidental or consequential damages in co
167. nnection with the use of this manual or its contents Advantech Corporation reserves the right to revise this manual at any time without prior notice Preface About This Manual This manual contains the information you need to get started with the Advantech 32 bit DLL Drivers software package The DLL Drivers allow you to easily perform versatile I O operations through proper ties methods and events in programs developed with Microsoft Visual Basic Microsoft Visual C Delphi Borland C Builder and other programming languages and development environments This manual contains step by step instructions for building applica tions with the DLL Drivers You can modify these sample applications to suit your needs This manual does not show you how to solve every possible programming problem Specific questions should be directed to Advantech s application engineers To use this manual you should already be familiar with one of the supported programming environments and Windows 95 or Windows NT Organization of This Manual This user manual is divided into the following sections Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Drivers introduces the DLL Drivers and how they can be used in your applications to get the most out of Advantech s Data Acquisi tion and Control cards It also explains how to install the software Two additional utilities the Device Installation Utility DEVINST EXE and the Advantech Test Util
168. nsigned short Max number of alarm channel number of bits for A D converter depends on hardware depends on hardware usNumADByte usNumDABit unsigned short unsigned short A D channel width in bytes number of bits for D A converter depends on hardware depends on hardware usNumDAByte usNumGain unsigned short unsigned short D A channel width in bytes Max number of gain code depends on hardware depends on hardware glGainList array of GAINLIST depends on hardware Gain listing dwPermutation output double word hardware Table 5 104 DEVFEATURES Member Description Chapter 5 Functions Reference 253 254 Note Definition for dwPermutation member Bit 0 Software AI Bit 1 DMA AI Bit 2 Interrupt AI Bit 3 Condition AI Bit 4 Software AO Bit 5 DMA AO Bit 6 Interrupt AO Bit 7 Condition AO Bit 8 Software DI Bit 9 DMA DI Bit 10 Interrupt DI Bit 11 Condition DI Bit 12 Software DO Bit 13 DMA DO Bit 14 Interrupt DO Bit 15 Condition DO Bit 16 High Gain Bit 17 Auto Channel Scan Bit 18 Pacer Trigger Bit 19 External Trigger Bit 20 Down Counter Bit 21 Dual DMA Bit 22 Monitoring Bit 23 QCounter Advantech DLL Drivers User s Manual AOSET typedef struct tagAOSET USHORT usAOSource FLOAT fAOMaxVol FLOAT fAOMinVol AOSET FAR LPAOSET AOSET Member Description Name Direction Type usAOSource input unsig
169. nt arra long pointer to unsigned short 320 Advantech DLL Drivers User s Manual the output range of the hardware default Table 5 169 PT_FAOScale Member Description Conversion count input float point values of data buffer binary values converted from the voltages PT_FAOLoad typedef struct tagPT_FAOLoad 1 USHORT ActiveBuf USHORT far DataBuffer USHORT start ULONG Counc PT_FAOLoad FAR LPT_FAOLoad PT_FAOLoad is used by DRV_FAOLoad function Member Description Range Description Name Direction ActiveBuf Input unsiged short 0 1 0 buffer A or single buffer 1 buffer B DataBuffer long pointer to default binary data array unsigned short start unsigned short 0 65535 start point of the source buffer to be copied to the data buffer Input unsigned short 1 65535 number of points to be transferred from the binary data arra Table 5 170 PT_FAOLoad Member Description Chapter 5 Functions Reference 321 PT_FAOCheck typedef struct tagPT_FAOCheck 1 USHORT far ActiveBuf USHORT far stopped ULONG far CurrentCount USHORT far overrun USHORT far HalfReady PT_FAOCheck FAR LPT_FAOCheck PT_FAOCheck is used by DRV_FAOCheck function Member Description Name Direction Type Description ActiveBuf Output long pointer to A return value from the function to unsigned short indicate which buffer is being filled during high speed data transfer 0 buffer A or si
170. nterStart Member Description PT_QCounterRead Member Description PT_TimerCountSetting Member Description ccccsseeeseeteeeteeeee 300 PT_DICounter Member Description ccccecceeeseeeeeeeeeeeeeeeeeeeeeeeeees 301 PT_CounterPWMSetting Member Description ececeeeeeereeteeeeeeres 302 PT_AlarmConfig Member Description ececeeseeeeeeeeteeneeeeeeeeeeeaeeaee 303 PT_AlarmEnable Member Description 0 ccceeeeeeeeeeteeeeeeeeeeeneeeeee 304 PT_AlarmCheck Member Description 0 ccccecceeseeeeeeeteeeeeeeteeeeeeees 305 PT_FAIIntStart Member Description ssec 306 PT_FAIIntScanStart Member Description seese 307 PT_FAIDmaStart Member Description ccccccceeceeeeeeeeeeeeeeeeeeeee 308 PT_FAIDmaScanStart Member Description eceeeeeeeeeseeeeeeeereeees 309 PT_FAIDualDmaStart Member Description seeen 310 PT_FAIDualDmaScanStart Member Description s e 311 PT_FAITransfer Member Description ooooocnncnniconinonocnnonncnancnancnanananann 312 PT_FAICheck Member Description scceecseceeseeeeseeeereeeeeereaeeereeetenes 313 PT_FAIWatchdogConfig Member Description c cecseceeseeeeeeeeereeees 314 PT_FAIIntWatchdogStart Member Description s es 315 PT_FAIDmaWathchdogStart Member Description eeeeseeeeees 316 PT_FAIWathchdogCheck Member Description ceseseeeeeereeneeeee 317 PT_FAOIntStart Member Description
171. ny development environments and programming languages including Microsoft Visual C Visual Basic and Borland Delphi Device drivers are software programs that specify the communications protocol to be used between a peripheral device and the computer Installing the drivers is necessary to successfully use Advantech I O products This documentation describes our drivers application programming interface API System Overview An overview of driver functions is shown in Figure 4 1 Registry Configuration File configuration data gt Applications function call Driver System Hardware input output data gt Figure 4 1 Driver System Overview Component Description Applications include user programs configuration utilities and other application software that use the driver The driver system prepares for communication between the host computer and Advantech s I O products Upon receiving a request from the application it provides the following services and functions N 2 Advantech DLL Drivers User s Manual 1 Device function initializes and configures your hardware and software Analog input converts single and multiple channel A D Analog output converts single D A Digital VO controls digital I O for the specified channel Port I O controls port I O D Uu FW N Counter performs event counting frequency measurement and pulse output 7 Temperature measurement measures temperature
172. o Board With DEVINST EXE 1 The same as step 1 in the Win32 Console example Step 2 Write Your Application 1 Go into the Start menu and click on the Visual Basic 5 0 icon in the Microsoft Visual Basic folder Figure 3 12 Starting Microsoft Visual Basic 5 0 Chapter 3 Tutorial 57 2 The Visual Basic 5 0 development environment will load as follows Figure 3 13 Select Standard EXE from the New Project Dialog Box 3 Select the Standard EXE icon and press the Open button A new project is created Then click on the Project Explorer in the View menu Add the declaration file Driver bas module by clicking on Add Module in the Project menu The Driver bas file is located in the Advantech Adsapi Include directory Name the adsoft frm form in the project 58 Advantech DLL Drivers User s Manual Figure 3 14 Adding the Declaration File driver bas 4 Design your form place a Label control on Form1 and enter Analog Input as its Caption field Then place a TextBox control on Form1 Switch to the Property Window and enter txtAlValue as 1ts Name property At last place a CommandButton control on the form Enter cmdRead as its Name property and enter Read as the Caption property Your form should look similar to the one shown below Figure 3 15 Form Design of Form1 5 Write your code for the cmdRead button as below Chapter 3 Tutorial 59 Private Sub cmdRead_Click Dim ErrCde As Long Error code Dim sz
173. o any selected A D range However the optimum range is the A D range that can handle the entire temperature range for each supported thermocouple type PCLD 8115 CJC Terminal boards The PCLD 8115 is used as a terminal board to allow the user to connect differential or single ended signals to a PCL 818HG The PCLD 8115 includes a CJC circuit that can be enabled or disabled Because the PCL 818HG provides amplification to a gain of 1000 the PCLD 8115 itself requires no gain settings If temperature mea surement is to be performed the CJC channel 0 must be enabled The PCLD 8115 must always be connected to the first eight A D channels 0 7 of the multi I O card Follow the procedure to perform thermocouple measurement 1 2 Connect the thermocouple s to the PCLD 8115 terminals Enable the CJC circuit and always set at channel 0 on the PCLD 8115 Of course the CJC channel cannot be used for any other purpose during temperature measurement Configure the base address and connection in the configuration dialog box of the device installation utility Select the input range 0 05 V to 0 05 V in your application for all thermocouple types When thermocouple type is selected the driver will perform the appropriate linearization for the selected thermocouple type with respect to any selected A D range However the optimum range is the A D range that can handle the entire temperature range for each supported thermo
174. oard is attached 4 TCExp8115Read return code 5 TCExp788Read return code 208 Advantech DLL Drivers User s Manual Note Using the PCLD 770 PCLD 779 or PCLD 789 for thermocouple measurement Thermocouple linearization is provided automatically by the driver if a temperature measurement operation is chosen in the application program The linearization is performed and the tempera ture acquired by the thermocouple mux card is available for control strategy use or display in degrees Celsius The conversion to units other than degrees C Fahrenheit Kelvin etc can be accomplished by use of a calculation scaling factor To perform thermocouple measurement 1 Properly configure the DAS card 2 Connect the thermocouple s to the terminals on the PCLD 770 779 789 889 3 Use a shielded ribbon cable to connect CN1 of the PCLD 770 779 789 889 to the analog input port on the DAS card in use 4 Use a ribbon cable to connect CN2 of the PCLD 770 779 789 to the digital output port on the DAS card in use 5 Select a proper input range or gain on the PCLD 770 779 789 for the type of thermocouple used as described in the PCLD 770 779 789 hardware manual K type 50 J type 100 T type 200 E type 50 R type 200 S type 200 B type 200 6 Select the desired input channel on the DAS card to correspond with each PCLD 770 779 789 by setting jumper block JP1 PCLD 770 JP16 PCLD 789 or JP2 PCLD 779 to a proper position Posi
175. on t have to use hardware specific register commands and it gives you a powerful programming API for use with a variety of program ming environments and languages Advantech DLL driver software supports the high speed functions that utilize DMA or interrupt for data acquisition This kind of data transfer is performed in the background It thus uses less CPU time and speeds the data transfer rate These functions are used to transfer large amounts of data at high rates The driver uses double buffering techniques for continuous uninterrupted transfer of large amounts of data The Advantech DLL driver also supports event functions It notifies your program by posting messages when events occur within the device You only have to take the necessary actions when receiving the messages without checking its status manually It is more efficient and reduces the program s complexity Advantech DLL Drivers User s Manual Programming Ermaronment Adwantech Application Sotbwar Wa Delphi YE Acwanbech Achelia Bortand E C Budde Advantech DLL Later Advantech Hardeware Figure 1 1 DLL Drivers Programming Environment and Hardware 1 1 1 How To Start Programming Advantech Hardware The following figure shows the steps to program with Advantech DLL driver software Chapter 1 Introduction to the 32 bit Windows 95 98 NT DLL Driver 3 Install Driver CD ROM then power off PC Plug in Hardware and power on PC Use configuration util
176. operations the data buffer is configured as a circular buffer The data acquisition board fills the circular buffer with data When the end of the buffer is reached the board returns to the beginning of the buffer and fills it with data again The process continues until it is interrupted by a hardware error or cleared by a function call Unlike single buffered operations double buffered operations reuse the same buffer and are therefore able to input an infinite number data points without requiring an infinite amount of memory However in order for double buffering to be useful there must be a means by which to access the data for updating storage and processing The driver logically divides the circular buffer into two equal halves By dividing the buffer into two halves the driver can coordinate user access to the data buffer with the data acquisition board The double buffered input operation begins when the data acquisition board starts writing data into the first half of the circular buffer After the board begins writing to the second half of the circular buffer and before the board writes to the first half of the circular buffer again the user needs to copy the data from the first half into the transfer buffer by calling a function The user can then store the data in the transfer block to disk or process it according to the needs of his application After the input board has filled the second half of the circular buffer the board r
177. orage n PT_MAIVoltag address for ein NumChan StartChan GainArray TrigMode and VoltageArray Table 5 29 DRV_MAIVoltagein Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidInputParam if GainArray or VoltageArray NULL 4 AlVoltageln return code 170 Advantech DLL Drivers User s Manual DRV_MAIVoltagelnExp status DRV_MAIVoltageInExp DriverHandle lpMAIVoltageInExp Purpose Reads an analog input channel with expansion board and returns the result scaled to a voltage in units of volts This function supports the expansion boards PCLD 770 779 789 789D 788 Parameters Name Direction Range Description DriverHandle Input default assigned by DRV_DeviceOpen IpMAlVoltagel Input Output long pointer to default the storage n PT_MAIVoltageln address for NumChan DasChanArray DasGainArray ExpChanArray and Table 5 30 DRV_MAIVoltagelnExp Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidInputParam if DasChanArray DasGainArray or VoltageArray NULL 4 AlVoltagelnExp return code Note If there is no expansion boards connecting to the corresponding DAS channel or ExpChanArray is equal to NULL it will call MATVoltageIn function The scan channels must be contiguous however Chapter 5 Functions Reference 171 DRV_EnableEventEx status DRV_EnableEventEx
178. ort or memory address which has not been defined in the Registry for this device Chapter 5 Functions Reference 191 DRV_ReadPortWord status DRV_ReadPortWord DriverHandle lpReadPortWord Purpose Reads a 16 bit data from the specified I O port The port address is an T O port address on the PC Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpReadPortWord Input Output long pointer to default the storage address PT_ReadPortWord for port and WordData Table 5 51 DRV_ReadPortWord Parameter Table Return 1 2 3 SUCCESS if successful InvalidDriverHandle if DriverHandle NULL KelnvalidHandleValue if the kernel mode driver cannot be opened KeFileNotFound if an attempt was made to open kernel mode driver while the driver was not running KeTooManyCmds if the logic commands have created an apparent endless loop for kernel mode driver KelnvalidHandle if the handle for kernel mode driver is not a valid handle KelnvalidParameter if the parameter passed to kernel mode driver is incorrect KeNoAccess if an attempt to access a port or memory address which has not been defined in the Registry for this device 192 Advantech DLL Drivers User s Manual DRV_CounterEventStart status DRV_CounterEventStart DriverHandle lpCounterEventStart Purpose Configures the specified counter for an event counting operation and starts the counte
179. our new Advantech equipment is destined for the laboratory or the factory floor you can be assured that your product will provide the reliability and ease of operation for which the name Advantech has come to be known Your satisfaction is our primary concern Here is a guide to Advantech s customer services To ensure you get the full benefit of our services please follow the instructions below carefully Technical Support We want you to get the maximum performance from your products So if you run into technical difficulties we are here to help For the most frequently asked questions you can easily find answers in your product documentation These answers are normally a lot more detailed than the ones we can give over the phone So please consult this manual first If you still cannot find the answer gather all the information or questions that apply to your problem and with the product close at hand call your dealer Our dealers are well trained and ready to give you the support you need to get the most from your Advantech products In fact most problems reported are minor and are able to be easily solved over the phone In addition free technical support is available from Advantech engineers every business day We are always ready to give advice on application requirements or specific information on the installation and operation of any of our products Preface iii Technical Suppport Offices USA Asia Europe Mai
180. ows Control Panel Add Remove Programs Dialog Box Installation Completes ansis tieven A e aba Figure 1 14 Click OK When the Uninstallation Completes oooonnoicccnnnnncnccnnnecncnnno Figure 1 15 Installing a Device in the Device Installation Utility Figure 1 16 I O Device Installation WindOW ceceeceeseeseeeeeeeeeeeeeeeeeeeeeeaeseeeeneeeaeeaees Figure 1 17 Existing Device Found csccsessescescsesesscessocsestersescseessoesearseseseneesseeeeees Figure 1 18 Installed Device Configuration Window Figure 1 19 Newly Installed Device o o onoconinnnnnonoccnicnnananacaninncnrn cano nan cnn anna car cnn cnn Figure 1 20 Advantech Device Test Utility Analog input tab 0 0 eee Figure 1 21 Advantech Device Test Utility Figure 1 22 Advantech Device Test Utility Analog output tab eh Digital input tab 0 0 eee eee Figure 1 23 Advantech Device Test Utility Digital output tab ee Figure 1 24 Advantech Device Test Utility Counter tab Figure 2 1 Figure 2 2 Figure 2 3 Figure 2 4 Figure 2 5 Figure 2 6 Figure 2 7 Figure 2 8 Figure 2 9 Creating a New Visual C Application ceceeeseeeeeeeeteeteeeeeeeeeeeeneeatees Defining the Application Type and Assigning a Project Directory 23 Including the DLL Drivers Header File in Your Project sit Including Driver h DLL Driver Header File in the Project Directory 25 Dri
181. pens failure 13 KeInsufficientResources if resource is conflict with another driver 14 KeConInterruptFailure if connects interrupt failure Advantech DLL Drivers User s Manual DRV_FAlDualDmaScansStart status DRV_FAIDualDmaScanStart DriverHandle lpFAIDualDmaScanStart Purpose Initiates an asynchronous mutiple channel data acquisition operation with DMA and stores its input in an array and the gain codes for the scan channels Parameters Direction Type DriverHandle Input long default assigned by DRV_DeviceOpen LpFAlDualDma Input Output long pointer to default the storage address ScanStart PT_FAIDualDma for TrigSrc ScanStart SampleRate NumChan StartChan GainList BufferA BufferB count Table 5 86 DRV_FAlDualDmaScanStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if BufferA NULL BufferB NULL or GainList NULL BoardIDNotSupported if function doesn t have support in driver InvalidGain if gain code is incorrect InvalidChannel if chan is out of range InvalidDmaChannel if DMA channel isn t set to dual DMA mode in device installation utility PEO 8 InvalidCountNumber have these conditions count is zero count is not even counter is less than 2048 When you do analog input with DMA transfer conversion number must be bigger than 2048 The size of data must be bigger than PAGE_SIZE 4K 9
182. ples V B dipattn Advantech Adsapi Examples Delphi dipattn Advantech Adsapi Examples V C dipattn Function Description Demo program for digital input function with pattern match 4 5 2 Digital Output Functions The digital output functions perform digital output operations Call Flow You simply call the DRV_DioWriteBit function to set the state to the specified bit Port Bit DRV_DioWriteBit Figure 4 16 Digital Output Function Call Flow Besides the DRV_DioWriteBit function the DLL drivers also provide the DRV_DioWritePortByte function to write a byte value to a port In addition the DRV_DioGetCurrentDOBit and DRV_DioGetCurrentDOByte functions are used to retrieve current output status Advantech DLL Drivers User s Manual 4 6 Examples Directory Advantech Adsapi Examples Console digout Advantech Adsapi Examples VB digout Advantech Adsapi Examples Delphi digout Advantech Adsapi Examples V C digout Function Description Demo program for digital output function Counter Function Group The counter function group includes three kinds of operations event counting pulse output and frequency measurement 4 6 1 Event Counting 4 6 1 1 General Counter Intel 8254 or AMD 9513A The event counting functions perform the counter operation Chapter 4 Function Overview 107 Call Flow DRV_CounterEventStart DRV_CounterEventRead Another Reading DRV_CounterReset
183. ption chan Input unsigned short the channel for alarm monitoring latching 1 disable 0 Table 5 153 PT_AlarmEnable Member Description 304 Advantech DLL Drivers User s Manual PT_AlarmCheck typedef struct tagPT_AlarmCheck 1 USHORT chan USHORT far LoState USHORT far HiState PT_AlarmCheck FAR LPT_AlarmCheck PT_AlarmCheck is used by DRV_AlarmCheck function Member Description Name Direction Type Description chan Input unsigned short the channel for alarm monitoring unsigned short the low alarm limit RE BER Tt long pointer to the current state of unsigned short the high alarm limit Table 5 154 PT_AlarmCheck Member Description Chapter 5 Functions Reference 305 PT_FAlintStart typedef struct tagPT_FAIIntStart Name TrigSrc SampleRate 1 USHORT DWORD USHORT USHORT USHORT far ULONG USHORT USHORT Trigro SampleRate chan gain buffer count cyclic IntrCount PT_FAIIntStart FAR LPT_FAIIntStart PT_FAIIntStart is used by DRV_FAIIntStart function Member Description Direction Input Input Type unsigned short floating point unsigned short Range 0 1 depends on the pacer on hardware 0 n n depends on hardware Description triggering source external 1 internal 0 sampling rate in second the sampled channel unsigned short long pointer to unsigned short array depends on input range on hardware depends on I O
184. put output DRV_DioSetPortMode DRV_DioWritePortByte DRV_DioWriteBit DRV_DioGetCurrentDOByte Temperature DRV_TCMuxRead High speed functions DRV_CheckEvent DRV_EnableEvent Table 5 7 DLL Driver Functions Supported by PCI 1720 146 Advantech DLL Drivers User s Manual Device Function PCL PCL PCL PCL 734 735 833 720 721 MIC 1723 2750 2752 2760 Device functions y DRV_DeviceGetFeatures Y DRV_WritePortWord DRV_ReadPortWord Digital input output DRV_DioGetConfig DRV_DioSetPortMode DRV_DioReadPortByte DRV_DioWritePortByte DRV_DioReadBit DRV_DioWriteBit DRV_DioGetCurrentDOByte DRV_DioGetCurrentDOBit Counter functions DRV_CounterEventStart DRV_CounterEventRead DRV_CounterFreqStart DRV_CounterFreqRead DRV_CounterPulseStart DRV_CounterReset DRV_QCounterConfig DRV_QCounterConfigSys DRV_QCounterStar DRV_QCounterRead DRV_CounterPWMSetting High speed functions DRV_TimerCountSetting DRV_EnableEventEx DRV_FDITransfer e L e dE e ad a Leje ea AA 2 2 2 2 2 2 2 i HH ES ejeje e E a 2 a Pa eje L L 2 ae 2 ele ejeje jeje 2 ejeje e can an a 2l2lelezie ETA 221212 L eje jejeje 2 a a f paa L 2 2 2l2 22 Leje Table 5 8 DLL Driver Function Support by Advantech Hardware Chapter 5
185. r Parameters A eps pe E l default assigned by DRV_DeviceOpen Li pa SIMA pointer to default the storage address for PT_CounterEventStart countger and GateMode Table 5 52 DRV_CounterEventStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Operations 1 The programming method depends on the counter timer chip on the board There are two kinds of chips that are used in DASCards Intel 8254 and AMD Am9513A For Am9513A counter channels 0 9 can all function as a rising edge event counter Connect your external event generator to the clock input of the desired counter If hardware gating in which the counter may be started by a separate external hardware input is desired choose a gating type and use an external device to trigger the gate input of the counter 2 Both of the above counter timer chips are 16 bits However the function supports a 32 bit counter i e it counts up 2 It will check if the counter is overflowing and converts it to 32 bits by calculation Chapter 5 Functions Reference 193 3 Intel 8254 hardware counter needs 2 cycle time to reload counter setting so counter program has to wait for 2 external trigger cycle time to read correct counter value At the first time of calling DRV_CounterEventStart Intel 8254 h
186. ring Dual DMA trigger ing utilities two DMA channels for data transfer It depends on hardware PCL 1800 supports dual DMA triggering DMA Buffer Because of the AT and Micro Channel bus architectures the DMA region is limited to lie in the 1 MB of physical memory and must be continuous and fixed The Windows API does not support this kind of buffer allocation Therefore driver provides two function calls DRV_AllocateDMABuffer and DRV_FreeDMA Buffer to allocate DMA buffer and free the allocated DMA buffer Note The DMA buffer size must exceed 4K bytes Call Flow The following shows the call flow for single channel reading Advantech DLL Drivers User s Manual l Channel Gain SampleRate Count Cyclic DRV_AllocateDMA Buffer DRV_FAIDmaStart DRV_FAICheck Buffer Ful complete Yes DRV_FAITransfer No DRV_FAIStop Yes DRV_FreeDMABuffer Figure 4 7 Single Channel Reading Call Flow Chapter 4 Function Overview 87 This is almost the same as interrupt triggering except the DRV_FAIIntStart function starts the analog input operation with DMA triggering In addition it uses the DRV_AllocateDMA Buffer function to allocate the DMA buffer before starting the DMA operation and uses DRV_FreeDMA Buffer to free the DMA buffer after finishing the DMA operation Note Besides single data reading the driver also provides the DRV_FAIDmaScanStart function for multiple channel reading For this kind of opera
187. rnc nan cnnn cnn 89 Table 4 5 Supported Event Types ss cc 129 Table 5 1 Driver File Descriptions comoomommmeonmmmsrmeosmsarccereess 140 Table 5 2 DLL Functions Supported By Advantech Hardware ooooocccccnccnicccincccncccnnos 141 Table 5 3 DLL Functions Supported By Advantech Hardware s es 142 Table 5 4 DLL Driver Functions Supported By PCI 1710 1713 1711 1731 oe eee 143 Table 5 5 DLL Driver Functions Supported By PCI 1710 1713 1711 1731 oo eee 144 Table 5 6 DLL Driver Functions Supported by Advantech Hardware 145 Table 5 7 DLL Driver Functions Supported by PCI 1720 Table 5 8 DLL Driver Function Support by Advantech Hardware seses 147 Table 5 9 DLL Driver Support for PCI 1753 0 ceeeeeeeeeeceeeeeeeeeeeeeeeeeaeeeeseeeeaeeaeeeeees 148 Table 5 10 DLL Driver Support for Advantech Hardware ccccsccceeeeeseteeeeeeeees 149 Table 5 11 DLL Driver Support for Advantech Hardware ccseeeceeseeseeeeereteeenteees 150 Table 5 12 General form of every Advantech DLL Driver Function 008 151 Table 5 13 DRV_SelectDevice Parameter Table ooooccnccccnocccncoonnnoooncnononnnononanonnna 152 Table 5 14 DRV_DeviceGetNumOfList Parameter Table coooocococccccocacooocacononnnnnos 153 Table 5 15 DRV_DeviceGetList Parameter Table 0 cecccscseeeeeeeeeeeeeeeeeeeeeeeeenees 154 Table 5 16 DRV_DeviceGetSubList Parameter Table ooooonncccncccccnccoccconoonccnonnnonona 1
188. rt number specifies which bit s of data should be sent to the digital output port and which bits remain unchanged new digital logic state Table 5 131 PT_DioWritePortByte Member Description 282 Advantech DLL Drivers User s Manual PT_DioReadBit typedef struct tagPT_DioReadBit 1 USHORT port USHORT bit USHORT far state PT_DioReadBit FAR LPT_DioReadBit PT_DioReadBit is used by DRV_DioReadBit function Member Description Name Direction _ Type Range Description Input unsigned short 0 n n depends the digital port on hardware number bit Impue unsigned short 0 7 the bit number Output long pointer to Oor1 bit data read unsigned short from the specified port Table 5 132 PT_DioReadBit Member Description Chapter 5 Functions Reference 283 PT_DioWriteBit typedef struct tagPT_DioWriteBit 1 USHORT port USHORT bit USHORT state PT_DioWriteBit FAR LPT_DioWriteBit PT_DioWriteBit is used by DRV_DioWriteBit function Member Description Name Direction Type Range Description ees eee unsigned short 0 n n depends the digital port on hardware number Bit Input unsigned short__ 0 7 the bit number Seer Tp T unsigned short default new digital logic state Table 5 133 PT_DioWriteBit Member Description 284 Advantech DLL Drivers User s Manual PT_DioGetCurrentDOByte typedef struct tagPT_DioGetCurrentDOByte 1 USHORT port USHORT far valu
189. s It uses an efficient polling method to check the event Your CPU can then simultaneously perform other functions EnableEventEx This function is used in the PCI 1760 It configures and starts the event type for pattern match digital filter counter match counter overflow or change of state Call Flow Event call flow for single channel analog input with interrupt trigger ing 130 Advantech DLL Drivers User s Manual Single channel DRV_EnableEvent DRV_FAIIniStart DRV_CheckEvent Buffer Ful complete Yes DRV_FAITransfer No DRV_FAIStop Figure 4 26 Single Channel Analog Input with Interrupt Triggering Yes Chapter 4 Function Overview 131 Multiple Channel DRV_EnableEvent DRV_FAlIntScanStart DRV_CheckEvent Yes DRV_FAITransfer Repeated No DRV_FAIStop Figure 4 27 Multiple Channel Analog Input with Interrupt Triggering 132 Advantech DLL Drivers User s Manual DRV_AlarmConfig DRV_AlarmEnable DRV_AlarmCheck DRV_AlarmReset Figure 4 28 Multiple Channel Analog Input with DMA Triggering Chapter 4 Function Overview 133 l Conditional conversion Yes Yes y DRV_FAITransfer Repeated No y DRV_FAIStop Figure 4 29 Analog Input with Interrupt and Watchdog Triggering 134 Advantech DLL Drivers User s Manual i Conditional conversion A A DRV_FAIWatchdogConfig See DRV_AllocateDMABuffer e DRV_EnableEvent
190. s deseisetesceseesebtedeteededetssveiedesateodes 294 PT_CounterPulseStart oooncncncnnnninnninininininininininanananananaanannnnos 295 PT QCounterConfig c ciioccocinnoancr cristian siena 296 PT_QCounterConfigSys o occooconocncncnonononncconoconcconccnnncnnncnancnnnoo 297 Advantech DLL Drivers User s Manual PT OCounterStart ici aliadas 298 PTOCommterRedd aii aceon 299 PT_TimerCountSetting occcccccnonnnonononononoconannnnnannnnn nono nonnccnna ns 300 PE DIC OUMER Laa dia daa cidade 301 PT_CounterPWMSetting ccooccooccnocnnoncnoncconaconcconanancona nono ncnnnoos 302 PY Alarm one cocotero tenacidad did nn 303 PT AlarmEnable ies iii saseaessabsrcvoasascsasesanasscatavevasancess 304 PT AlarmCheck ii ii a talones 305 PT FATI Static doa 306 PT_FAT Dt canStart nerian nnise a a Ea is is 307 PT FATD Mostar a a ta ts data as 308 PT_FAIDmaScanStart cccccnnnnnnnnnninininanananananananananon cn nano nononnnnns 309 PT_FAIDualDmaStart nennen rma n 310 PT_FAIDualDmaScanStart cocccnnnnnnnananananananannananonononcnnononanonos 311 PT BAU ran ster ics ssc52 c0sdeccsihs ccecbsbsacseavadeces vabesanebanaratetagerastagess 312 PLE EATChec a a 313 PT_FATWatchdogConfig cococcnocccoccnoncnonoconocnnanaccnnnncnancnnncnnnoos 314 PT_FAlIntWatchdogStalt oooconncnnocnnocononcconoconanaccnnn nono nonnncnnnnns 315 PT_FAIDmaWathchdogStart ocoonccnnocnococococoncconncanncnnnnnnncnnnoo 316 PT_FAIlWathchdogCheck ooooconocnnoconocococonoconoccnnncnnnnonnnonnnoo
191. s used by DRV_FAIDmaStart function Member Description Name Direction Type Description TrigSrc Input unsigned short triggering source external 1 internal 0 SampleRate floating point depends on the sampling rate in pacer on second hardware chan Input unsigned short 0 n n depends the sampled on hardware channel gain Input unsigned short depends on input gain code range on hardware buffer Output long pointer to depends on I O data buffer unsigned short register format arra on hardware unsigned long 1 65536 conversion count Table 5 157 PT_FAlDmaStart Member Description 308 Advantech DLL Drivers User s Manual PT_FAlDmaScansStart typedef struct tagPT_FAIDmaScanStart 1 USHORT DWORD USHORT USHORT USHORT USHORT ULONG TrigSrc SampleRate NumChans StartChan far GainList far buffer count PT_FAIDmaScanStart FAR LPT_FAIDmaScanStart PT_FAIDmaScanStart is used by DRV_FAIDmaScanStart function Member Description Name TrigSrc SampleRate Direction Input Type unsigned short floating point triggering eae external internal He depends on the sampling rate in pacer on second hardware NumChans StartChan GainList unsigned short unsigned short long pointer to unsigned short array with NumChans entries number of channels start channel of the scan channel gain code array for the scan channel 0 n n depends on the
192. scription counter GatePeriod Input unsigned short gating period in seconds for AMD Am9513A GateMode Input unsigned short gating mode to be used for AMD Am9513A Table 5 142 PT_CounterFreqStart Member Description Chapter 5 Functions Reference 293 PT_CounterFreqRead typedef struct tagPT_CounterFreqRead USHORT counter FLOAT far freq PT_CounterFregRead FAR LPT_CounterFreqRead PT_CounterFreqRead is used by DRV_CounterFreqRead function Member Description Name Direction Type Description counter Input unsignedshortt counternumber Output long pointer to current frequency floating point returned Table 5 143 PT_CounterFreqRead Member Description 294 Advantech DLL Drivers User s Manual PT_CounterPulseStart typedef struct tagPT_CounterPulseStart USHORT counter FLOAT period FLOAT UpCycle USHORT GateMode PT_CounterPulseStart FAR LPT_CounterPulseStart PT_CounterPulseStart is used by DRV_CounterPulseStart function Member Description Type Description Counter Input unsigned short counter number Period floating point total period in seconds UpCycle floating point the first 1 2 cycle length in seconds for AMD Am9513A GateMode Input unsigned short gating modeto be usedior AMD Am9513A Table 5 144 PT_CounterPulseStart Member Description Chapter 5 Functions Reference 295 PT_QCounterConfig typedef struct tagPT_QCounterCon
193. se output functions perform the pulse output operation Call Flow y DRV_CounterPulseStart y DRV_CounterReset v Figure 4 20 Pulse Output General Output Function Call Flow 114 Advantech DLL Drivers User s Manual The DRV_CounterPulseStart function starts the pulse output opera tion It then runs in the background When it is complete you can use the DRV_CounterReset function to stop the pulse output operation Notice a The programming method depends on the counter timer chip on the board There are two kinds of chips that are used in DA amp C cards Intel 8254 and AMD Am9513A b For the AMD Am9513A chip counter channels 0 9 can all function as an arbitrary duty cycle pulse generator You should select an on board frequency F1 F5 source that is closest to the desired output frequency for pulse output The pulse waveform will then be generated on the output pin of the counter used If hardware gating in which the counter may be started by a separate external hardware input is desired choose a gating type and use an external device to trigger the gate input of the counter c The Intel 8254 chip always generates a square wave Examples Directory Advantech Adsapi Examples Console pulse Advantech Adsapi Examples VB pulse Advantech Adsapi Examples Delphi pulse Advantech Adsapi Examples VC pulse Function Description Demo program for the pulse output function Chapter 4 Funct
194. status DRV_FreeDMABuf fer DriverHandle buffer Purpose Releases the buffer allocated by AllocateDMABuffer Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen bufter____ Input Output__ longpointer____ default bufferaddress___ Table 5 92 DRV_FreeDMABuffer Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 240 Advantech DLL Drivers User s Manual DRV_FAOIntStart status DRV_FAOIntStart DriverHandle lpFAOIntStart Purpose Initiates an asynchronous analog output operation with interrupt transfer Parameters Name Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen LpFAOIntStart Input Output long pointer to default the storage address PT_FAOIntStart for StartChan StopChan buffer count cyclic Table 5 93 DRV_FAOIntStart Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 InvalidWindowsHandle if buffer NULL 4 BoardIDNotSupported if function doesn t have support in driver 5 InvalidChannel if chan is out of range 6 InvalidCountNumber have these conditions count is zero or count is not even 7 MlegalSpeed if SampleRate is out of range 8 InvalidEventCount if EventCount is zero 9 ChanConflict if interrupt channel is conflict 10 OpenEventFailed if event name opens failure
195. t Message Functions section for further details Parameters Cyclic Type Unsigned Short Size 2 bytes To acquire waveform data the analog input function group provides single shot non cyclic and continuous acquisition cyclic You can set the Cyclic parameter to 1 for continuous operation or 0 for one shot operation SampleRate Type Floating Point Size 4 bytes The SampleRate parameter specifies the rate for sampling one data in Hz The driver uses it to program the on board pacer Count Type Unsigned Long Size 4 bytes The Count parameter specifies the number of samples acquired in a one shot acquisition or continuous acquisition The driver allocates the same size of the buffer to store the acquired data Note The Count parameter ranges from 1 to 65535 For continuous acquisition it affects the sampling rate If the sampling rate is higher the Count parameter should be larger Chapter 4 Function Overview 83 84 4 3 2 2 Interrupt Triggering There are two kinds of interrupt operations for analog input One generates a hardware interrupt for each conversion The other one keeps the conversion data in FIFO then generates a hardware interrupt for half full of FIFO or full of FIFO It depends on the hardware Parameters IntrCount Type Unsigned Short Size 2 bytes The IntrCount parameter determines how many conversions generate a hardware interrupt It depends on the hardware Call Flow The following s
196. t Visual Basic ooommss 30 2 4 Using Borland Delphi o ocooooccomocsossscs 36 2 5 Using Borland C or Borland C Builder 42 2 6 Advantech DLL Drivers Programming Considerations 43 2 6 1 Buffer Allocati0N oooooononocnncnooocnnononcnnononnnnccononnncnnnnss 43 26 2 String Passing swe sce diria 43 2 6 3 Parameter Passing ooooonocnnoncnoccnnnconncnnnnonononaconnccnnaconecnos 43 viii Advantech DLL Drivers User s Manual Chapter 3 Tutorial cococosrimomiin cita 45 3 1 DLL Driver Introductory Tutorial oooomms 46 3 2 DLL Driver Tutorial for Win32 Console Program 46 Step 1 Add Demo Board With DEVINST EXE ee 46 Step 2 Write Your Application with DLL Driver 49 Step 3 Test Your Program siene esnai aiie iN iaaii 55 3 3 DLL Driver Tutorial for Visual Basic Application 57 Step 1 Add Demo Board With DEVINST EXE oee 57 Step 2 Write Your Application ooooonnccnnccnncnnocnnoncconaconanancnnnos 57 Step 3 Test Your Program scaip renni enia a 61 3 4 DLL Driver Tutorial for Delphi Applications 62 Step 1 Add Demo Board With DEVINST EXE ee 62 Step 2 Write Your Application ooooonnccnnconnccnocnnoncnonaconananannnos 62 Step 3 Test Your Program ooooocnoccconcconanonnnonnnoncnnoconacnncnnncnnn nos 65 3 5 Advantech DLL Driver Example Programs 000 66 3 5 1 Analog Input With Software Triggering 0 0 66 3 5 2 Multiple C
197. tConfig Retrieve the serial port settings e g port number baud rate parity check etc COMWrite232 Write data to the specified serial port though the standard RS 232 protocol COMEscape Provide escape services Notice For this function group you don t need to call DRV_DeviceOpen and DRV_DeviceClose functions However you must link adscomm lib Examples Directory Advantech Adsapi Examples VC comm Function Description Demo program for communication function 4 11 Event Function Group 128 Some data acquisition operations run in the background such as analog input with DMA or interrupt triggering The DLL drivers provide two ways to check the status of data acquisition operation One is the polling method For example you can call the DRV_FAICheck function repeatedly to check the status of analog input with DMA triggering The other way is the event function group After you enable the event function the DLL driver will fire an event when some hardware interrupt occurs You do not have to poll the status by yourself Advantech DLL Drivers User s Manual EnableEvent First you have to use the EnableEvent function to configure and enable the event type There are three parameters for it Parameters Event Type Data type Unsigned short Size 2 bytes The Event Type specifies what kind of event will fire an event The DLL driver supports the following events
198. ter 5 Functions Reference 141 Function PCL 818 Series PCM 3718 H HG High speed functions DRV_FAlIntStart a 22 DRV_FAlDmaStart N DRV_FAlIntScanStart DRV_FAIDmaScanStart a ae DRV_FAIDualDmaStart e A PE an Ei EA lt lt 4 e2leiele ejeje je ejeje je DRV_FAlDualScanStart DRV_FAITransfer a e E a a a ejeje je a a DRV_FAICheck a a ue ee a a DRV_FAIIntWatchdogStart DRV_FAIDmaWatchdogStart a Fre DRV_FAlWatchdogCheck DRV_FAIStop a ie a a ed DRV_AllocateDMABuffer DRV_FreeDMABuffer DRV_FAOIntStart lt 2 2 2 2 E A REA lt 2 2 a oss DRV_FAODmaStart 2l2lejejl DRV_FAOLoad DRV_FAOScale DRV_FAOCheck DRV_FAOStop 2 2 2 DRV_CheckEvent DRV_CheckEvent Counter functions Leje 2 2 A a a EA 2 2 2 lt 2 2 lt 2 2 DRV_CounterEventStart DRV_CounterEventRead a DRV_CounterFregStart DRV_CounterFreqRead 2 2 DRV_CounterPulseStart a ae lt 2 2 2 2 2 2 ejeje je Ht DRV_CounterReset DRV_QCounterConfig DRV_QCounterConfigSys a a Leje ait ES EAA Ean ea PN Da EN EA eje jejejeje ejejejeje je ejejejeje je DRV_QCounterStart DRV_QcounterRead Leje 4 Table 5 3 DLL Functions Supported By Advantech Hardware 142 Advantech DLL Drivers User s Manual Pa Device Lie DRV_DeviceOpen
199. the operation of analog output with interrupt triggering Before you call it you must scale your voltage output data into binary data by the DRV_FAOScale function When the operation is running you can use the DRV_FAOCheck function to check the background status Meanwhile you can reload the output data by using the DRV_FAOScale and DRV_FAOLoad functions when the output is complete If you have scaled the output data to binary data you can skip the DRV_FAOScale function After all output operation is complete you can call DRV_FAOStop function to terminate the operation Examples Directory Advantech Adsapi Examples Console daint Advantech Adsapi Examples VB daint Advantech Adsapi Examples Delphi daint Advantech Adsapi Examples V C daint Function Description Demo program for analog output function with interrupt triggering 4 4 3 2 DMA Triggering Call Flow The call flow for analog output with DMA triggering is shown below Chapter 4 Function Overview 99 Channel SampleRate Cyclic TrigSrc Voltage Data l DRV_AllocateDmaBuffer C DRV_FAOScale A DRV_FAODmaStart e n DRV_FAOCheck NT No Output Status complete Yes A A DRV_FAOScale Yes Yes Y DRV_FAOLoad No DRV_FAOStop DRV_FreeDMABuffer Figure 4 12 DMA Triggering Function Call Flow 100 Advantech DLL Drivers User s Manual 4 5 The call flow is the same as for interrupt triggering except that the
200. tial or single ended signals to a PCL 818HG The PCLD 8115 includes a CJC circuit that can be enabled or disabled Because the PCL 818HG provides amplification to a gain of 1000 the PCLD 8115 itself requires no gain settings If temperature mea surement is to be performed the CJC channel 0 must be enabled The PCLD 8115 must always be connected to the first eight A D channels 0 7 of the multi I O card Using the PCLD 8115 for thermocouple measurement Thermocouple linearization is provided by the driver automatically if a temperature measurement operation is chosen in the application program The linearization is performed and the temperature acquired by the thermocouple mux card is available for control strategy use or display in degrees Celsius The conversion to units other than degrees C Fahrenheit Kelvin etc can be accomplished by use of a calcula tion scaling factor To perform thermocouple measurement 1 Properly configure the DAS card to be used 2 Connect the thermocouple s to the PCLD 8115 terminals 3 Enable the CJC circuit and always set at channel 0 on the PCLD 8115 Of course the CJC channel cannot be used for any other purpose during temperature measurement Chapter 5 Functions Reference 211 4 Select the appropriate configuration in the driver configuration dialog box base address etc 5 Select the input range 0 05V to 0 05V in the application software for all thermocouple type 6 When THERMO
201. tion you should set the buffer size to be a multiple of the number of channels Otherwise for the cyclic mode the first data in the circular buffer may not be for the start channel For dual DMA triggering it is similar to the single DMA triggering except uses DRV_FAIDualDmaStart or DRV_FAIDualDmaScanStart to start the dual DMA triggering for single channel reading or multiple channel reading Besides you have to allocate two DMA buffers This is only supported in the PCL 1800 model Examples Directory Advantech Adsapi Examples Console addma Advantech Adsapi Examples V Bladdma Advantech Adsapi Examples Delphi addma Advantech Adsapi Examples VC addma Function Description Demo program for analog input function with DMA triggering 88 Advantech DLL Drivers User s Manual 4 3 2 4 Watchdog Triggering This triggering mode is only supported in the PCL 1800 For data acquisition with the watchdog function analog comparator it acquires data and compares it against the triggering levels and condi tions in the watchdog It has four triggering modes free run pre trigger post trigger and position trigger Free run means that it ignores the level triggering For pre trigger it acquires and stores data in the circular buffer until the watchdog is triggered On the other hand post trigger mode acquires data after the watchdog is triggered For position trigger it acquires data before and after the watchdog is triggered This mode
202. tions 0 9 correspond to analog inputs 0 9 of the DAS card in use Chapter 5 Functions Reference 209 210 7 Select the desired input channel on the DAS card for the CJC cold junction compensation circuit on the PCLD 770 by hard wiring the CJC output directly to an A D channel On the PCLD 779 789 select the CJC channel by setting the jumper block JP17 PCLD 789 or JP3 PCLD 779 Positions 0 9 correspond to analog inputs 0 9 of the DAS card in use Of course the CJC channel selected cannot be set to any analog channel that is already being used for another purpose 8 If you are cascading or Y connecting more than one PCLD 779 789 for thermocouple measurement normally only one CJC input is required i e only one of the PCLD 770 779 789s has to connect its CJC to the DAS card 9 Make sure jumper blocks JP16 and JP17 or JP2 and JP3 are not at the same position They must be set to different input channels on the DAS card 10 Select the appropriate configuration in the driver configuration dialog box DAS card expansion board and base address etc 11 When THERMOCOUPLE TYPE in the application software is selected the driver will perform the appropriate linearization only if the DAS card s A D input range is set to 5V to 5V Using the PCLD 788 for thermocouple measurement Thermocouple linearization is provided by the driver automatically if a temperature measurement operation is chosen in the application program T
203. triggering However waveform data reading utilizes the on board pacer to trigger the sampling operation and acknowledge the driver through a hardware interrupt 4 3 2 1 Waveform Data Acquisition Operation Theory This kind of data transfer is performed in the background It thus uses less CPU time and speeds the transfer rate These functions are used for larger amounts of data transfer at higher rates The driver uses double buffering techniques for continuous uninterrupted data transfer of large amounts of data Single buffered Input In single buffered input operations a fixed number of samples are acquired at a specified rate and transferred into computer memory After the data is stored into the memory buffer the computer can analyze display or store the data to the hard disk for later processing Single buffered output operations output a fixed number of samples from computer memory at a specified rate After the data is output the buffer can be updated with new or freed data Single buffered operations are relatively simple to implement and can usually take advantage of the full hardware speed of the data acquisi Chapter 4 Function Overview 81 82 tion board The major disadvantage of single buffered operation is that the amount of data at any one time is limited to the amount of free memory available in the computer and the available count in the DMA count register 1 e 64K Double buffered Input In double buffered
204. u want to include the sample program code SDK 2 If the header library for example WDSAPNEXMPLESBC LIB ADSAPIBC LIB is not compatible with your Borland C version you should apply the IMPLIB utility to create a new LIB file Syntax IMPLIB options libname 1ib dliname d11 Example IMPLIB C Program Files Advantech Adsapi Examples BC LIB NADSAPIBC LIB C WinNT ADSAPI32 DLL Note The header file for Borland C and Borland C Builder is identical to the Visual C header file 1 Add your source code filename into this project 2 Configure the Data Alignment to Quad Word 8 Byte in the Processor item of 32 bit Compiler setup of Project Options Because the default Data Alignment of Visual C Visual Basic and Delphi are in Quad Word 8 Byte you do not have to change the configuration in those programming language environments 42 Advantech DLL Drivers User s Manual 2 6 Advantech DLL Drivers Programming Considerations In addition to knowing how to use the Advantech DLL drivers you should consider some special problems that can occur when you access certain DLL routines This section briefly describes the nature of the problems The following sections which are specific to each language give the methods for solving the problems 2 6 1 Buffer Allocation Allocating memory in a Windows application is much more restrictive than what is normally encountered in a non Windows application Windows has its own m
205. ulse Output General Output Function Call FIOW cceeeeeeees 114 PWM Output Function Call FIOW cceeceeeeeceeseseeeeeeeeeeeeeeeerseeeeaeeaneaeeees 116 Frequency Measurement Function Call FIOW cccesseeeeeeeeeeeeeeees 117 Temperature Measurement Function Group Function Call Flow 120 Alarm Function Call Flow Communication Function Call FIOW cceeceeceecesseeeeeeeeeeeeeeeseeeeaeeneeeees Single Channel Analog Input with Interrupt Triggering s es Multiple Channel Analog Input with Interrupt Triggering Multiple Channel Analog Input with DMA Triggering seese Preface xvii Figure 4 29 Analog Input with Interrupt and Watchdog Triggering Figure 4 30 Analog Input with DMA and Watchdog Triggering Figure 4 31 Event Call Flow for Analog Output with DMA Triggering Figure 4 32 Event Call Flow for Analog Output with Interrupt Triggering 137 Figure 4 33 Event Call Flow for Counter with Interrupt Triggering ceeeeeeeeees 138 xviii Advantech DLL Drivers User s Manual Tables Table 4 1 Device Analog Input Output Digital Input Output Function Calls 74 Table 4 2 Temp Measurement Port I O Alarm and Counter Function Calls 74 Table 4 3 High Speed Analog Input Analog Output Event and Other Function Calls 74 Table 4 4 Watchdog Triggering Relationships ooonocnnncnininncnonacanacaninacanaca
206. unctions Reference 297 PT_QCounterStart typedef struct tagPT_QCounterStart 1 USHORT counter USHORT InputMode PT_QCounterStart FAR LPT_QCounterStart PT_QCounterStart is used by DRV_QCounterStart function Member Description Direction Description counter unsigned short counter number InputMode unsigned short Input mode control DISABLE 0 ABPHASEX1 1 ABPHASEX2 2 ABPHASEX4 3 TWOPULSEIN 4 ONEPULSEIN 5 Table 5 147 PT_QCounterStart Member Description 298 Advantech DLL Drivers User s Manual PT_QCounterRead typedef struct tagPT_QCounterRead USHORT counter USHORT far overflow ULONG far LoCount ULONG far HiCount PT_QCounterRead FAR LPT_QCounterRead PT_QCounterRead is used by DRV_QCounterRead function Member Description Counter Input unsigned short counter number Overflow Output long pointer to overflow state of the unsigned short counter 1 means overflow otherwise 0 LoCount Output long pointer to the low 32 bit data of unsigned long current total HiCount Output long pointer to the high 32 bit of unsigned long current total Table 5 148 PT_QCounterRead Member Description Chapter 5 Functions Reference 299 PT_TimerCountSetting typedef struct tagPT_TimerCountSetting USHORT counter ULONG Count PT_TimerCountSetting FAR LPT_TimerCountSetting PT_TimerCountSetting is used by DRV_ TimerCountSetting function Member Description Na
207. ur project is to select View Project Explorer 30 Advantech DLL Drivers User s Manual Figure 2 10 Including the Advantech DLL Driver for Visual Basic Header File 3 After clicking on the Project Explorer you will get a window titled with the project name Move your cursor into this window and right click to display a list of the available options Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 31 Figure 2 11 Visual Basic Project Options 4 Click on Add File to include the Visual Basic header file Driver bas for Windows 95 98 NT DLL functions Visual Basic will display a file search window to look for the Driver bas file This header file is added into the dedicated path assigned by the DLL driver installation For the Visual Basic DLL calling method please refer to the Microsoft Visual Basic user manual 32 Advantech DLL Drivers User s Manual Figure 2 12 Adding the Driver bas Visual Basic Header File to Your Project 5 After adding the header file you can view the constant definition parameter declaration and DLL function calls that you used in your application Chapter 2 Creating Windows 95 98 NT Applications with DLL Drivers 33 case nil ma Wetdddied 1 00 id CA ay IA Cape 6 I ee Cece LLE LII Digita ceaeowe AS AS cuca Coral Raabe 200 me I Ll Baiiia cla Coit Esabiccp E Ciba Co al EsaFoct 1 Elclal Coit Esa ilcikagls NE
208. ure 3 17 Figure 3 18 Figure 3 19 Figure 3 20 Figure 4 1 Figure 4 2 Figure 4 3 Figure 4 4 Figure 4 5 Figure 4 6 Figure 4 7 Figure 4 8 Figure 4 9 Figure 4 10 Figure 4 11 Figure 4 12 Figure 4 13 Figure 4 14 Figure 4 15 Figure 4 16 Figure 4 17 Figure 4 18 Figure 4 19 Figure 4 20 Figure 4 21 Figure 4 22 Figure 4 23 Figure 4 24 Figure 4 25 Figure 4 26 Figure 4 27 Figure 4 28 Starting the Device Installation Utility Device Installation Utility I O Device Installation Dialog BOx Selecting the Advantech DEMO Board Device cccccceeeseeeeeeteeeeees 48 Device Configuration WiINdOW ececceeeeeeeeeeeeeeeeeeeeeeeeaeeaeseeeeeeeaeeeeeeeees 49 I O Device Installation Dialog Box 49 Start Microsoft Visual C 50 Creating a New VC Application oococcccnnnnonncnicnnnorcccnnccnrnnnnos 51 Creating a Win32 Console Application in the VC App Wizard we 51 Adding the adsapi32 lib Library File and adsoft cpp to Your Project Running Your Sample Win32 Console Program sesser Starting Microsoft Visual Basic 5 0 oo ceeeceseeeeeeeeeteeeeeeeeeeeseeeaeeeneeeeeaee Select Standard EXE from the New Project Dialog Box ah Adding the Declaration File driver bas cece cee cece cece eeee eee eeeeeee Form DESIGN Of FORMA sia di a Testing the Sample Program Starting Delphi
209. using this function it allows the DIO port for input or output to change at run time 182 Advantech DLL Drivers User s Manual DRV_DioReadPortByte status DRV_DioReadPortByte DriverHandle lpDioReadPortByte Purpose Returns digital input data from the specified digital I O port The byte is specified by port number which is from 0 to the maximum byte of the device s digital output For example PCL 722 has up to 18 digital output ports The port number of the board is from 0 to 17 Parameters DriverHandle Input default assigned by DRV_DeviceOpen LpDioReadPortByte Input Output long pointer to default the storage address PT_DioReadPortByte for port and value Table 5 42 DRV_DioReadPortByte Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupported if the function is not supported for this device 4 InvalidChannel if the port number is out of range Chapter 5 Functions Reference 183 DRV_DioWritePortByte status DRV_DioWritePortByte DriverHandle lpDioWritePortByte Purpose Writes digital output data to the specified digital port Parameters A il E default assigned by DRV_DeviceOpen iaasa a fives 2 oad pointer to default the storage address PT_DioWritePortByte for port mask and state Table 5 43 DRV_DioWritePortByte Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 BoardIDNotSupport
210. vantech Adsapi Examples Console addma Advantech Adsapi Examples VB addma Advantech Adsapi Examples Delphi addma Advantech Adsapi Examples VC addma 66 Advantech DLL Drivers User s Manual 3 5 5 Analog Input With Watchdog Triggering Directory Advantech Adsapi Examples VB cdaddma cdadint Advantech Adsapi Examples Delphi cdaddma cdadint Advantech Adsapi Examples VC cdaddma cdadint 3 5 6 Analog Output Directory Advantech Adsapi Examples Console dasoft Advantech Adsapi Examples VB dasoft Advantech Adsapi Examples Delphi dasoft Advantech Adsapi Examples VC dasoft 3 5 7 Synchronous Analog Output Directory Advantech Adsapi Examples Console dasync Advantech Adsapi Examples VB dasync Advantech Adsapi Examples Delphi dasync Advantech Adsapi Examples VC dasyncc dasyncv 3 5 8 Analog Output with Interrupt Triggering Directory Advantech Adsapi Examples Console daint Advantech Adsapi Examples VB daint Advantech Adsapi Examples Delphi daint Advantech Adsapi Examples VC daint 3 5 9 Analog Output with DMA Triggering Directory Advantech Adsapi Examples Console dadma Advantech Adsapi Examples VB dadma Advantech Adsapi Examples Delphi dadma Advantech Adsapi Examples VC dadma 3 5 10 Digital Input Directory Advantech Adsapi Examples Console digin Advantech Adsapi Examples VB digin Advantech Adsapi Examples Delphi digin Advantech Adsapi Examples VC digin Chapter 3 Tutorial 67 68 3 5
211. ver h DLL Driver Header File in the Project Directory 0 ee Creating Your Application Source Code in the App Studio sis Adding the DLL Import Library Into Your Project ooononoccninnninininnnnnninacaninan Linking Your DLL Driver Libray to Your Project o ooonnonnicnnnnnniconicncnananananinos Creating a New Visual Basic Project Figure 2 10 Including the Advantech DLL Driver for Visual Basic Header File 31 Figure 2 11 Figure 2 12 Adding the Driver bas Visual Basic Header File to Your Project Visual Basic Project Options oooooconionicnnccnnnconronocnncnncnrrcnc nan rra rc rca Figure 2 13 Constants Parameters and DLL Function Calls oooonnccnnnnnnnnnnonconncnn Figure 2 14 Writing the Source Code ecceseeceseeeceseeeeeeceeseeeeaeeaeeeeeeeeeaeeaeseeseeseaeeaees Figure 2 15 Creating a New Borland Delphi Application Figure 2 16 Opening the Project Manager e ceeeecseeeseeeeeneeeeeeeeeseeeeeeeeeeeateareeeeees Figure 2 17 Adding Header File Into Your Project ooooonoconnnoniconinanocanannnnancnano nana nanann Figure 2 18 Adding the DLL Header File Figure 2 19 Constants Parameters and DLL Function Calls xvi Advantech DLL Drivers User s Manual Figure 3 1 Figure 3 2 Figure 3 3 Figure 3 4 Figure 3 5 Figure 3 6 Figure 3 7 Figure 3 8 Figure 3 9 Figure 3 10 Figure 3 11 Figure 3 12 Figure 3 13 Figure 3 14 Figure 3 15 Figure 3 16 Fig
212. w FLOAT fHigh TRIGLEVEL TRIGLEVEL is used by DAQConfig Watchdogfunction Member Description Name Direction Type Range Description floating point floating point Table 5 109 TRIGLEVEL Member Description Chapter 5 Functions Reference 259 PT_EVLIST DEVLIST typedef struct tagPT_DEVLIST 1 DWORD dwDeviceNum char szDeviceName 50 SHORT nNumOfSubdevices PT_DEVLIST PT_DEVLIST is used by DRV_DeviceGetList function Member Description Name Direction Type Range Description dwDeviceNum Input DWORD 0 999 Device number szDeviceName 50 _ Output______char______ ____ Devicename nNumOfSubdevices Output short Number of sub devices in device number Table 5 110 PT_EVLIST DEVLIST Member Description 260 Advantech DLL Drivers User s Manual PT_DeviceGetFeatures typedef struct tagPT_DeviceGetFeatures 1 LPDEVFEATURES buffer USHORT size PT_DeviceGetFeatures PT_DeviceGetFeatures is used by DRV_DeviceGetFeatures function Member Description Name Direction Type Description buffer Output the storage long pointer to DEVFEATURES address of the device features size imput unsignedshort_ __________ buffersize Table 5 111 PT_DeviceGetFeatures Member Description Chapter 5 Functions Reference 261 PT_AlConfig typedef struct tagPT_AIConfig 1 USHORT DasChan USHORT DasGain PT_AIConfig FAR LPT_AIConfig PT_AIConfig is used by DRV_AIConfig
213. y You can then call the DRV_CounterReset function to stop the frequen cy measurement operation Notice a The programming method depends on the counter timer chip on the board There are two kinds of chips that are used in DA amp C cards Intel 8254 and AMD Am9513A b Since the AMD Am9513A chip uses two counter timer channels a highly accurate frequency mea surement device can be attained Channels 0 8 function as possible input sources for frequency measurement from 1 Hz to 65535 Hz Channel 9 the last channel on the chip is reserved and used as a gate period counter For frequency measurement the on board time base is used and divided by the gate period counter channel Since a long gating period is generally desirable choosing F5 100 Hz will allow for longer gating periods You must connect a jumper between the gate period counter output and the gate input of the desired frequency mea surement counter Connect your external frequency generator to the frequency measurement counter s clock source input If hardware gating in which the counter may be started by a separate external hardware input is desired choose a gating type and use an external device to trigger the gate input of the gate period counter fixed at channel 9 by this function c For the Intel 8254 chip there is no gate period counter The function uses the Windows API to get the time period between two samples The
214. y DRV_DeviceOpen LpCounterPWMSetting long pointer to default the storage address for PT_CounterPWMSetting Port Period HiPeriod OutCount and GateMode Table 5 63 DRV_CounterPWMSetting Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL Note 206 Advantech DLL Drivers User s Manual DRV_CounterPWMEnable status DRV_CounterPWMEnable DriverHandle Port Purpose Enable PWM Pulse Width Modulation output operation Parameters Lee ae piston eee default assigned by DRV_DeviceOpen Input unsign ERA default Enable Disable port If bitO 1 portO is enabled If bit 1 porti is enabled Table 5 64 DRV_CounterPWMEnable Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL Note Chapter 5 Functions Reference 207 DRV_TCMuxRead status DRV_TCMuxRead DriverHandle lpTCMuxRead Purpose Measures the temperature with expansion boards for example PCLD 788 779 789D 8 115 770 Parameters Direction Type Range Description DriverHandle Input long default assigned by DRV_DeviceOpen IpTCMuxRead Input Output long pointer to default the storage address PT_TCMuxRead for DasChan DasGain ExpChan TCType TempScale and temp Table 5 65 DRV_TCMuxRead Parameter Table Return 1 SUCCESS if successful 2 InvalidDriverHandle if DriverHandle NULL 3 NoExpansionBoardConfig if no expansion b
215. yIn 1 USHORT NumChan USHORT StartChan USHORT TrigMode USHORT far ReadingArray PT_MAlBinaryIn FAR LPT_MAlBinaryIn PT_MAIBinaryln is used by DRV_MAIBinaryln function Member Description Name Direction Type Range Description NumChan Input unsigned short 1 n n depends number of the on hardware channels StartChan unsigned short 0 n n depends start one of scan on hardware channels TrigMode unsigned short 0 normal trigger mode software 1 external ReadingArray Output long pointer to depends on the unscaled unsigned short hardware result arra Table 5 119 PT_MAIBinaryln Member Description Chapter 5 Functions Reference 269 PT_MAIVoltageln typedef struct tagPT_MAIVoltageIn 1 USHORT USHORT USHORT far USHORT FLOAT far NumChan StartChan GainArray TrigMode VoltageArray PT_MAIVoltageIn FAR LPT_MAlVoltageln PT_MAIVoltageIn is used by DRV_MAIVoltageln function Member Description Name Direction Type Range Description NumChan StartChan Input Input unsigned short unsigned short 1 n n depends on hardware 0 n n depends on hardware number of the channels the start one of scan channels GainArray Input long pointer to unsigned short refer to gain list in hardware manual gain code array TrigMode Input unsigned short 0 normal software 1 external trigger mode VoltageArray Output
216. you can use the DRV_CheckEvent function to check its status When it reaches the count it will return a hardware event You can then use the DRV_EnableEvent function to stop the counter operation Chapter 4 Function Overview 111 112 Examples Directory Advantech Adsapi Examples Console cntint Advantech Adsapi Examples VC cntint Function Description Demo program for counter function with interrupt triggering 4 6 1 3 Quadratic Counting These functions perform quadratic counter operations They are only supported by the PCL 833 Advantech DLL Drivers User s Manual Call Flow DRV_QCounterConfig DRV_QCounterStart DRV_QCounterRead Repeat DRV_CounterReset Figure 4 19 Quadratic Counting Function Call Flow Chapter 4 Function Overview 113 DRV_QCounterConfig function configures the quadratic counter The DRV_QCounterStart function starts the quadratic counter operation When it is running you can use DRV_QCounterRead function to repeatedly read the count value You can then call DRV_CounterReset to stop the counter operation In addition the DLL drivers provide the DRV_QCounterConfigSys function to configure the system clock and time period of the quadratic counter Examples Directory Advantech Adsapi Examples VC qcounter Function Description Demo program for quadratic counter function 4 6 2 Pulse Output The pulse output functions include general output and PWM output 4 6 2 1 General Output The pul
217. ypedef struct tagPT_FAITransfer 1 USHORT LPVOID USHORT ULONG ULONG ActiveBuf DataBuffer DataType start count USHORT far overrun PT_FAITransfer FAR LPT_FAITransfer PT_FAITransfer is used by DRV_FAITransfer function Member Description Name Direction Type Description ActiveBuf DataBuffer DataType Input Output unsiged short long pointer to floating point or unsigned short unsigned short depends on hardware 0 1 0 buffer A or single buffer 1 buffer B data array data type unsigned short 0 float point 1 start unsigned short unsigned short 0 65535 1 65535 start point of the source buffer to be copied to the data buffer number of points in the source buffer to be copied to the data buffer overrun unsigned short 312 Advantech DLL Drivers User s Manual overrun status overrun 1 no overrun 0 Table 5 161 PT_FAITransfer Member Description PT_FAICheck typedef struct tagPT_FAICheck USHORT far ActiveBuf USHORT far stopped ULONG far retrieved USHORT far overrun USHORT far HalfReady PT_FAICheck FAR LPT_FAICheck PT_FAICheck is used by DRV_FAICheck function Member Description Direction Type 0 1 ActiveBuf Output long pointer to A return value unsigned short from the function to indicate which buffer is being filled during high speed data transfer 0 buffer A or si
218. yte word data to an I O port The specified I O port is an absolute address The DLL drivers support the following functions DRV_outp Writes byte data from the specified I O port DRV_outpw Writes word data from the specified I O port DRV_inp Read byte data from the specified 1 O port DRV_inpw Reads word data from the specified 1 O port Chapter 4 Function Overview 125 Notice For this function group you don t need to call DRV_DeviceOpen and DRV_DeviceClose functions Examples Directory Advantech Adsapi Examples V B portio Advantech Adsapi Examples Delphi portio Advantech Adsapi Examples V C portio Function Description Demo program for port I O function 4 10 Communication Function Group 126 The communication function group performs COM port functions Advantech DLL Drivers User s Manual Call Flow COMOpen COMSetConfig gt y COMRead COMWrite Repeat v COMClose Figure 4 25 Communication Function Call Flow The COMOpen function opens a serial communication port This function must be called before using any other functions The COM SetConfig function configures the communication port such as baud rate parity check etc You can then call COMRead or COMWrite functions repeatedly When it is complete you can call COMClose to close the serial communication port Chapter 4 Function Overview 127 Other Functions COMGe
Download Pdf Manuals
Related Search
downloading download chrome download google chrome downloading downloading apps downloading games downloading windows 11 downloading youtube videos downloading music download roblox downloading youtube downloading movies downloading photos from iphone to pc downloading speed downloading apps on laptop downloading microsoft office downloading music for free downloading teams downloading pictures from iphone to pc downloading youtube videos to computer downloading vs code server downloading vlc downloading books for free downloading mysql downloading do not turn off target downloading shards
Related Contents
intext:Bedienungsanleitung filetype:pdf Sunbeam Freightmaster 400 78625-00 User's Manual (3955Kb)製品カタログ(PDF)のダウンロード Manual de Instalação SICAM 2010 - Tribunal de Contas do Estado SIMATIC Dezentrales Peripheriegerät ET 200eco Fehlersicheres Cuidado y limpieza del horno. Sony SA-VE835ED System GBC WireBind Karo 40Pro Page 1 Page 2 Sateーi。 DD 4450P田D 4450/DD 4440P / デジタル 3.9×50mm - フェローズジャパン Copyright © All rights reserved.
Failed to retrieve file