Môn Vi điều khiển Báo cáo Ứng dụng kỹ thuật tự động vào công nghiệp

45 2 0
Môn Vi điều khiển Báo cáo Ứng dụng kỹ thuật tự động vào công nghiệp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

LỜI NÓI ĐẦU LỜI NÓI ĐẦU Chúng ta đang sống ở thế kỷ 21, thế kỷ của khoa học cách mạng kỹ thuật Quang chúng ta có rất nhiều thiết bị hiện đại Ngày nay trong công nghiệp chúng ta thấy có rất nhiều bộ đi.

LỜI NÓI ĐẦU Chúng ta sống kỷ 21, kỷ khoa học cách mạng kỹ thuật.Quang có nhiều thiết bị đại.Ngày cơng nghiệp thấy có nhiều điều khiển khác có vi điều khiển PLC(Programble logic control) phổ biến rộng rãi Có thể nói ngày Robot tổ hợp khả hoạt động linh hoạt cấu điều khiển theo chương trình số,cũng chế tạo cảm biến,cơng nghệ lập trình,… Nhóm em học vi điều khiển, robot công nghiệp.Và làm mơ hình thực tế điều khiển VĐK Sau báo cáo nhóm em sau thực mơ hình I)ĐẶT VẤN ĐỀ Hiện nay, việc ứng dụng kỹ thuật tự động vào công nghiệp sử dụng rộng rãi Việt Nam Chính với mong muốn học hỏi ứng dụng kiến thức học vào công việc mong muốn chúng em tốt nghiệp Với suy nghĩ sau học xong mơn VĐK, chúng em hỗ trợ kiến thức để tự tay xây dựng mơ hình Mơ hình hệ thống chúng em chọn thực II)PHẦN CỨNG I) BẢN VẼ II) HÌNH ẢNH IV)SƠ ĐỒ MẠCH ĐIỆN 1)NÚT NHẤN LED: 2)MULTI_COTROLLER: 3)DK VAN: 4)USENSOR: 5)POWER: 6)MULTI_CONTROLLER: 7)MẠCH NGUỒN: 8)ZSENSOR: V)LƯU ĐỒ GIẢI THUẬT 1)LƯU ĐỒ SWITCH a)NÚT START: SWSTART Đ SWSTART=0 S Đ i++ i=1000 S ENB_START=1 i=0 EXIT b)NÚT STOP: SWSTOP Đ SWSTOP=0 Đ i++ i=1000 S S ENB_STOP=1 i=0 EXIT c)NÚT RESET: SWRESET Đ SWRESET=0 S Đ i++ i=1000 S ENB_RESET=1 i=0 EXIT 2)LƯU ĐỒ SENSOR: SENSOR Đ SS1=0 Đ i=1000 i++ S i=0 S SS1_ENB=1 i=0 EXIT SENSOR Đ SS2=0 Đ i=1000 i++ S i=0 S SS2_ENB=1 i=0 EXIT SENSOR Đ SS3=0 Đ i=1000 i++ S i=0 S SS3_ENB=1 i=0 EXIT SENSOR Đ SS4=0 Đ i=1000 i++ S i=0 S SS4_ENB=1 i=0 EXIT 3)LƯU ĐỒ LED,BUZZER: enb_reset=1;//? //>>>> xss_pass=0; yss_pass=0; xss_count=0; yss_count=0; xvector=0; yvector=0; xenbsmotor=1; yenbsmotor=1; enb_reset=1; hold=0; setspeed=60; framelxy= read_eeprom(0x04); framelxy++; write_eeprom(0x04,framelxy); if(framelxy==0) { framehxy= read_eeprom(0x05); framehxy++; write_eeprom(0x04,framehxy); if(framehxy==5) { framelxy=0; m=3; value=0x9f; StepXYv02.c running=0; write_eeprom(0x00,value); write_eeprom(0x01,m); disable_interrupts(GLOBAL); } } output_low(complete); } confirmp_exit: //******************************************** if((xss_pass==0)&(input(xss_point)==0)) { xss_count++; if(xss_count==200) { xss_pass=1; xss_count=0; } } if((xss_pass==1)&(input(xss_point)==1)) { xss_count++; if(xss_count==50) { xss_pass=0; xss_count=0; if(nextstepx==1) goto jumpass; xenbsmotor=0; jumpass: nextstepx=0; xready=0; if(xvector==1) pointx++; else pointx ; } // -if((yss_pass==0)&(input(yss_point)==0)) { yss_count++; if(yss_count==200) { yss_pass=1; yss_count=0; } } if((yss_pass==1)&(input(yss_point)==1)) { yss_count++; if(yss_count==50) { yss_pass=0; yss_count=0; yenbsmotor=0; yready=0; if(yvector==1) pointy++; else pointy ; } } if((xready==0)&(yready==0)) { hold=1; stready=0; // output_low(ready); output_high(ready); } } if(hold==1) { retimer++; if(retimer==5000) { retimer=0; output_low(lowpower); } } //================================ smotor_run: speed++; if(speed==setspeed) { speed=0; // -if(yenbsmotor==1) { yready=1; retimer=0; // output_high(ready); output_low(ready); output_high(lowpower); if(yvector==1)//stepy_mext: { sendy=font_sm[county]; county++; if (county>=8) county=0; } // -else//stepy_return: { sendy=font_sm[county]; county ; if (county==255) county=7; } // -if(xenbsmotor==1) { xready=1; retimer=0; // output_high(ready); output_low(ready); output_high(lowpower); if(xvector==1)//stepx_mext: { sendx=font_sm[countx]; countx++; if (countx>=8) countx=0; } else//stepx_return: { sendx=font_sm[countx]; countx ; if (countx==255) countx=7; } // sendy=sendy&(0xf0); sendx=sendx&(0x0f); sendb=sendy|sendx; output_b(sendy|sendx); exit_motor: //============================================= if(enb_reset==1)// { if(input(xss_offset)==0) { pointx=0; xvector=1; xenbsmotor=0; } if(input(yss_offset)==0) { yvector=1; yenbsmotor=0; } if((input(xss_offset)==0)&(input(yss_offset)==0)) { hold=1; countxy=0; pointx=0; enb_reset=0; output_high(ready); printf("\n\r>Reset "); } } else//While enb_reset==0 { if(countxy==0) { if(input(xss_offset)==0) { pointx=0; xvector=1; xenbsmotor=0; } if(input(yss_offset)==0) { yvector=1; yenbsmotor=0; } } } if(input(xss_over)==0) { xenbsmotor=0; pointx=13; xvector=0; } if(input(yss_over)==0) Page 9StepXYv02.c { yenbsmotor=0; pointy=10; yvector=0; } timer0_exit: set_timer0(250); } //&&&&&&&&&&&&&&&&&&&&&& void main: { set_tris_a(0x00);set_tris_b(0x00);set_tris_c(0xbf); set_tris_d(0xf8);set_tris_e(0x00); output_a(0xff);output_b(0xff);output_c(0xff); output_d(0xff);output_e(0xff); messager: printf("\n\r========================="); printf("\n\r->Model :May xep vi XY"); countx=0; county=0; reset_pass=0; enb_reset=0; output_low(lowpower); delay_ms(1000); value= read_eeprom(0x00); m= read_eeprom(0x01); if ((value==0x1f)&(m!=3)) { printf("\n\r->Ok! Confirm"); disable_interrupts(int_rda); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); set_timer0(250); enable_interrupts(int_timer0); enable_interrupts(GLOBAL); running=1; runenb=0; } else { while(m==3) { disable_interrupts(int_timer0); disable_interrupts(int_rda); // disable_interrupts(GLOBAL); printf("\n\r->Error Informations "); running=0; delay_ms(1000); goto messager; } printf("\n\r->Insert Confirm[1]:"); running=0; enable_interrupts(int_rda); enable_interrupts(GLOBAL); Page 10StepXYv02.c framelxy=0; write_eeprom(0x04,framelxy); framehxy=0; write_eeprom(0x05,framehxy); m=0; } //================================ while(true) { while(runenb==1) { k=0; m++; for(i=0;i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ldi r16,0xff out ddra,r16 out porta,r16 out ddrc,r16 out portc,r16 ldi r30,low(~timer) ldi r31,high(~timer) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> _voiman: rcall oclock rjmp _voiman ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> dislay: ;led0 _ ldi r23,0xff out portc,r23 ;ldi r26,0x00 //Digital lds r26,0x0100 rcall led0 ldi r23,0xfe out portc,r23 out porta,r25 rcall delays ;led1 _ ldi r23,0xff out portc,r23 ;ldi r26,0x01 //Digital lds r26,0x0101 rcall led0 ldi r23,0xfd out portc,r23 out porta,r25 rcall delays ;led2 _ ldi r23,0xff out portc,r23 //ldi r26,0x02 //Digital lds r26,0x0102 rcall led0 ldi r23,0xfb out portc,r23 out porta,r25 rcall delays ;led3 _ ldi r23,0xff out portc,r23 ;ldi r26,0x03 //Digital lds r26,0x0103 rcall led0 ldi r23,0xf7 out portc,r23 out porta,r25 rcall delays ;led4 _ ldi r23,0xff out portc,r23 ;ldi r26,0x04 //Digital lds r26,0x0104 rcall led0 ldi r23,0xef out portc,r23 out porta,r25 rcall delays ;led5 _ ldi r23,0xff out portc,r23 ;ldi r26,0x05 //Digital lds r26,0x0105 rcall led0 ldi r23,0xdf out portc,r23 out porta,r25 rcall delays dislay_exit: ret ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;bcd in r26 ;7seg out r25 bcd_7seg: led0: cpi r26,0x00 brne st1 ldi r25,0xc0 rjmp exit0 st1: cpi r26,0x01 brne st2 ldi r25,0xf9 rjmp exit0 st2: cpi r26,0x02 brne st3 ldi r25,0xa4 rjmp exit0 st3: cpi r26,0x03 brne st4 ldi r25,0xb0 rjmp exit0 st4: cpi r26,0x04 brne st5 ldi r25,0x99 rjmp exit0 st5: cpi r26,0x05 brne st6 ldi r25,0x92 rjmp exit0 st6: cpi r26,0x06 brne st7 ldi r25,0x82 rjmp exit0 st7: cpi r26,0x07 brne st8 ldi r25,0xf8 rjmp exit0 st8: cpi r26,0x08 brne st9 ldi r25,0x80 rjmp exit0 st9: cpi r26,0x09 brne exit0 ldi r25,0x90 rjmp exit0 exit0: ret ;=================================== .defss= r20 defmm= r21 defhh= r22 equtimer =2000 oclock: inc r30 brne oclock_esc inc r31 brne oclock_esc ldi r30,low(~timer) ldi r31,high(~timer) inc ss cpi ss,0x3c brne oclock_exit ldi ss,0xff inc mm cpi mm,0x3c brne oclock_exit ldi mm,0xff inc hh cpi hh,0x18 brne oclock_exit ldi hh,0xff oclock_exit: mov bcd0,ss ldi bcd1,0x00 rcall hex_bcd sts 0x0100,bcd0 sts 0x0101,bcd1 mov bcd0,mm ldi bcd1,0x00 rcall hex_bcd sts 0x0102,bcd0 sts 0x0103,bcd1 mov bcd0,hh ldi bcd1,0x00 rcall hex_bcd sts 0x0104,bcd0 sts 0x0105,bcd1 oclock_esc: rcall dislay ret ;=================================== scan_led7seg: ret ;=================================== hex_bcd: def bcd0=r23 def bcd1=r24 ldi r16,0x0a //m=10 cp bcd0,r16 //if bcd0>=m brsh hex_bcd_next rjmp hex_bcd_exit hex_bcd_next: subi bcd0,0x0a //bcd0-10 inc bcd1 //j++ rjmp hex_bcd hex_bcd_exit: ret ;=================================== delays: inc r0 brne delays ;inc r1 ;brne delays Ret equmfonts =0x0100 equmsize =8 ; - mled8x8: cpi r28,0x00 brne mled8x8_byte1 ldi r29,0x00 out portc,r29 ldi r29,~0xfe out porta,r20 out portc,r29 rjmp mled8x8_nexti ; - mled8x8_byte1: cpi r28,0x01 brne mled8x8_byte2 ldi r29,0x00 out portc,r29 ldi r29,~0xfd out porta,r21 out portc,r29 rjmp mled8x8_nexti ; - mled8x8_byte2: cpi r28,0x02 brne mled8x8_byte3 ldi r29,0x00 out portc,r29 ldi r29,~0xfb out porta,r22 out portc,r29 rjmp mled8x8_nexti ; - mled8x8_byte3: cpi r28,0x03 brne mled8x8_byte4 ldi r29,0x00 out portc,r29 ldi r29,~0xf7 out porta,r23 out portc,r29 rjmp mled8x8_nexti ; - mled8x8_byte4: cpi r28,0x04 brne mled8x8_byte5 ldi r29,0x00 out portc,r29 ldi r29,~0xef out porta,r24 out portc,r29 rjmp mled8x8_nexti ; - mled8x8_byte5: cpi r28,0x05 brne mled8x8_byte6 ldi r29,0x00 out portc,r29 ldi r29,~0xdf out porta,r25 out portc,r29 rjmp mled8x8_nexti ; - mled8x8_byte6: cpi r28,0x06 brne mled8x8_byte7 ldi r29,0x00 out portc,r29 ldi r29,~0xbf out porta,r26 out portc,r29 rjmp mled8x8_nexti ; - mled8x8_byte7: cpi r28,0x07 brne mled8x8_byte8 ldi r29,0x00 out portc,r29 ldi r29,~0x7f out porta,r27 out portc,r29 rjmp mled8x8_nexti ; - mled8x8_byte8: cpi r28,0x08 brne mled8x8_nexti ldi r28,0x00 ldi r29,0x00 out portc,r29 out porta,r29 rcall delays rjmp mled8x8_exit mled8x8_nexti: inc r28 rcall delays mled8x8_exit: ret ;============================================== delays: inc r10 brne delays ret 6)Xilanh .include"m16def.inc" org 0x0000 equ ss1=0 equ ss2=1 equ end=0 equ z1=2 equ z1contr=0x100 st1x2: lds r24,z1cont sbrs r24,enbz1 rjmp exit sbic pinc,ss2 rjmp st2x sbic pinc,ss1 rjmp sbi portc,z1 rjmp st2x: sbic pina,ss2 rjmp exit sbic pinc,ss1 rjmp exit cbi portc,z1 exit: ret 7)Sensor .include"m16def.inc" .org 0x0000 equ ss1=0 equ i=0x100 equ il=0x100 equ ih=0x101 equ z1ss=0x60 equ z1s1=0,z1s2=1 rjmp _reset _reset: ldi r16,low(ramend) out spl,r16 ldi r17,high(ramend) out sph,r17 setup_ports: ldi r16,0x00 out ddrb,r16 ldi r17,0xff out ddrc,r17 voidmain: rjmp voidmain: sensor: sbic pinb,ss1 rjmp exit lds r16,il inc r16 sts il,r16 brne exit lds r17,ih inc r17 sts ih,r17 brne exit ldi r16,0x00 sts il,r16 ldi r17,0x00 sts ih,r17 ldi r16,(1

Ngày đăng: 01/01/2023, 16:23

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan