Interrupt Control. ADLINK Technology PCI-8136M

Add to My manuals
107 Pages

advertisement

Interrupt Control. ADLINK Technology PCI-8136M | Manualzz

4.17 Interrupt Control

The PCI-8136M can generate INT signal to host PC according to 8 types of interrupt factors, refer to _8136_S_Set_Int_factor() function for more details.

The following table represents the interrupt setting for all factors.

_8136_S_Set_Int_factor( Cardno, AxisNo, Int_Factor)

AxisNo

0 1 2 3

Int. Factor bit (type)

0

1

2

3

4

5

6

7

EL1

ALM

EL2 EL3 EL4

4

EL5

5

EL6

ORG1 ORG2 ORG3 ORG4 ORG5 ORG6

EZ1 EZ2 EZ3 EZ4 EZ5 EZ6

CMP1 CMP2 CMP3 CMP4 CMP5 CMP6

Timer - - - - -

ADC1 ADC2 ADC3 ADC4 ADC5 ADC6

INP1 INP2 INP3 - - -

Note: EL is both PEL and MEL, EZ is index signal , CMP is position compare true, Timer is card’s internal timer, ADC is analog compare true. INP is motion command finished.

For each axis number, the interrupt can be set according to this table.

Because users can’t deal with interrupt under Windows System. PCI-8136M has another way for user to receive interrupts. That is Windows message system. This card uses events to notice user’s program if interrupt is coming.

Users can create a thread to get the interrupt events and then use

_8136_S_Get_Int_Status() to get the interrupt status. The status bits for each axis is in the following table:

_8136_S_Get_Int_Status(Cardno, AxisNo, Status )

Bits Description

0 Positive limit switch interrupt

1 Negative limit switch interrupt

2 Alarm pin interrupt

3 ORG pins interrupt

4 Index signal interrupt

5 Position counter compare interrupt

6 Internal timer interrupt

7 Analog compared interrupt

8 Motion command finished

Operation Theorem

• 59

Use Thread to deal with Interrupt under Windows NT/95

In order to detect the interrupt signal from PCI-8136M under Windows NT/95, user must create a thread routine first. Then use APIs provided by

PCI-8136M to get the interrupt signal. Each card has 7 events for these interrupts. Event 0 ~ 5 stands for axis 0~5 and event 6 stands for timer interrupt and alarm interrupt. The sample program is as follows:

Situatuins: Assume that we have one card and want to receive Timer interrupt.

Steps:

1. Define a Global Value to deal with interrupt event

HANDLE hEvent[7]; volatile bool ThreadOn;

2. In Initializing Section ( you must Initialize PCI-8136M properly first), set interrupt types and enable an event for each axis.

_8136_S_Set_Int_Factor(0,0, 0x40);

_8136_S_INT_Control(0,1);

_8136_INT_Enable(0,&hEvent[0]);

_8136_INT_Enable function.

Note: For each card, you must assign a 7 -events-array in.

3. Define a Global Function (Thread Body). Use WaitForSingleObject() or WaitForMultipleObjects() to wait events. Remenber to reset this event after you get the event.

UINT IntThreadProc(LPVOID pParam)

{

U32 IntSts;

while(ThreadOn==TRUE)

{

::WaitForSingleObject(hEvent[6],INFINITE);

_8136_S_Get_Int_status(0,0,&IntSts);

::ResetEvent(hEvent[6]);

}

return 0;

}

60

• Operation Theorem

4. Start the thread( Use a boolean value to control the thread’s life )

ThreadOn=TRUE;

AfxBeginThread(IntThreadProc,GetSafeHwnd(),THREAD_PRIORIT

Y_NORMAL);

5. Before exit the program, remember to let the thread go to end naturally.

ThreadOn=FALSE;

We suggest user to create a thread and use WaitForSingleObject() for each events in order to guarantee the performance.

You can also use _8136_Callback_Function() to receive INT event and ignore the above method but the interrupt service routine in this function should be programmed carefully. The total spent time in this call back function should not be too long.

Relative Functions:

_8136_INT_Enable(), _8136_INT_Disable(),

_8136_S_Set_Int_Factor(), _8136_S_INT_Control(),

_8136_S_Get_Int_Status(), _8136_Callback_Function() refer to section 5.9

Operation Theorem

• 61

5

Motion Library

This chapter describes the supporting software for PCI-8136M cards. User can use these functions to develop application program in C or Visual Basic or C++ language.

The function prototypes and some common data types are decelerated in

PCI-8136M.H. These data types are used by PCI-8136M library. We suggest you to use these data types in your application programs. The following table shows the data type names and their range.

Type Name

U8

I16

U16

I32

U32

F32

F64

Boolean

Description

8-bit ASCII character

16-bit signed integer

16-bit unsigned integer

Range

0 to 255

-32768 to 32767

0 to 65535

32-bit signed long integer -2147483648 to 2147483647

32-bit unsigned long integer

32-bit single-precision floating-point

0 to 4294967295

-3.402823E38 to 3.402823E38

64-bit double-precision floating-point

Boolean logic value

-1.797683134862315E308 to

1.797683134862315E309

TRUE, FALSE

The functions of PCI-8136’s software drivers use full-names to represent the functions' real meaning. The naming convention rules are:

In C Environment :

_{hardware_model}_{action_name}. e.g. _8136_Initial().

In order to recognize the difference between C/C++ library and Visual Basic library, A capital "B" is put on the head of each function name of the Visual

Basic function. e.g. B_8136_Initial().

62

• Motion Library

advertisement

Related manuals

advertisement

Table of contents