Nghiên cứu, thiết kế bộ tổ hợp tần số theo phương pháp tổ hợp số trực tiếp

BỘ QUỐC PHÒNG CỘNG HOÀ Xà HỘI CHỦ NGHĨA VIỆT NAM HỌC VIỆN KTQS Độc lập -Tự do -Hạnh phúc KHOA: VÔ TUYẾN ĐIỆN TỬ . d€˜ Phê chuẩn Độ mật: Ngày tháng năm 2005 Số: CHỦ NHIỆM KHOANHIỆM VỤ ĐỒ ÁN TỐT NGHIỆP Họ và tên: Lớp: Thông tin Khoá 35 Ngành: Điện- Điện tử Chuyên ngành: Viễn thông 1. Tên đồ án: Nghiên cứu thiết kế bộ tổ hợp tần số theo phương pháp tổ hợp số trực tiếp 2. Các số liệu ban đầu: . 3. Nội dung bản thuyết minh: Chương 1: Các đặc điểm thông tin vô tuyến quân sự sóng cực ngắn Chương 2: Các phương pháp tổng hợp tần số Chương 3: Thiết kế chế tạo modun tổ hợp tần số theo phương pháp tổ hợp số trực tiếp 4. Số lượng, nội dung các bản vẽ và các sản phẩm cụ thể (nếu có) Số lượng: bản vẽ A0 Nội dung: 5. Cán bộ hướng dẫn: Thượng tá, PGS.TS Đinh Thế Cường, Chủ nhiệm khoa Vô Tuyến Điện Tử - Khoa Vô tuyến điện tử - Học Viện Kỹ Thuật Quân Sự Ngày giao: 18/ 03/ 2005. Ngày hoàn thành: 20/ 06/ 2005. Hà nội, ngày .tháng .năm 2005. Chủ nhiệm bộ môn Cán bộ hướng dẫn PGS.TS. Đã hoàn thành và nộp đồ án ngày 20 tháng 06 năm 2005 Học viên thực hiện

doc12 trang | Chia sẻ: lvcdongnoi | Lượt xem: 2508 | Lượt tải: 1download
Bạn đang xem nội dung tài liệu Nghiên cứu, thiết kế bộ tổ hợp tần số theo phương pháp tổ hợp số trực tiếp, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
//AD9850 Setup #include #include #include #include #define ConFig 0x38 #define EnTryMode 0x06 #define HomeCursor 0x02 #define ClrDspl 0x01 #define offBlink 0x0c #define Blink 0x0e #define row1 0x00 #define row2 0x40 #define row3 0x10 #define row4 0x50 #define LCD_E P0_7 #define LCD_RW P0_6 #define LCD_RS P0_5 void curLCD(unsigned char vitri); void initLCD(); void busyLCD(); void ghilenhLCD(unsigned char lenh); void ghiLCD(unsigned char dulieu); void clrscr(); void offBlinkf(); void Blinkf(); void printstr(unsigned char *s1); void line1(unsigned char x); void line2(unsigned char x); void line3(unsigned char x); void line4(unsigned char x); void delay(); #define SDA P0_0 // pin5 #define SCL P0_1 // pin6 void start(); void stop(); unsigned char clock(); void ack(); void nack(); void out_byte(unsigned char byte); unsigned char get_byte(); void dummy_write(unsigned int addr); void seq_read(int current,int no_bytes,int addr,unsigned char *bytes); void seq_write(int no_bytes,int addr,unsigned char *bytes); #define DATA P3_5 #define FQ_UD P3_7 #define W_CLK P3_6 #define Enter P1_6 #define Change_val P1_1 #define Cursor P1_4 #define value 53.6870912//4294967296=2^32 //53.6870912=2^32 : 80000000Hz unsigned long Freqency; //Delta_phase = Freqency * value unsigned char Freq[8],buffer_cursor,chanel; bit e_write; void delayX(unsigned int x); void Setup(unsigned long bFreqency); void init(); void Shift_Cursor(); void Shift_Freq(); void read_chanel(unsigned char bchanel); void write_chanel(unsigned char bchanel); void display(); /*********************************************************/ void delay() { unsigned int i; for(i=1;i<=10;i++){} } /**********************************************************/ void delayX(unsigned int x) { unsigned int i; for(i=1;i<=x;i++){} } /************************* LCD *****************************/ void initLCD() { unsigned char i; LCD_RS =0; LCD_RW =0; LCD_E =0; P2=0x30; LCD_E =1; for(i=1;i<=5;i++){} LCD_E =0; delay(); P2=0x30; LCD_E =1; for(i=1;i<=5;i++){} LCD_E =0; delay(); P2=0x30; LCD_E =1; for(i=1;i<=5;i++){} LCD_E =0; for(i=1;i<=5;i++){} busyLCD(); ghilenhLCD(ConFig); ghilenhLCD(ClrDspl); ghilenhLCD(EnTryMode); ghilenhLCD(offBlink); } /*******************************************/ void busyLCD() { unsigned char j; P2=0xff; LCD_RW =1; LCD_RS =0; LCD_E =0; w_lcd: P2=0xff; LCD_E =1; j=P2&0x80; LCD_E =0; if(j!=0) goto w_lcd; } /***********************************/ void ghilenhLCD(unsigned char lenh) { LCD_RW =0;LCD_RS =0;LCD_E =0; P2=lenh; LCD_E =1; LCD_E =0; busyLCD(); } /*************************************/ void ghiLCD(unsigned char dulieu) { LCD_RW =0;LCD_RS =1;LCD_E =0; P2=dulieu; LCD_E =1; LCD_E =0; busyLCD(); } /*************************************/ void curLCD(unsigned char vitri) { vitri=vitri|0x80; ghilenhLCD(vitri); } /*************************************/ void printstr(unsigned char *s1) { char *s; s=s1; do{ #ifdef SERIAL put(*s); #else ghiLCD(*s); #endif s++; } while (*s!='*' && *s!=0); } /***********************************************/ void clrscr(){ghilenhLCD(ClrDspl);} void offBlinkf(){ghilenhLCD(offBlink);} void Blinkf(){ghilenhLCD(Blink);} void line1(unsigned char x){curLCD(row1+x);} void line2(unsigned char x){curLCD(row2+x);} void line3(unsigned char x){curLCD(row3+x);} //void line4(unsigned char x){curLCD(row4+x);} /**********************************************/ /******************* Ma nguon cho AT24C64 *************************/ void start() { SCL=1;SDA=1; SDA=0; SCL=0; } /*************************************************/ void stop() { SDA=0; SCL=1; SDA=1; } /*************************************************/ unsigned char clock() { unsigned char level; SCL=1; if(SDA==1) level=1; else level=0; SCL=0; return(level); } /************************************************/ void ack() { SDA=0; clock(); /* master sends acknowledge */ } /**************************************************/ void nack() { SDA=1; /* master receives acknowledge */ clock(); } /***************************************************/ void out_byte(unsigned char byte) { char count; e_write=0; /* send data to EEPROM */ for (count=0;count<=7;count++) { if ((byte & 0x80)==0) /* one bit at a time */ SDA=0; else SDA=1; byte = byte << 1; /* shift for next bit */ clock(); } SDA=1; SCL=1; if(SDA==1) e_write=1; SCL=0; } /****************************************************/ unsigned char get_byte() { unsigned char count,byte; bit temp; byte = 0; /* read data from EEPROM */ for (count=0;count<=7;count++) { byte=byte << 1; /* one bit at a time */ SDA=1; SCL=1; temp=SDA; /* input bit from port */ if (temp == 1) byte = byte | 0x01; SCL=0; } return(byte); } /************************************************************/ void dummy_write(unsigned int addr) { unsigned char temp; begin: start(); out_byte(0xA0); /* Microchip and Atmel slave address */ if(e_write==1) { stop();goto begin;} temp = (unsigned char)((addr & 0xFF00) >> 8); /* construct first address byte */ out_byte(temp); if(e_write==1) { stop();goto begin;} temp = (unsigned char)(addr & 0xFF); /* construct second address byte */ out_byte(temp); if(e_write==1) { stop();goto begin;} } /***************************************************************/ void seq_read(int current,int no_bytes,int addr,unsigned char *bytes) { int n; if(current==0) /* random read? */ begin2: dummy_write(addr); /* yes, send address */ start(); /* no */ out_byte(0xA1); /* slave address for Atmel and Microchip */ if(e_write==1) { stop();goto begin2;} /* sequentially read data */ for (n=0;n<no_bytes-1;n++) { bytes[n] = get_byte(); /* in loop and send acknowledges */ ack(); } bytes[no_bytes-1]=get_byte(); /* for last databyte, don't */ nack(); stop(); /* send acknowledge */ } /*************************************************************/ void seq_write(int no_bytes,int addr,unsigned char *bytes) { int n; begin1: dummy_write(addr); /* send address to EEPROM */ for (n=0;n<no_bytes;n++) { out_byte(bytes[n]); /* loop and send data bytes */ if(e_write==1) { stop(); goto begin1;} } /* poll for cycle completion */ stop(); } /**********************************************/ void main() { init(); while(1) { if(Enter ==0){ delayX(30000); write_chanel(chanel); seq_write(1,108,&chanel); Setup(Freqency); clrscr();delayX(10000); display(); clrscr();delayX(10000); display(); } if(Cursor ==0){ delayX(30000); Shift_Cursor(); } if(Change_val==0){ delayX(30000); Shift_Freq(); } } } //********************************************* void Shift_Cursor() { if(buffer_cursor==2) {buffer_cursor=6;line3(buffer_cursor);return;} if((buffer_cursor>=6)&&(buffer_cursor<=13)) { buffer_cursor=buffer_cursor+1; if(buffer_cursor>=14)buffer_cursor=2; line3(buffer_cursor); } } //********************************************* void Shift_Freq() { if(buffer_cursor==6) { if(Freq[0]!=1)Freq[0]=1; display(); return; } if(buffer_cursor==2) { chanel = chanel+1; if(chanel > 9)chanel=0; read_chanel(chanel); //doc du lieu kenh ra Setup(Freqency); //thiet lap tan so seq_write(1,108,&chanel); //ghi vao kenh hien hanh display(); return; } if((buffer_cursor>6)&&(buffer_cursor<=13)) { Freq[buffer_cursor-6]=Freq[buffer_cursor-6]+1; if(Freq[buffer_cursor-6]>9)Freq[buffer_cursor-6]=0; display(); } } //********************************************* void init() { delayX(100); initLCD(); DATA = 0; W_CLK = 0; FQ_UD = 0; FQ_UD = 1; delay(); FQ_UD = 0; delay(); FQ_UD = 1; delay(); FQ_UD = 0; delay(); seq_read(0,1,108,&chanel);//kenh hien hanh if(chanel>9){chanel=0;read_chanel(0);seq_write(1,108,&chanel);} read_chanel(chanel); Setup(Freqency); buffer_cursor = 2; display(); Blinkf(); } //********************************************* void display() { unsigned char i; clrscr(); line1(0); printstr(" DDS AD9850 *"); line2(0); printstr("================*"); line3(0); printstr("CH*"); ghiLCD(chanel + '0'); ghiLCD(':'); line3(6); for(i=0;i<8;i++)ghiLCD(Freq[i] + '0'); printstr("Hz*"); line3(buffer_cursor); } //********************************************* void Setup(unsigned long bFreqency) { unsigned long Delta_phase,tam; unsigned char i,control,tam1; Delta_phase = (unsigned long)(bFreqency * value); for(i=0;i<32;i++) { tam = Delta_phase & 1 ; if(tam == 0) { DATA = 0; } else { DATA = 1; } W_CLK = 1; delay(); W_CLK = 0; delay(); Delta_phase = Delta_phase >> 1; } control = 0x00;//00000000 --> W39 ... W32 for(i=0;i<8;i++) { tam1 = control&1; if(tam1==0)DATA = 0; else DATA = 1; W_CLK = 1; delay(); W_CLK = 0; delay(); control = control >> 1; } FQ_UD = 1; //Xac nhan tan so moi delay(); FQ_UD = 0; }//******************************************************************************* void read_chanel(unsigned char bchanel) { unsigned char i; for(i=0;i<8;i++){seq_read(0,1,bchanel*10+i,&Freq[i]);} Freqency = Freq[0]*10000000 + Freq[1]*1000000 + Freq[2]*100000 + Freq[3]*10000 + Freq[4]*1000 + Freq[5]*100 + Freq[6]*10 + Freq[7]; if((Freqency=20000000)) { Freq[0]=1; Freq[1]=0; Freq[2]=0; Freq[3]=0; Freq[4]=0; Freq[5]=0; Freq[6]=0; Freq[7]=0; //chanel++;if(chanel>9)chanel=0; write_chanel(chanel); seq_write(1,108,&chanel); } } //******************************************************************************* void write_chanel(unsigned char bchanel) { unsigned char i; for(i=0;i<8;i++){seq_write(1,bchanel*10+i,&Freq[i]);} Freqency = Freq[0]*10000000 + Freq[1]*1000000 + Freq[2]*100000 + Freq[3]*10000 + Freq[4]*1000 + Freq[5]*100 + Freq[6]*10 + Freq[7]; }

Các file đính kèm theo tài liệu này:

  • docAD9850 Setup.doc
  • rarcan in.rar
  • docdon bichQKTD.doc
  • docdon.doc
  • docdontt.doc
  • rarmachdien.rar
  • rarmachin.rar
  • docmuc luc.doc
  • rarphu.rar
  • rarPhuluc.rar
  • docpll.doc
  • docVIET TATbich.doc