Advantech ADS-839 API Help Index

Advantech ADS-839 API

Using the API

Function Summary

Function Call Order

Compiling and Linking

Functions

set_base

set_speed

set_mode

status

m_stop

slowdown

sldn_stop

waitrdy

chkbusy

out_port

in_port

org

cmove

pmove

In_byte

Out_byte


Using the API

The ADS-839 API Dynamic Link Library (DLL) enables you to efficiently write Window applications for PCL-839 card. The library supports both C++ and Visual Basic. The DLL includes all necessary function calls to utilize the PCL-839.


Function Summary

set_base

set_speed

set_mode

status

m_stop

slowdown

sldn_stop

waitrdy

chkbusy

out_port

in_port

org

cmove

pmove

In_byte

Out_byte


Function call order

In general, the functions may be called in any order, with the following restrictions:

1)  Before any of the PCL-839 routines can be used, user have to add the card by way of the device install program.

2)  Any other ADS839 API functions may now be called in any order. Before any ADS752 API function is called, however, its associated parameters must be filled with certain values.


Compiling and Linking

Visual Basic:

To be able to interface with the API, you have to load the supplied header file ADS839.bas into Visual Basic (version 4.0 or higher) using the Add file... option in the File menu.

C, C++:

To compile and link your newly designed application program with the API, you must refer to your compiler's documentation, along with the documentation provided here and in the WINDOWS SDK (Software Development Kit). Your program should include the supplied header file ADS839.h.

After the compilation stage, you must link with the supplied import library AD839.lib.

Also, the supplied DLL driver must be present in either your application's working directory or the WINDOWS\SYSTEM (for WIN95) or WINNT\SYSTEM32 (for WINNT) directory prior to running your application.


Set_base

Subroutine : int set_base (int address)

Description : This function check the PCL-839 with the assigned base address that have installed in the system, and enable following function call operate with this card. It is enables the use to operate multiple PCL-839, if you require to do so.

Parameter :

 address : The base address of the card that user will operate

Return :	0 (no error)

-1 (The assigned base address have no PCL-839 present)


set_speed

Subroutine : int set_speed (int chan , int low_speed , int high_speed , int accelerate)

Description : This function sets the low-speed pulse output frequency,high-speed pulse output frequency and acceleration/deceleration rate for selected channel.

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

low_speed (FL) :

low-speed frequency setting form 1 to 16382 pulses/sec

high_speed (FH) :

high-speed frequency setting from 1 to 16382 pulses/sec

accelerate

Acceleration/Deceleration value setting from 2 to 1023

 Tsud = (FH - FL) * (accelerate value) * 0.0000002 sec

Return : 	0 (no error)

-1 (Parameter error occurred)

-2 (none available PCL-839)

Comment :


set_mode

Subroutine : int set_mode (int chan, int mode)

Description : This function sets the output mode for selected channel.

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

mode :

0 for Direction (one-pulse) mode

1 for Pulse (two-pulse) mode

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)

Comment :


status

Subroutine : int status (int chan)

Description : This function reads and returns the current status of seleced channel

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

Return :

-1 (parameter error)

-2 (none available PCL-839)

others for channel status

bit 0 : EL- signal status, 1 for ON, 0 for OFF

bit 1 : EL+ signal status,  1 for ON, 0 for OFF

bit 2 : ORG signal status, 1 for ON, 0 for OFF

bit 3 : Counter value, 1 for counter = 0, 0 for counter <> 0

bit 4 : n/a

bit 5 : Output pulse status, 1 for stabilized, 0 for non stabilized

bit 6 : Channel operation status, 1 for running, 0 for stop

bit 7 : n/a

bit 8 : n/a

bit 9 : n/a

bit 10 : SD- signal status, 1 for ON, 0 for OFF

bit 11 : SD+ signal status, 1 for ON, 0 for OFF

bit 12 : Ramping-up status, 1 for in Ramping-up progress, 0 for non in Ramping-up progress

bit 13 : Ramping-down status, 1 for in Ramping-down progress, 0 for non in Ramping-down progress

bit 14 : n/a

bit 15 : n/a


m_stop

Subroutine : int m_stop (int chan)

Description: This function stops the selected channel

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)

Comment :


slowdown

Subroutine : int slowdown (int chan)

Description : This function ramps down the output frequency to FL of selected channel(s)

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)

Comment :


sldn_stop

Subroutine : int sldn_stop (int chan)

Description : This function ramps the output frequency of selected channel down to FL then stops

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)

Comment :


waitdry

Subroutine : int waitrdy (int chan)

Description : This function checks the operating status of selected channels(s), this function wil only return when all selected channel all stop.

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)


chkbusy

Subroutine : int chkbusy (void)

Description : This function check the operation status of all channels

Return :

-2 (none available PCL-839)

others

 bit 0 : channel 1 status, 1 for running, 0 for stopped

 bit 1 : channel 2 status, 1 for running, 0 for stopped

 bit 2 : channel 3 status, 1 for running, 0 for stopped


out_port

Subroutine : int out_port (int port_no , int value)

Description : This function outputs a value to selected digital output port

Parameter :

port_no : 0 for DO7-0 (port 0)

  1 for DO15-8 (port 1)

  2 for DO15-0 (port 1 and 0)

value :

when port_no = 0, port 0 <- value (bit7-bit0)

when port_no = 1, port 1 <- value (bit7-bit0)

when port_no = 2, port 1 <- value (bit15-bit8), port 0 <- value (bit7-bit0)

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)


in_port

Subroutine : int in_port (int port_no)

Description : This function reads and returns a value from selected digital input port

Parameter :

port_no : 0 for DI7-0 (port 0)

  1 for DI15-8 (port 1)

  2 for DI15-0 (port 1 and 0)

Return :

-1 (Parameter error)

-2 (none available PCL-839)

others for current DI status

 	when port_no = 0, return value bit 7-0 map to DI7-0,

 	when port_no = 1, return value bit 7-0 map to DI15-8,

 	when port_no = 2, return value bit 15-0 map to DI15-0.


org

Subroutine : int org (int chan, int dir1, int speed1, int dir2, int speed2 , int dir3, int speed3)

Description : This function returns the selected channels to the ORIGIN point. The direction and speed that each channel has to use, are supplied.

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

dir1,2,3 : retnurn direction

0 for CW direction

1 for CCW direction

speed1,2,3 : return speed

0 for FL

1 for FH

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)


cmove

Subroutine : int cmove (int chan , int dir1 , int speed1 ,int dir2 , int speed2 ,int dir3 , int speed3)

Description : This function starts selected ch in continious mode. Channel 1 will move in dir1 direction at speed1 speed, etc. The channel(s) will stay in continious move mode until m_stop or sldn_stop is executed.

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

dir1,2,3 : moving direction

0 for CW direction

1 for CCW direction

speed1,2,3 : moving speed

0 for FL

1 for FH

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)

Comment :


pmove

Subroutine: int pmove (int ch, int dir1, int speed1, long step1, int dir2, int speed2, long step2, int dir3, int speed3, long step3)

Description: This function starts selected channel in continious mode, for a certain amount of steps. Channel 1 will move in dir1 direction at speed1 speed and will stop when it has completed step1 steps, etc.

Parameter :

chan : channel number

1 for channel 1

2 for channel 2

3 for channel 3

4 for channel 1 and 2

5 for channel 1 and 3

6 for channel 2 and 3

7 for channel 1, 2 and 3

dir1,2,3 : moving direction

0 for CW direction

1 for CCW direction

speed1,2,3 : moving speed

0 for FL

1 for FH

step1,2,3 : moving steps from 1 to 262143 steps

Return :

 0 (no error)

-1 (Parameter error)

-2 (none available PCL-839)

Comment :


In_byte

Subroutine : int In_byte (int offset)

Description : This function reads and returns a BYTE value from a I/O port

Parameter :

offset : offset value from the base address, must be >= 0 and < 16

Return :

-1 (Parameter error)

-2 (none available PCL-839)

others for current I/O port value, bit 7-0 is valid


Out_byte

Subroutine : int Out_byte (int offset , int value)

Description : This function output a BYTE value to a I/O port

Parameter :

offset : offset value from the base address, must be >= 0 and < 16

value : the value to I/O port, bit 7-0 is valid

Return :

-1 (Parameter error)

-2 (none available PCL-839)

others for current I/O port value