User manual


Add to my manuals
101 Pages

advertisement

User manual | Manualzz

PCI-1202/1602/1800/1802 Hardware User’s Manual

3.6 Section 3: Control Register

z I/O address of control register

= wAddrCtrl + 0*4 z I/O address of status register

= wAddrCtrl + 0*4 z I/O address of trigger register

= wAddrCtrl + 1*4

The flow path of analog input signal is given as follows:

Signals

MUX

Max=+/-10V Max=+/-5V

AMP1 AMP1

Gain

4,3,2,1,0 7,6

Single-ended

Differential

Figure 3-2: The flow path of Analog input signal.

Rang

9,8

3.6.1 The control register

The format of the control register is given as follows:

B15 B14 B13 B12 ~ B10 B9, B8 z B4~ B0: A/D channel select z B7, B6: A/D gain control. z B9, B8: A/D input range control. z B12~B10: external trigger control. z B13: handshake control to MagicScan controller. z B15: clear FIFO. z B5, B14: reserved

B7, B6

ADC

B5 B4 ~ B0

:

:

:

:

.

1

0

1

0

Version: 3.8 (Mar.2007, PPH-014-38) ---- 38

PCI-1202/1602/1800/1802 Hardware User’s Manual

3.6.1.1 Bit4~ Bit0: A/D channel select

A/D channel B4 B3 B2 B1 B0

3.6.1.2 Gain control

[B7, B6]

[0, 0]

[0, 1]

[1, 0]

[1, 1]

PCI-1XXX L/LU PCI-1XXX H/HU

PGA=1 PGA=1

PGA=2

PGA=4

PGA=8

PGA=10

PGA=100

PGA=1000

3.6.1.3 Input range control

[B9, B8]

[0, 0]

Output

PGA

[1, 0]

[0, 1]

[1, 1]

PGA-5

PGA/2

PGA/2 - 5

Version: 3.8 (Mar.2007, PPH-014-38) ---- 39

PCI-1202/1602/1800/1802 Hardware User’s Manual

3.6.1.4 Configuration Table

The configuration table of PCI-1202L/LU/1800L/1802L is given as follows:

Bipolar/Unipolar Input Signal Range Gain Settling Time [B9,B8,B7,B6]

Bipolar +/- 5V 1 3 us 0000

Bipolar

Bipolar

Bipolar

+/- 2.5V

+/- 1.25V

+/- 0.625V

2

4

8

3 us

3 us

3 us

0001

0010

0011

Bipolar

Bipolar

Bipolar

Bipolar

Unipolar

Unipolar

Unipolar

Unipolar

+/- 10V

+/- 5V

+/- 2.5V

+/- 1.25V

0V ~ 10V

0V ~ 5V

0V ~ 2.5V

0V ~ 1.25V

0.5 3 us

1 3 us

2

4

1

2

4

8

3 us

3 us

3 us

3 us

3 us

3 us

0100

0101

0110

0111

1000

1001

1010

1011

The configuration table of PCI-1202H/HU/1800H/1802H is given as follows:

Bipolar/Unipolar Input Signal Range Gain Settling

Bipolar

Bipolar

+/- 5V

+/- 0.5V

1

10

23 us

28 us

0000

0001

Bipolar

Bipolar

+/- 0.05V

+/- 0.005V

100 140 us

1000 1300 us

0010

0011

Bipolar

Bipolar

Bipolar

Bipolar

Unipolar

Unipolar

Unipolar

Unipolar

+/- 10V

+/- 1V

+/- 0.1V

+/- 0.01V

0V ~ 10V

0V ~ 1V

0V ~ 0.1V

0V ~ 0.01V

0.5 23 us

5 28 us

50 140 us

500 1300 us

1 23 us

10 28 us

100 140 us

1000 1300 us

0100

0101

0110

0111

1000

1001

1010

1011

Version: 3.8 (Mar.2007, PPH-014-38) ---- 40

PCI-1202/1602/1800/1802 Hardware User’s Manual

3.6.1.5 Set Channel Configuration

The demo program to set the channel/gain is given as follows:

WORD P180X_SetChannelConfig(WORD wAdChannel, WORD wAdConfig)

{

WORD wConfig,wChannel; wChannel = (wAdChannel&0x1f); wSysConfig = (wAdConfig&0x1f); // store for P1802_AdPolling wConfig = (wAdConfig&0x0f); wConfig = wConfig << 6; wConfig += wChannel;

/* Bit15=1 --> no reset FIFO

Bit14=?

Bit13=?

Bit12=0 --> command [001] --> set channel&Config command

Bit11=0

Bit10=1

Bit9 =B --> Range control code [BB] --> unipolar/bipolar & divided by 2

Bit8 =B

Bit7 =B --> gain control code [BB] --> 1/10/100/1000 or 1/2/4/8

Bit6 =B

Bit5 =?

Bit4-Bit0 --> channel number */

wConfig+= 0x8400; // this is set channel config command

return(pic_control(wConfig));

} z P1202_SetChannelConfig(…) is designed for PCI-1202H/L/HU/LU z P1602_SetChannelConfig(…) is designed for PCI-1602 and PCI-1602F

Version: 3.8 (Mar.2007, PPH-014-38) ---- 41

PCI-1202/1602/1800/1802 Hardware User’s Manual

3.6.1.6 Calculate the A/D Value

The demo program to calculate the real A/D value is given as follows: double ComputeRealValue(DWORD dwAdConfig, DWORD dwAdHex)

{

WORD wZERO; double dfMAX, dfVal; switch (dwAdConfig)

{ case 0 : wZERO=2048; dfMAX=5.0; break;

case 1 : wZERO=2048; dfMAX=2.5; break;

case 2 : wZERO=2048; dfMAX=1.25; break;

case 3 : wZERO=2048; dfMAX=0.625; break;

case 4 : wZERO=2048; dfMAX=10.0; break;

case 5 : wZERO=2048; dfMAX=5.0; break;

case 6 : wZERO=2048; dfMAX=2.5; break;

For PCI-1202/1800/1802L

case 7 : wZERO=2048; dfMAX=1.25; break ;

case 8 : wZERO= 0; dfMAX=10.0/2.0; break;

case 9 : wZERO= 0; dfMAX=5.0/2.0; break;

case 10: wZERO= 0; dfMAX=2.5/2.0; break;

case 11: wZERO= 0; dfMAX=1.25/2.0; break;

case 0x10 : wZERO=2048; dfMAX=5.0; break;

case 0x11 : wZERO=2048; dfMAX=0.5; break;

case 0x12 : wZERO=2048; dfMAX=0.05; break;

case 0x13 : wZERO=2048; dfMAX=0.005; break;

case 0x14 : wZERO=2048; dfMAX=10.0; break;

case 0x15 : wZERO=2048; dfMAX=1.0; break ;

case 0x16 : wZERO=2048; dfMAX=0.1; break;

case 0x17 : wZERO=2048; dfMAX=0.01; break;

case 0x18 : wZERO= 0; dfMAX=10.0/2.0; break ;

case 0x19 : wZERO= 0; dfMAX=1.0/2.0; break;

case 0x1A : wZERO= 0; dfMAX=0.1/2.0; break;

case 0x1B : wZERO= 0; dfMAX=0.01/2.0; break;

default: return(ConfigCodeError); } dfVal=(((double)(wAdHex)-wZERO)/2048.0)*dfMAX; return(dfVal);

}

Note: B4=0 is used

to identify PGL

For PCI-

1202/1800/1802H

Note: B4=1 is used to

identify PGH

Version: 3.8 (Mar.2007, PPH-014-38) ---- 42

PCI-1202/1602/1800/1802 Hardware User’s Manual

3.6.1.7

Command Sets of MagicScan Controller

The command sets of MagicScan controller are given as follows:

Command [B12~B10]

Reset [0 0 0]

Descriptions

Reset the MagicScan controller. The software driver

must send this command once after power-on.

Set channel/gain

Add to scan queue

Start MagicScan

[0 0 1] Set the channel/gain value of the fixed-channel mode. It will not affect the scan queue.

[1 0 0] Add the channel/gain code to the scan queue.

(At most 48 scan-channels can be stored in the

MagicScan controller.)

[1 0 1] Start the MagicScan controller

Stop MagicScan

Get ODM number

[0 1 0]

[1 1 0]

Stop the MagicScan controller.

Get the ODM number of the PCI-1202/1602/1800/1802.

The demo program to reset the MagicScan controller is given as follows: wVal=pic_control(0xC000); /* 11?0 00?? ???? ???? cmd_000=reset */

The demo program to clear MagicScan queue is given as follows:

WORD P180X_ClearScan(void)

{

WORD i; for(i=0; i<32; i++) wMagicScanSave[i]=0; disable_timer0(); disable_timer1(); return(pic_control(0xC000)); /* 11?0 00?? ???? ???? cmd_000=reset */

} z P1202_ClearScan(…) is designed for PCI-1202H/L/HU/LU z P1602_ClearScan(…) is designed for PCI-1602 and PCI-1602F

Version: 3.8 (Mar.2007, PPH-014-38) ---- 43

PCI-1202/1602/1800/1802 Hardware User’s Manual

The demo program of send command to MagicScan control is given as follows:

WORD pic_control(WORD i)

{

WORD j; if ((inport(wAddrCtrl)&0x04)==0)

{

outport(wAddrCtrl,0xffff); /* send a recovery to PIC */

} j=0; while ((inport(wAddrCtrl)&0x04)==0)

{

j++;

if (j>65530) return(AdControllerError); /* time out */

} i = i & 0xDFFF; /* set pic low !! */ outport(wAddrCtrl,i); j=0; while ((inport(wAddrCtrl)&0x04)!=0)

{

j++;

if (j>65530) return(AdControllerError); /* time out */

} outport(wAddrCtrl,(WORD)(i | 0x2000)); /* set pic high !! */ j=0; while ((inport(wAddrCtrl)&0x04)==0)

{

j++;

if (j>65530) return(AdControllerError); /* time out */

} return(NoError);

}

Version: 3.8 (Mar.2007, PPH-014-38) ---- 44

PCI-1202/1602/1800/1802 Hardware User’s Manual

The demo program to set the channel/gain is given as follows:

WORD P180X_SetChannelConfig(WORD wAdChannel, WORD wAdConfig)

{

WORD wConfig,wChannel; wChannel = (wAdChannel&0x1f); wSysConfig = (wAdConfig&0x1f); // store for P1802_AdPolling wConfig = (wAdConfig&0x0f); wConfig = wConfig << 6; wConfig += wChannel;

/* Bit15=1 --> no reset FIFO

Bit14=?

Bit13=?

Bit12=0 --> command [001] --> set channel&Config command

Bit11=0

Bit10=1

Bit9 =B --> Range control code [BB] --> unipolar/bipolar & divided by 2

Bit8 =B

Bit7 =B --> gain control code [BB] --> 1/10/100/1000 or 1/2/4/8

Bit6 =B

Bit5 =?

Bit4-Bit0 --> channel number */

wConfig+= 0x8400; // this is set channel config command

return(pic_control(wConfig));

} z P1202_SetChannelConfig(…) is designed for PCI-1202H/L/HU/LU z P1602_SetChannelConfig(…) is designed for PCI-1602 and PCI-1602F

Version: 3.8 (Mar.2007, PPH-014-38) ---- 45

PCI-1202/1602/1800/1802 Hardware User’s Manual

The demo program to add to MagicScan queue is given as follows:

WORD P180X_AddToScan(WORD wAdChannel, WORD wAdConfig, WORD wAverage, WORD wLowAlarm, WORD wHighAlarm, WORD wAlarmType)

{WORD wConfig,wChannel,wRetVal; if (wAlarmType>=5) return(AlarmTypeError); wMagicLowAlarm[wMP]=wLowAlarm; wMagicHighAlarm[wMP]=wHighAlarm; wMagicAlarmType[wMP]=wAlarmType; wChannel = wAdChannel&0x1f; wMagicChannel[wMP]=wChannel; wSysConfig = wAdConfig&0x1f; /* Store for P180X_AdPolling */ wMagicConfig[wMP]=wSysConfig; wMagicAve[wMP]=wAverage; wConfig = wAdConfig&0x0f; wConfig = wConfig << 6; wConfig += wChannel;

/* Bit15=1 --> no reset FIFO

Bit14=1

Bit13=?

Bit12=1 --> command [100] --> add_to_scan command

Bit11=0

Bit10=0

Bit9 =B --> Range control code [BB] --> unipolar/bipolar & divided by 2

Bit8 =B

Bit7 =B --> gain control code [BB] --> 1/10/100/1000 or 1/2/4/8

Bit6 =B

Bit5 =?

Bit4-Bit0 --> channel number */ wConfig+= 0xD000; /* this is add_to_scan_queue command */ wRetVal=pic_control(wConfig); if (wRetVal!=0) return(wRetVal); return(NoError);

} z P1202_AddToScan(…) is designed for PCI-1202H/L/HU/LU z P1602_AddToScan(…) is designed for PCI-1602 and PCI-1602F

Version: 3.8 (Mar.2007, PPH-014-38) ---- 46

PCI-1202/1602/1800/1802 Hardware User’s Manual

The demo program to start MagicScan operation is given as follows:

WORD P180X_StartScan(WORD wSampleRate, WORD wNum)

{

WORD wVal;

WORD wRetVal; wMagicNum=wNum; disable_timer0(); /* Disable pacer timer first */

/* start MagicScan controller */ wRetVal=pic_control(0xD400); /* 11?1 01?? ???? ???? cmd_101=start scan */ if (wRetVal!=0) return(wVal);

/* Clear FIFO to clear all data */ outport(wAddrCtrl,0x2000); /* Bit15=0=clear FIFO, Bit13=1=not PIC cmd */ outport(wAddrCtrl,0xA000); /* Bit15=1=no reset FIFO, BIT13=1=not PIC cmd */ enable_timer0(wSampleRate); /* Enable pacer timer, sampling rate=8M/dwSample */ magic_scan(); /* Call MagicScan subroutine(DOS) or thread(Windows) */ return(NoError);

} z P1202_StartScan(…) is designed for PCI-1202H/L/HU/LU z P1602_StartScan(…) is designed for PCI-1602 and PCI-1602F

Version: 3.8 (Mar.2007, PPH-014-38) ---- 47

PCI-1202/1602/1800/1802 Hardware User’s Manual

3.6.1.8 External Trigger Control

The operation steps of post-trigger are given as follows:

Step 1: Disable all external trigger

External trigger signal

Step 2: Set the pacer rate of timer-1

Step 3: Clear FIFO & disable timer-1

Step4: Wait until external trigger signal

to enable timer-1

Step 5: Fetch N data(N=End-Start)

CHn

Start End

External post-trigger timing

Step 6: Stop all timer

The operation steps of pre-trigger are given as follows:

Step 1: Disable all external trigger

External trigger signal

Step 2: Set the pacer rate of timer-1 t

Step 3: Clear FIFO & enable timer-1

Step 4: Circular-fetch N-data until

CHn

external trigger signal to disable

timer-1 (N=End-Start)

Step 5: Stop all timer

NOTE: The circular-fetch operation is performed by software t

Start End

External pre-trigger timing diagram

The operation steps of middle-trigger are given as follows:

Step 1: Disable all external trigger

External trigger signal

Step 2: Set the pacer rate of timer-1

Step 3: Clear FIFO & enable timer-1

CHn

Step4: Circular-fetch N-data until

external trigger signal (N=End-

Start)

Step 5:Fetch more N2-data & stop timer-1

N2

End t

Start

External middle-trigger timing diagram

Step 6: Stop all timer

NOTE: The circular-fetch operation is performed by software z Note 1: The external trigger operation must use with the MagicScan controller.

The software flowchart of external trigger is given in next page. z Note 2: The post-trigger operation can use all MagicScan function. z Note 3: The user cant enable MagicScan HI/LO alarm and digital filter function

in the pre-trigger & middle-trigger operation.

Version: 3.8 (Mar.2007, PPH-014-38) ---- 48

PCI-1202/1602/1800/1802 Hardware User’s Manual

The software flowchart of external trigger operation is given as follows:

P180X_ClearScan Clear the MagicScan controller

P180X_AddToScan

P180X_SaveScan

Add channel 1 to circular queue

If the AD data need to save

P180X_AddToScan

P180X_SaveScan

Add channel 2 to circular queue

If the AD data need to save

P180X_AddToScan

P180X_SaveScan

Add channel ? to circular queue

If the AD data need to save

P180X_StartScanPostTrg or

Start the external trigger operation

P180X_StartScanPreTrg or

P180X_StartScanMiddleTrg

P180X_WaitMagicScanFinish Wait external trigger signal

Perform analysis z Refer to chapter-4 for more information z This flowchart is validate for PCI-1202/1602/1800/1802

Version: 3.8 (Mar.2007, PPH-014-38) ---- 49

PCI-1202/1602/1800/1802 Hardware User’s Manual

The demo program of post-trigger is given as follows:

wRetVal=P180X_ClearScan();

wRetVal += P180X_AddToScan(0,0,1,0,0,0); // CH:0 to scan

wRetVal += P180X_SaveScan(0,wV0);

wRetVal += P180X_AddToScan(2,0,1,0,0,0); // CH:2 to scan

wRetVal += P180X_SaveScan(1,wV2); // Notice: 1 not 2

// ^ : This is a ordinal number in

// Scan Queue not a channel number. wRetVal += P180X_StartScanPostTrg(wSampleRateDiv,DATALENGTH,nPriority);

if (wRetVal==0) sprintf(cShow,"2. External Post-Trigger Setup OK");

else sprintf(cShow,"2. External Post-Trigger Setup Error");

TextOut(hdc,x*dx,(y+iLine)*dy,cShow,strlen(cShow)); iLine++;

for (; ;)

{

P180X_ReadScanStatus(&wStatus,&dwLowAlarm,&dwHighAlarm);

if (wStatus>1) break;

Sleep(10);

}

sprintf(cShow,"3. ScanStatus=%x",wStatus);

TextOut(hdc,x*dx,(y+iLine)*dy,cShow,strlen(cShow)); iLine++;

wRetVal=P180X_StopMagicScan();

if (wRetVal!=NoError)

{

sprintf(cShow,"4. StopMagicScan Error");

TextOut(hdc,x*dx,(y+iLine)*dy,cShow,strlen(cShow)); iLine++;

for (dwI=0; dwI<100; dwI++) Beep(10,10);

}

SHOW_WAVE(hwnd,LINE1,wV0,1);

SHOW_WAVE(hwnd,LINE2,wV2,1); z Refer to DEMO23.C for completely source program

Version: 3.8 (Mar.2007, PPH-014-38) ---- 50

PCI-1202/1602/1800/1802 Hardware User’s Manual

The B13 must set to 1 to set the external trigger logic. The external trigger controller commands are given as follows:

Descriptions

Disable external trigger

(for PCI-1800/1X02)

[B12, B11, B10 ]

[ 1, 0, X] Disable all external trigger.

Post-trigger

(for PCI-1202/1602/

1800/1802)

Pre-trigger

(for PCI-1202/1602 &

PCI-1800/1802/ver-F)

Middle-trigger

(for PCI-1202/1602 &

PCI-1800/1802/ver-F)

Pre-trigger

(for PCI-1800/1802)

(version-C)

Middle-trigger

(for PCI-1800/1802)

(version-C)

[ 1, 0, X ]

[ 0, 1, X ]

[ 1, 1, 1]

[ 1, 0, X]

[ 1, 0, X ]

[ 0, 1, X ]

[ 1, 1, 1]

[ 1, 0, X]

[ 1, 0, X]

[ 1, 0, X ]

[ 1, 1, 1 ]

[ 1, 0, X]

[ 1, 0, X ]

[ 0, 1, X ]

[ 1, 1, 0 ]

[ 1, 0, X]

[ 1, 0, X ]

[ 0, 1, X ]

[ 1, 1, 0]

[ 0, 1, X]

[ 1, 0, X]

(1) disable all external trigger

(2) set pacer time-1

(3) clear FIFO and disable timer-1

(4) waiting for external signal to enable timer-1

(5) fetch N data

(6) stop all timer & disable all external trigger

(1) disable all external trigger

(2) set pacer timer-1

(3) clear FIFO and enable timer-1

(4) waiting for the external signal to stop timer-1.

(5) circular-fetch the last N data

(6) stop all timer & disable all trigger

(1) disable all external trigger

(2) set pacer timer-1

(3) clear FIFO and enable timer-1

(4) waiting for the external signal.

(5) fetch more N2 data (circular-fetch)

(6) stop all timer & disable all trigger

(1) disable all external trigger

(2) set pacer timer-1

(3) clear FIFO and enable timer-1

(4) waiting for the external signal to stop timer-1.

(5) keep the last N data (circular-fetch)

(6) stop all timer & disable all trigger

(1) disable all external trigger

(2) set pacer timer-1

(3) clear FIFO and enable timer-1

(4) waiting for the external signal to stop timer-1

(5) enable timer-1

(6) fetch more N2 data

(7) stop all timer & disable all trigger

Version: 3.8 (Mar.2007, PPH-014-38) ---- 51

PCI-1202/1602/1800/1802 Hardware User’s Manual

The Windows driver of post-trigger is given as follows:

WORD CALLBACK P180X_StartScanPostTrg(WORD wSampleRateDiv, DWORD dwNum,

SHORT nPriority)

{ wVal=pic_control(0xD400); /* 11?1 01?? ???? ???? cmd_101=start scan */ if (wVal!=0) return(wVal);

_outpw(wAddrCtrl,0xf000); // 1. disable all external trigger enable_timer1(wSampleRateDiv); // 2. Sampling rate=8M/dwSampleRateDiv

_outpw(wAddrCtrl,0x7000); // 3. B15=0,S2=1,S1=S0=0 --> clr FIFO

_outpw(wAddrCtrl,0xf000); // 3. B15=1,S2=1,S1=S0=0 --> disable timer-1

_outpw(wAddrCtrl,0xfc00); // 4. S2=1, S1=1, S0=1 --> wait ext signal to

// enable timer-1

// create magicscan thread

InitializeCriticalSection(&MagicScan_CS); wThreadStatus=0; wAskThreadStop=0; hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)magic_scan,

SetThreadPriority(hThread,nPriority); i=0; for(;;)

{

EnterCriticalSection(&MagicScan_CS);

j=wThreadStatus;

LeaveCriticalSection(&MagicScan_CS);

if (j!=0) break;

i++; Sleep(1);

if (i>1000) return(ThreadCreateError);

} return(NoError);

} z P1202_StartScanPostTrg(…) is designed for PCI-1202H/L/HU/LU z P1602_StartScanPostTrg(…) is designed for PCI-1602 and PCI-1602F

Version: 3.8 (Mar.2007, PPH-014-38) ---- 52

PCI-1202/1602/1800/1802 Hardware User’s Manual

The windows driver of pre-trigger is given as follows:

WORD CALLBACK P180X_StartScanPreTrg(WORD wSampleRateDiv, DWORD dwNum,

SHORT nPriority)

{ wVal=pic_control(0xD400); /* 11?1 01?? ???? ???? cmd_101=start scan */ if (wVal!=0) return(wVal);

_outpw(wAddrCtrl,0xf000); // 1. disable all external trigger enable_timer1(wSampleRateDiv); // 2. Sampling rate=8M/dwSampleRateDiv

_outpw(wAddrCtrl,0x6800); // 3. B15=0,S2=0,S1=1,S0=0 --> clr FIFO

_outpw(wAddrCtrl,0xE800); // 3. B15=1,S2=0,S1=1,S0=0 --> enable timer-1

_outpw(wAddrCtrl,0xF800); // 4. S2=1; S1=1; S0=0 --> wait ext signal to

// disable timer-1

// create magicscan thread

InitializeCriticalSection(&MagicScan_CS); hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)

magic_scan_pre_mid_trg, NULL, 0,&dwThreadID);

SetThreadPriority(hThread,nPriority); // can not use HI/LO alarm & digital filter i=0; for(;;)

{

EnterCriticalSection(&MagicScan_CS);

j=wThreadStatus;

LeaveCriticalSection(&MagicScan_CS);

if (j!=0) break;

i++; Sleep(1);

if (i>1000) return(ThreadCreateError);

} return(NoError);

} z P1202_StartScanPostTrg(…) is designed for PCI-1202H/L/HU/LU z P1602_StartScanPostTrg(…) is designed for PCI-1602 and PCI-1602F

Version: 3.8 (Mar.2007, PPH-014-38) ---- 53

PCI-1202/1602/1800/1802 Hardware User’s Manual

The windows driver of middle-trigger is given as follows:

WORD CALLBACK P180X_StartScanMiddleTrg(WORD wSampleRateDiv, DWORD dwNum, SHORT nPriority)

{ wVal=pic_control(0xD400); /* 11?1 01?? ???? ???? cmd_101=start scan */ if (wVal!=0) return(wVal);

_outpw(wAddrCtrl,0xf000); // 1. disable all external trigger enable_timer1(wSampleRateDiv); // 2. Sampling rate=8M/dwSampleRateDiv

_outpw(wAddrCtrl,0x6800); // 3. B15=0,S2=0,S1=1,S0=0 --> clr FIFO

_outpw(wAddrCtrl,0xE800); // 3. B15=1,S2=0,S1=1,S0=0 --> enable timer-1

_outpw(wAddrCtrl,0xFC00); // 4. S2=1; S1=1; S0=1 --> wait ext signal

// create magicscan thread

InitializeCriticalSection(&MagicScan_CS); wThreadStatus=0; wPreMid=1; wAskThreadStop=0; // middle-trigger hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE,

magic_scan_pre_mid_trg, NULL, 0,&dwThreadID);

SetThreadPriority(hThread,nPriority); // can not use HI/LO alarm & digital filter i=0; for(;;)

{

EnterCriticalSection(&MagicScan_CS);

j=wThreadStatus;

LeaveCriticalSection(&MagicScan_CS);

if (j!=0) break;

i++; Sleep(1);

if (i>1000) return(ThreadCreateError);

} return(NoError);

} z P1202_StartScanPostTrg(…) is designed for PCI-1202H/L/HU/LU z P1602_StartScanPostTrg(…) is designed for PCI-1602 and PCI-1602F

Version: 3.8 (Mar.2007, PPH-014-38) ---- 54

PCI-1202/1602/1800/1802 Hardware User’s Manual

The pre-trigger driver for PCI-1800/1802/ver-C is given as follows:

WORD CALLBACK P180X_StartScanPreTrgVerC(WORD wSampleRateDiv, DWORD dwNum, SHORT nPriority)

{ wVal=pic_control(0xD400); /* 11?1 01?? ???? ???? cmd_101=start scan */ if (wVal!=0) return(wVal);

_outpw(wAddrCtrl,0xf000); // 1. disable all external trigger enable_timer1(wSampleRateDiv); // 2. Sampling rate=8M/dwSampleRateDiv

_outpw(wAddrCtrl,0x6800); // 3. B15=0,S2=0,S1=1,S0=0 --> clr FIFO

_outpw(wAddrCtrl,0xE800); // 3. B15=1,S2=0,S1=1,S0=0 --> enable timer-1

_outpw(wAddrCtrl,0xF800); // 4. S2=1; S1=1; S0=0 --> wait ext signal to

// disable timer-1

// create magicscan thread

InitializeCriticalSection(&MagicScan_CS); hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE,

magic_scan_pre_mid_trg_ver_c, NULL, 0,&dwThreadID);

SetThreadPriority(hThread,nPriority); i=0; for(;;)

{

EnterCriticalSection(&MagicScan_CS);

j=wThreadStatus;

LeaveCriticalSection(&MagicScan_CS);

if (j!=0) break;

i++; Sleep(1);

if (i>1000) return(ThreadCreateError);

} return(NoError);

} z This driver is designed for PCI-1800/1802 version-C

Version: 3.8 (Mar.2007, PPH-014-38) ---- 55

PCI-1202/1602/1800/1802 Hardware User’s Manual

The middle-trigger driver for PCI-1800/1802/ver-C is given as follows:

WORD CALLBACK P180X_StartScanMiddleTrgVerC(WORD wSampleRateDiv, DWORD dwNum, SHORT nPriority)

{ wVal=pic_control(0xD400); /* 11?1 01?? ???? ???? cmd_101=start scan */ if (wVal!=0) return(wVal);

_outpw(wAddrCtrl,0xf000); // 1. disable all external trigger enable_timer1(wSampleRateDiv); // 2. Sampling rate=8M/dwSampleRateDiv

_outpw(wAddrCtrl,0x6800); // 3. B15=0,S2=0,S1=1,S0=0 --> clr FIFO

_outpw(wAddrCtrl,0xE800); // 3. B15=1,S2=0,S1=1,S0=0 --> enable timer-1

_outpw(wAddrCtrl,0xF800); // 4. S2=1; S1=1; S0=0 --> wait ext signal to

// disable timer-1

// create magicscan thread

InitializeCriticalSection(&MagicScan_CS); wThreadStatus=0; wPreMid=1; wAskThreadStop=0; // middle-trigger hThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE,

magic_scan_pre_mid_trg_ver_c, NULL, 0,&dwThreadID);

SetThreadPriority(hThread,nPriority); i=0; for(;;)

{

EnterCriticalSection(&MagicScan_CS);

j=wThreadStatus;

LeaveCriticalSection(&MagicScan_CS);

if (j!=0) break;

i++; Sleep(1);

if (i>1000) return(ThreadCreateError);

} return(NoError);

} z This driver is designed for PCI-1800/1802 version-C

Version: 3.8 (Mar.2007, PPH-014-38) ---- 56

PCI-1202/1602/1800/1802 Hardware User’s Manual

The external trigger drivers are given as follows:

Driver Name

P180X_StartScanPostTrg(…) demo program

Applications demo23.c for PCI-1800/1802 ver-C & ver-

F

P180X_StartScanPreTrg(…) demo24.c for PCI-1800/1802 ver-F

P180X_StartScanMiddleTrg(…) demo25.c for PCI-1800/1802 ver-F

P180X_StartScanPreTrgOld(…) demo26.c for PCI-1800/1802 ver-C

P180X_StartScanMiddleTrgOld(…) demo27.c for PCI-1800/1802 ver-C

P1202_StartScanPostTrg(…) demo23.c PCI-1202

P1602_StartScanPostTrg(…) demo23.c PCI-1602

3.6.1.9 Clear FIFO Bit

The B15 is used to reset the on-board FIFO. When set to low, FIFO will be clear. The

FIFO must be clear once after power-on.

The demo program of handshaking is given as follows:

// Clear FIFO to clear all data outport(wAddrCtrl,0x2000); /* Bit15=0=clear FIFO, Bit13=1=not PIC cmd */ outport(wAddrCtrl,0xA000); /* Bit15=1=no reset FIFO, BIT13=1=not PIC cmd */

Version: 3.8 (Mar.2007, PPH-014-38) ---- 57

PCI-1202/1602/1800/1802 Hardware User’s Manual

3.6.1.10 Handshake Control Bit

Set the B13 to 0 if the command is sent to the MagicScan controller. Keep this bit at high when not used.

The demo program of handshaking is given as follows:

WORD pic_control(WORD i)

{

WORD j; if ((inport(wAddrCtrl)&0x04)==0)

{

outport(wAddrCtrl,0xffff); /* send a recovery to PIC */

} j=0; while ((inport(wAddrCtrl)&0x04)==0)

{

j++;

if (j>65530) return(AdControllerError); /* time out */

} i = i & 0xDFFF; /* set pic low !! */ outport(wAddrCtrl,i); j=0; while ((inport(wAddrCtrl)&0x04)!=0)

{

j++;

if (j>65530) return(AdControllerError); /* time out */

} outport(wAddrCtrl,(WORD)(i | 0x2000)); /* set pic high !! */ j=0; while ((inport(wAddrCtrl)&0x04)==0)

{

j++;

if (j>65530) return(AdControllerError); //time out

} return(NoError);

}

Version: 3.8 (Mar.2007, PPH-014-38) ---- 58

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals