Advantech AE Technical Share...

20
1 Advantech AE Technical Share Document Date 2017/11/2 SR# 1-3050819460 Category FAQ □SOP Related OS Windows 7, Windows XP Abstract IAG_FAQ APAX-5580, How to use LabVIEW in APAX-5580 to control APAX IO Module Keyword APAX-5580, LabVIEW, IO module Related Product APAX-5580 Problem Description: In this document, we describe the detailed procedures of how to use LabVIEW in APAX-5580 to control APAX IO module. Furthermore, we explain how to build runtime in case of the customer does not install LabVIEW. Answer: 1. First of all, install the latest version of EtherIO Bus Driver on the Advantech support webpage. http://support.advantech.com/Support/DownloadSRDetail_New.aspx?SR_ID=1-10YRSVF &Doc_Source=Download 2. If you installed it with default path, you can find ADSDIO.dllin C:\Windows\System32 3. To use Advantech defined DIO functions, we need to prepare the header file of VC++ for APAX-5580. If you install AdamApax.NET Class Library VS2008 with default path, you can find ADSDIO.hin C:\Program Files (x86)\Advantech\AdamApax.NET Class Library\Sample Code\APAX\Win32\CPlusPlus\include

Transcript of Advantech AE Technical Share...

Page 1: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

1

Advantech AE Technical Share Document

Date 2017/11/2 SR# 1-3050819460

Category ■FAQ □SOP Related OS Windows 7, Windows XP

Abstract IAG_FAQ APAX-5580, How to use LabVIEW in APAX-5580 to control APAX IO

Module

Keyword APAX-5580, LabVIEW, IO module

Related

Product APAX-5580

Problem Description:

In this document, we describe the detailed procedures of how to use LabVIEW in APAX-5580

to control APAX IO module.

Furthermore, we explain how to build runtime in case of the customer does not install

LabVIEW.

Answer:

1. First of all, install the latest version of EtherIO Bus Driver on the Advantech support

webpage.

http://support.advantech.com/Support/DownloadSRDetail_New.aspx?SR_ID=1-10YRSVF

&Doc_Source=Download

2. If you installed it with default path, you can find “ADSDIO.dll” in C:\Windows\System32

3. To use Advantech defined DIO functions, we need to prepare the header file of VC++ for

APAX-5580. If you install AdamApax.NET Class Library VS2008 with default path, you can find

“ADSDIO.h” in C:\Program Files (x86)\Advantech\AdamApax.NET Class Library\Sample

Code\APAX\Win32\CPlusPlus\include

Page 2: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

2

4. Open the LabVIEW and New a Blank VI. In this document, we use LabVIEW2012 in

Windows 7 as demonstration. (LabVIEW2009 with Windows XP is also verified can work

in APAX-5570.)

5. After creating a new VI, switch from the “Front Panel” to “Block Diagram” window.

Right click your mouse, and choose “Connectivity” “Libraries & Executables”

“Call Library Function Node” button. This kind of node could call DLL or functions in

the shared library directly.

Page 3: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

3

6. Double click the VI and define the path of DLL, which is C:\Windows\System32

Use C language as calling convention.

7. Open ADSDIO.H to decide which API you want to transfer it to LabVIEW VI. Now we

use API DIO_GetValue for illustration of APAX-5040 (DI-module).

8. In the “Function” tab, follow the rule of function name defined in ADSDIO.H.

If you define the path of DLL correctly, it would be a list for you to choose.

Page 4: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

4

9. In the “Parameters” tab, the parameter of each variable needs to be defined.

9.1 Return value

We use the name ‘ERR_DIOGET’ as the return value of the API “DIO_GetValue”.

Use “Signed 32-bit Integer” data type as compatible to “LONG” type.

9.2 LONG handle

Page 5: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

5

9.3 WORD i_wSlot

Use “Unsigned 16-bit Integer” data type as compatible to “WORD” type.

9.4 WORD i_wChannel

Page 6: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

6

9.5 WORD* o_wValue

Use “Signed 16-bit Integer Pointer” data type as compatible to “BOOL*” type.

10. After defining those parameters, you could see the icon on the block diagram as below.

For the following steps, we are going to demonstrate in detail to illustrate the concept of

modularity for the amateur user of LabVIEW. One may build a project as bellow figure.

For more details of modularity, one could refer to LabVIEW official tutorial:

http://www.ni.com/white-paper/7593/en/

Page 7: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

7

11. Move your mouse on the pin, and right-clicking on the pin to create input type ( such as

“Constant”, “Control”) or output type (“Indicator”) of pins.

12. Generally, the left hand side of the module is for input pin, and usually used as “Control”.

The right hand side is for output pin and used as “Indicator”.

13. For demonstration, we arranged all pins as shown below.

However, considering APAX-5040 is a DI module, for input pins, we only need to create

1) handle is the driver handler, which is created by function ADAMDrvOpen. If driver

initialization succeeded, function returns ERR_SUCCESS, and the handle will be used for

rest of the functions. handle shall be terminated by function ADAMDrvClose.

2) i_wSlot for controlling the slot ID of the APAX-5040 module

3) i_wChannel for controlling the channel number of the APAX-5040 module

Page 8: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

8

For output pin, we need to create

1) o_bValue for monitoring the DI value of APAX-5040.

2) handle for passing the driver handler to the next module.

14. Switch to the Front Panel to assign the connector.

There would be 9 pins already created shown on the Panel.

15. Assign connectors to specified pins.

In the Connector zone, click the left-top connector.

Then click the pin of “handle”.

It would make the connector and pin as a pair.

Page 9: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

9

Similarly, click the other connector in the Connector zone.

Then click the pin of “i_wSlot” to make them as a pair.

Assign the rest of input pins with connectors.

There are 5 output pins but only 4 connectors. However, we only assign those output we need

same as step 14th

indicated.

For example, if we want to monitor the error code of this function, we assign ERR_DIOGet to

the right-top connector.

Page 10: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

10

The handle needs to be passed to the next APAX IO Module, so we assign it as well.

To get the DI value, we use the o_bValue to be shown as the indicator.

After finishing the assignment of module APAX-5040, we can save the file.

Page 11: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

11

16. Besides, in LabVIEW, there is an option for you to edit the icon of the VI.

Right click on the icon and choose ‘Edit Icon…’

There is painter for you to edit the icon.

Page 12: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

12

17. To use the VI you created, save the VI (APAX5040), and then open a new blank VI.

18. Click the “Select a VI” button on the “Functions” palette.

19. Navigate to the VI, and left click to place it on the block diagram.

20. You can move your pointer on each pin, and it will show the variable name of the pin.

For example, it shows ‘handle’ when the pointer move on the left top pin.

Page 13: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

13

21. In case of transmitting handle correctly among APAX IO Modules, we need 2 additional

modules. Use ADAMDrvOpen Module as the first module, and ADAMDrvClose Module

as the last module.

22. You could follow previous steps to create these 2 modules by their API definitions.

23. Select these 2 modules in your blank VI with APAX5040.

Page 14: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

14

24. You can create indicator for checking Error code.

Connect the handle of DrvOpen to the handle pin of APAX5040.

25. Because we may change APAX IO Module ID and channel ID, we leave i_wSlot and

i_wChannel could be changed.

26. Connect the handle of APAX5040 and DrvClose. Complete all connection.

Page 15: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

15

27. If you don’t use the correct APAX IO Module ID, you would get Error as below.

28. You may use AdamApax .NET Utility to check your APAX IO Module.

29. After using the correct ID, you can get the value of channel 0 successfully!

Page 16: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

16

For the Error code definition, you can look up in the ADSDIO.H for detailed explanation.

Page 17: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

17

It is possible that the customer does not install LabVIEW in APAX-5580, but still wants to use

APAX-IO Module. For this reason, we could build runtime (EXE file) and provide runtime to meet

the customer’s request without asking him to install LabVIEW.

By following steps, we explain how to build runtime with LabVIEW.

1. Create a new a project and add the file.

Page 18: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

18

2. Add from File.

3. It will include the used VI files and DLL automatically if the VI file includes other VI files.

Page 19: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

19

4. Save your project. Select Build Specification and New an application (EXE)

5. Set your destination directory and your application name.

Page 20: Advantech AE Technical Share Documentadvdownload.advantech.com/productfile/Downloadfile2/1-1EGDNWZ/… · 02/11/2017  · 7. Open ADSDIO.H to decide which API you want to transfer

20

6. Configuring the project by moving the VI from Project Files to Startup VIs.

7. Click “Build” button to build the EXE file.

8. After building, find the runtime “Application.exe”. You can use the program to run.