intTypePromotion=3

Giáo trình thiết kế thiết bị bán dẫn chứa các mạch logic điện tử có khả năng xử lý dữ liệu p8

Chia sẻ: Safs Gdfghdf | Ngày: | Loại File: PDF | Số trang:11

0
49
lượt xem
5
download

Giáo trình thiết kế thiết bị bán dẫn chứa các mạch logic điện tử có khả năng xử lý dữ liệu p8

Mô tả tài liệu
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Dòng khởi động của động cơ là: Ikđ =(5 ữ7 ).In = (5 ữ7 ).0,625 = 3,125 ữ 4,375 A làm khoá đóng cắt cho động cơ làm việc. Dòng qua C828 đ−ợc xác định như,Sơ đồ mạch động lực điều khiển tốc độ quay động cơ Động cơ điện một chiều ta sử dụng có công suất định mức Pn = 15 W

Chủ đề:
Lưu

Nội dung Text: Giáo trình thiết kế thiết bị bán dẫn chứa các mạch logic điện tử có khả năng xử lý dữ liệu p8

  1. 78 LUAÂÄN VAÊN TOÁT NGHIEÄP extern int GetMtx(); extern int GetMty(); //extern EVENT OldEvent(); extern int Double(LPEVENT); #endif // End of MOUSE.H IX.MODULE MOUSE.CPP #include #include //#include #include #include "mouse.h" void SetMouseRange(LPRECT lpRect) // Dat vung di chuyen cho chuot { _AX = 0x07;//ham 07 cua ngat 33 de dinh gioi han di chuyen ngang _CX = lpRect->left; _DX = lpRect->right; geninterrupt(INT_MOUSE);//INT_MOUSE=0x33:ngat 33 _AX = 0x08;//ham 08 cua ngat 33 dinh gioi han di chuyen doc cho con tro _CX = lpRect->top; _DX = lpRect->bottom; geninterrupt(INT_MOUSE); } //--------------------------------------------------------- int InitMouse(LPRECT lpRect) // Khoi dong chuot { int ax; _AX = 0; geninterrupt(INT_MOUSE); ax = _AX; if (ax == 0) return FALSE; SetMouseRange(lpRect); return TRUE; } //--------------------------------------------------------- void ShowMouse(void) // Hien thi chuot { _AX = 1; geninterrupt(INT_MOUSE); } //--------------------------------------------------------- void HideMouse(void) // Dau chuot { _AX = 2; geninterrupt(INT_MOUSE); } //--------------------------------------------------------- #include #include void MouseRead(LPEVENT lpEvent) // Tra ve bien co nhan duoc tu chuot : Nut trai hay phai duoc an {
  2. 79 LUAÂÄN VAÊN TOÁT NGHIEÄP int bx; _AX = 3; geninterrupt(INT_MOUSE); bx = _BX; //cx = _CX; //dx = _DX; lpEvent->Msg = bx; lpEvent->Posx = _CX; lpEvent->Posy = _DX; gettime(lpEvent->t); } //--------------------------------------------------------- void ResetEvent(LPEVENT lpEvent) { lpEvent->Msg = 0; lpEvent->Posx = lpEvent->Posy = 0; } //--------------------------------------------------------- EVENT PrevEvent, CurEvent; //--------------------------------------------------------- LPEVENT GetEvent(void) { ResetEvent(&CurEvent); MouseRead(&CurEvent); // chuyen sang toa do ViewPort CurEvent.Posx = CurEvent.Posx-MainWindow.rViewPort.left; CurEvent.Posy = CurEvent.Posy-MainWindow.rViewPort.top; // xet trang thai chuot co thay doi hay khong if((CurEvent.Posx!=PrevEvent.Posx)&&(CurEvent.Posy!=PrevEvent.Posy)) CurEvent.Msg |= M_CHANGE; PrevEvent = CurEvent; // delay(50); return (&CurEvent); } //--------------------------------------------------------- void DeviceRelease(int Msg) { while(GetEvent()->Msg&Msg); } //--------------------------------------------------------- int Double(LPEVENT lpEvent) { if(lpEvent->Msg==1) { delay(100); ResetEvent(lpEvent); lpEvent=GetEvent(); if(lpEvent->Msg==1) //if((abs(CurEvent.Posx-oldEvent.Posx))
  3. 80 LUAÂÄN VAÊN TOÁT NGHIEÄP void MouseText(int x,int y,int color1,int color2)//,char s[])//gia dau nhay con tro { HideMouse(); // int h=textheight(s); int w=5; int color=getcolor(); do { for(int i=0;i
  4. 81 LUAÂÄN VAÊN TOÁT NGHIEÄP RECT rSys; /*System area of window*/ RECT rTitleBar; /*Caption area of window*/ RECT rMenuBar; /*Rectangle in which window's menu is located*/ RECT rMessage; /* Rectangle in which messages is display }WINDOWS; // Dinh nghia cac ham va bien dung toan cuc extern int Xc, Yc; // Goc toa do extern int LineColor; extern int VP_WIDTH; extern int VP_HEIGHT; extern WINDOWS MainWindow; extern void InitGraphics(void); extern void OutMessage(char *Msg); extern void InitScreen(void); extern void InitValues(char *lpCaption); extern int OutError(char *s); #endif // End of SCREEN.H XI.MODULE SCREEN.CPP #include #include #include #include #include #include "screen.h" #include "mouse.h" int T_SIZE, W_SIZE, H_SIZE, W_CHAR, H_CHAR, MSG_SIZE; int COLOR_WINDOW; int COLOR_BUTTON; int COLOR_BORDER; int COLOR_CAPTION; int COLOR_TEXT; int VP_WIDTH; int VP_HEIGHT; int Maxx, Maxy; // Maxx - Maxy of screen WINDOWS MainWindow; //int Xc, Yc; // Goc toa do //int LineColor = MAGENTA; // Mau cua duong thang can ve - Dung trong thu tuc SetPixel //--------------------------------------------------------- void InitGraphics(void) // Khoi tao che do do hoa { int grDrv=DETECT, grMode; int ErrCode; initgraph(&grDrv, &grMode, ""); ErrCode = graphresult(); if(ErrCode!= grOk) { printf("Graphics error: %s\n", grapherrormsg(ErrCode)); printf("Press any key to halt..."); getch(); exit(1); /* return with error code */ } Maxx = getmaxx();
  5. 82 LUAÂÄN VAÊN TOÁT NGHIEÄP Maxy = getmaxy(); } //--------------------------------------------------------- void InitValues(char *lpCaption) // Khoi tao cac gia tri cho bien Windows de ve cua so man hinh { int WinWidth, WinHeight; W_CHAR = 8; H_CHAR = 8; // Chieu rong va chieu cao cua mot ki tu W_SIZE = 8; H_SIZE = 20; T_SIZE = 18; MSG_SIZE = 20; COLOR_WINDOW = CYAN; COLOR_BUTTON = LIGHTGRAY; COLOR_BORDER = LIGHTGRAY; COLOR_CAPTION = BLUE; COLOR_TEXT = BLUE; strcpy(MainWindow.sCaption, lpCaption); // Gan gia tri cho WinRect - H.C.nhat chua cua so MainWindow.rWinRect.left = 0; MainWindow.rWinRect.top = 0; MainWindow.rWinRect.right = Maxx; MainWindow.rWinRect.bottom= Maxy; WinWidth = MainWindow.rWinRect.right-MainWindow.rWinRect.left+1; WinHeight= MainWindow.rWinRect.bottom-MainWindow.rWinRect.top+1; // Gan gia tri cho rSys - H.C.nhat chua SystemMenu MainWindow.rSys.left = BORDERSIZE; MainWindow.rSys.top = BORDERSIZE; MainWindow.rSys.right = MainWindow.rSys.left+T_SIZE; MainWindow.rSys.bottom= MainWindow.rSys.top+T_SIZE; // Gan gia tri cho rTitleBar - H.C.nhat chua thong tin thanh tieu de MainWindow.rTitleBar.left = BORDERSIZE+1;//MainWindow.rSys.right+1; MainWindow.rTitleBar.top = BORDERSIZE+1; MainWindow.rTitleBar.right = WinWidth-BORDERSIZE-1; MainWindow.rTitleBar.bottom= MainWindow.rSys.top+T_SIZE; // Gan gia tri cho rMenuBar - H.C.nhat chua thong tin menu // Gan gia tri cho rMessage - H.C.nhat chua thong tin cua cac //thong bao MainWindow.rMessage.left = BORDERSIZE+1; MainWindow.rMessage.right = WinWidth-BORDERSIZE-2; MainWindow.rMessage.top = WinHeight-(BORDERSIZE+2)-MSG_SIZE; MainWindow.rMessage.bottom= MainWindow.rMessage.top+MSG_SIZE; // Gan gia tri cho rViewPort - H.C.nhat chua thong tin ve vung lam viec // thuc su cua cua so MainWindow.rViewPort.left = BORDERSIZE+1; MainWindow.rViewPort.top = MainWindow.rTitleBar.bottom+2;//MainWindow.rMenuBar.bottom+2; MainWindow.rViewPort.right = WinWidth-BORDERSIZE-2; MainWindow.rViewPort.bottom= MainWindow.rMessage.top-2; VP_WIDTH = MainWindow.rViewPort.right-MainWindow.rViewPort.left; VP_HEIGHT = MainWindow.rViewPort.bottom-MainWindow.rViewPort.top; } //---------------------------------------------------------
  6. 83 LUAÂÄN VAÊN TOÁT NGHIEÄP void OutMessage(char *Msg) // Ghi thong bao Msg ra cua so rMessage { struct fillsettingstype FillInfo; int OldColor; struct viewporttype vp; // luu thong tin cu getfillsettings(&FillInfo); OldColor = getcolor(); getviewsettings(&vp); // xoa thong bao cu setviewport(MainWindow.rWinRect.left, MainWindow.rWinRect.top, MainWindow.rWinRect.right, MainWindow.rWinRect.bottom, 1); setfillstyle(SOLID_FILL, COLOR_BUTTON); setcolor(COLOR_TEXT); bar(MainWindow.rMessage.left, MainWindow.rMessage.top, MainWindow.rMessage.right, MainWindow.rMessage.bottom); // in thong bao moi ra outtextxy(MainWindow.rMessage.left+W_CHAR, MainWindow.rMessage.bottom-H_CHAR-5, Msg); // tra ve trang thai cu setfillstyle(FillInfo.pattern, FillInfo.color); setcolor(OldColor); setviewport(vp.left,vp.top, vp.right, vp.bottom, 1); } //--------------------------------------------------------- void DrawScreenBorder(int left, int top, int right, int bottom) // Ve duong vien cho mot hinh chu nhat co toa do (left, top), (right, bottom) { setfillstyle(SOLID_FILL, COLOR_BORDER); bar(left, top, right, top+BORDERSIZE); bar(left, bottom, right, bottom-BORDERSIZE); bar(left, top, left+BORDERSIZE, bottom); bar(right-BORDERSIZE, top, right, bottom); setcolor(BLACK); rectangle(left, top, right, bottom); rectangle(left+BORDERSIZE, top+BORDERSIZE, right-BORDERSIZE, bottom-BORDERSIZE); } //--------------------------------------------------------- #include void InitScreen(void) // Ve cac thanh phan cua cua so { int x, y; int WinWidth, WinHeight; struct viewporttype vp; getviewsettings(&vp); setviewport(MainWindow.rWinRect.left, MainWindow.rWinRect.top, MainWindow.rWinRect.right, MainWindow.rWinRect.bottom, 1); WinWidth = MainWindow.rWinRect.right-MainWindow.rWinRect.left+1; WinHeight= MainWindow.rWinRect.bottom-MainWindow.rWinRect.top+1; x = (WinWidth-W_CHAR*strlen(MainWindow.sCaption))/2+1; y = BORDERSIZE+(T_SIZE-H_CHAR)/2+1; // Ve duong vien cua hinh chu nhat DrawScreenBorder(0, 0, WinWidth-1, WinHeight-1);
  7. 84 LUAÂÄN VAÊN TOÁT NGHIEÄP delay(DEMODELAY); // Ve thanh tieu de setfillstyle(SOLID_FILL, COLOR_CAPTION); bar(MainWindow.rTitleBar.left, MainWindow.rTitleBar.top, MainWindow.rTitleBar.right, MainWindow.rTitleBar.bottom); setcolor(WHITE); outtextxy(x, y, MainWindow.sCaption); delay(DEMODELAY); // Ve SystemMenu setfillstyle(SOLID_FILL, COLOR_BUTTON); /* bar(MainWindow.rSys.left+1, MainWindow.rSys.top+1, MainWindow.rSys.right-1, MainWindow.rSys.bottom-1); setcolor(BLACK); rectangle((MainWindow.rSys.left+MainWindow.rSys.right)/2-5, (MainWindow.rSys.top+MainWindow.rSys.bottom)/2-1, (MainWindow.rSys.left+MainWindow.rSys.right)/2+5, (MainWindow.rSys.top+MainWindow.rSys.bottom)/2+1); delay(DEMODELAY); */ // Ve Menu // bar(MainWindow.rMenuBar.left, MainWindow.rMenuBar.top, // MainWindow.rMenuBar.right, MainWindow.rMenuBar.bottom); // outtextxy(MainWindow.rMenuBar.left+8, MainWindow.rMenuBar.bottom- 13, // "Menu of Program is here"); // delay(DEMODELAY); // Ve thanh chua thong bao bar(MainWindow.rMessage.left, MainWindow.rMessage.top, MainWindow.rMessage.right, MainWindow.rMessage.bottom); OutMessage("Welcome to Demo Window Program"); delay(DEMODELAY); // Ve vung lam viec setfillstyle(SOLID_FILL, COLOR_WINDOW); bar(MainWindow.rViewPort.left, MainWindow.rViewPort.top, MainWindow.rViewPort.right, MainWindow.rViewPort.bottom); setcolor(BLACK); rectangle(MainWindow.rViewPort.left-1, MainWindow.rViewPort.top, MainWindow.rViewPort.right+1, MainWindow.rViewPort.bottom); delay(DEMODELAY); // Dat lai viewport la rViewPort setviewport(MainWindow.rViewPort.left, MainWindow.rViewPort.top, MainWindow.rViewPort.right, MainWindow.rViewPort.bottom, 1); } //--------------------------------------------------------- /*void DrawSysCoordinates(void) // Ve he truc toa do { Xc = VP_WIDTH/2; Yc = VP_HEIGHT/2; setcolor(COLOR_TEXT); // ve hai truc toa do line(0, Yc, VP_WIDTH, Yc); line(Xc, 0, Xc, VP_HEIGHT); // ve hai mui ten line(Xc, 0, Xc-5, 5); line(Xc, 0, Xc+5, 5); line(VP_WIDTH, Yc, VP_WIDTH-5, Yc-5); line(VP_WIDTH, Yc, VP_WIDTH-5, Yc+5); // Ve goc toa do outtextxy(Xc-8, Yc+8, "O"); } //--------------------------------------------------------- void SetLineColor(int C)
  8. 85 LUAÂÄN VAÊN TOÁT NGHIEÄP { LineColor = C; } //--------------------------------------------------------- void SetPixel(int x, int y) { putpixel(Xc+x, Yc-y, LineColor); } //--------------------------------------------------------- void Set2Pixel(int Ox, int Oy, int x, int y) { putpixel(Ox+x, Oy-y, LineColor); putpixel(Ox-x, Oy-y, LineColor); } //--------------------------------------------------------- void Set2PixelHor(int Ox, int Oy, int x, int y) { putpixel(Ox+x, Oy-y, LineColor); putpixel(Ox+x, Oy+y, LineColor); } //--------------------------------------------------------- void ClearViewPort(void) { struct fillsettingstype FillInfo; // luu thong tin cu getfillsettings(&FillInfo); setfillstyle(SOLID_FILL, COLOR_WINDOW); bar(0, 0, VP_WIDTH, VP_HEIGHT); setfillstyle(FillInfo.pattern, FillInfo.color); DrawSysCoordinates(); } */ // End of SCREEN.C //--------------------------------------------------------- #include int OutError(char *s) { void far *buf;//con tro chi vung luu tru man hinh unsigned int size = imagesize(200,150,470,240); LPEVENT lpEvent; int Cx1=280,Cy1=203,Cx2=337,Cy2=223; int Ox1=350,Oy1=203,Ox2=405,Oy2=223; if ((buf = farmalloc(size)) == NULL) { return -1; } else { getimage(200,150,470,240,buf); } setfillstyle(SOLID_FILL,BLUE); HideMouse(); bar(200,150,470,240); setcolor(WHITE); rectangle(200,150,470,240); outtextxy(200+(270-8*strlen(s))/2,170,s); setfillstyle(SOLID_FILL,LIGHTBLUE); bar(Cx1,Cy1,Cx2,Cy2);//280,203,337,223); int OK=0; outtextxy(285,210,"Cancel"); outtextxy(365,210,"OK"); int event; do
  9. 86 LUAÂÄN VAÊN TOÁT NGHIEÄP { lpEvent=GetEvent(); if(kbhit()) { if((event=getch())==13) { CompleteOk: HideMouse(); putimage(200,150,buf,COPY_PUT); ShowMouse(); farfree(buf); return OK; } if(event==27) { CompleteCancel: HideMouse(); putimage(200,150,buf,COPY_PUT); ShowMouse(); farfree(buf); return 0; } if(event==9) { OK=!OK; Cancel: if(OK==0) { HideMouse(); setfillstyle(SOLID_FILL,BLUE); bar(Ox1,Oy1,Ox2,Oy2);//350,203,405,223); outtextxy(365,210,"OK"); setfillstyle(SOLID_FILL,LIGHTBLUE); bar(Cx1,Cy1,Cx2,Cy2);//280,203,337,223); outtextxy(285,210,"Cancel"); ShowMouse(); } Ok: if(OK==1) { HideMouse(); setfillstyle(SOLID_FILL,BLUE); bar(Cx1,Cy1,Cx2,Cy2);//280,203,337,223); outtextxy(285,210,"Cancel"); setfillstyle(SOLID_FILL,LIGHTBLUE); bar(Ox1,Oy1,Ox2,Oy2);//350,203,405,223); outtextxy(365,210,"OK"); ShowMouse(); } } if(event==0) { event=getch(); if(event==75) { OK=0; goto Cancel; } if(event==77) { OK=1; goto Ok; }
  10. 87 LUAÂÄN VAÊN TOÁT NGHIEÄP } else flushall(); } if(lpEvent->Msg==1) { if(lpEvent->Posx>=Cx1&&lpEvent->PosxPosy>=Cy1&&lpEvent->PosyPosx>=Ox1&&lpEvent->PosxPosy>=Oy1&&lpEvent->Posy
  11. 88 LUAÂÄN VAÊN TOÁT NGHIEÄP unsigned int Value1=0,Value2=0; char FindPos,FindValue; int Thoigian=0; FILE *f,*f1; char t,t1,t2,t3,t4; // char St_add[]="0000 Hex",End_add[]="000F Hex"; int end_line; strcpy(OutFile,InFile); i=strlen(OutFile); do { OutFile[i]='\0'; }while(OutFile[--i]!='.'); strcat(OutFile,"tmp");//dat ten cho file se tao ra for (FindPos=3;FindPos>=0;FindPos--) for(FindValue=0;FindValue=0;FindPos--) for(FindValue=0;FindValue

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản