48
#define MSR 0x0006
unsigned char rdat[60];
/* read 2 data from address 2102H of AC drive with address 1 */
unsigned char tdat[60]={':','0','1','0','3','2','1','0',’2', '0','0','0','2','D','7','\r','\n'};
void main(){
int i;
outportb(PORT+MCR,0x08); /* interrupt enable */
outportb(PORT+IER,0x01); /* interrupt as data in */
outportb(PORT+LCR,(inportb(PORT+LCR) | 0x80));
/* the BRDL/BRDH can be access as LCR.b7==1 */
outportb(PORT+BRDL,12); /* set baudrate=9600,
12=115200/9600*/
outportb(PORT+BRDH,0x00);
outportb(PORT+LCR,0x06); /* set protocol, <7,N,2>=06H
<7,E,1>=1AH, <7,O,1>=0AH
<8,N,2>=07H, <8,E,1>=1BH
<8,O,1>=0BH */
for(i=0;i<=16;i++){
while(!(inportb(PORT+LSR) & 0x20)); /* wait until THR empty */
outportb(PORT+THR,tdat[i]); /* send data to THR */
}
i=0;
while(!kbhit()){
if(inportb(PORT+LSR) & 0x01){ /* b0==1, read data ready */
rdat[i++]=inportb(P
ORT+RDR); /* read data form RDR */
} } }
ωέΎδΘϟ Ϧϣ ϝΎϘΘϧϻ ΩΩήΗ
1
ωέΎδΘϟ ϰϟ
2
ϊϨμϤϟ ςΒο
:
0.00
ϝΎϘΘϧϻ ΩΩήΗ
ΆσΎΒΘϟ Ϧϣ
1
ΆσΎΒΘϟ ϰϟ
2
ϊϨμϤϟ ςΒο
:
0.00
ΕΩΪϋϻ
0.01
ϰϟ
400.0
ΰΗήϫ
ΓΪΣϮϟ
:
0.10
ΰΗήϫ
0.00
ΔϠόϔϣ ήϴϏ
x
ϩάϫ
ϭ ωέΎδΘϟήϴϴϐΘϟ ϡΪΨΘδΗ ϒΎχϮϟ
ΆσΎΒΘϟ
ΩΎϤΘϋϹΎΑ
ΩΩήΘϟ ϰϠϋ
ϭ ϑΪϬϟ
ϞΧΪϤϟ ϰϠϋ ΪϤΘόΗ ϻ
ΔϴΟέΎΨϟ
.
ΔϳϮϟϭϷ
ωέΎδΘϟ Ϧϣί Ϧϣ ϰϠϋ ήΘϣέΎΒϟ άϬϟ
/
ΆσΎΒΘϟ
1
ωέΎδΘϟ ϭ
/
ΆσΎΒΘϟ
2
.
ϟ
ήϴϓϮΘ
ϲΎϘϠΘϟ
ϟ
ΔϗΎτϠ
ϊϨμϤϟ ςΒο
:
00
ΕΩΪϋϻ
00
ΔϴϠϤϋ
ϟ
φϔΤ
ϟ ϲΎϘϠΘϟ
ΔϠόϔϣ ήϴϏ ΔϗΎτϠ
01
ΔϴϠϤϋ
ΔϗΎτϠϟ ϲΎϘϠΘϟ φϔΤϟ
ΔϠόϔϣ
x
ϞϤόϳ ˬ ΔϠόϔϣ ΔϔϴχϮϟ ϩάϫ ϥϮϜΗ ΎϣΪϨϋ
ήϔϧϻ
ήΗ
ϟΎΑ
ΪϬΠ
ϞϣΎϜϟ
δϟ ΕήϴϐΗ ˯ΎϨΛ
Δϋή
.
ΔΘΑΎΜϟ Δϋήδϟ ΕήΘϓ ϲϓ
ΐδΤϳ
ήΗήϔϧϻ
ΜϣϷ ΝήΨϟ ΪϬΟ ΔϤϴϗ
ϞμΤϳ ΎϤΑέϭ ϞϤΤϠϟ Ϟ
ϰϠϋ
κϘϧ
30 %
ΝήΨϟ ΪϬΟ Ϧϣ
ϲϤψϋϷ
.