|  | 
| 
 | Tài trợ cho PIC Vietnam | ||||||||
| Cơ bản về vi điều khiển và PIC Những bài hướng dẫn cơ bản nhất để làm quen với vi điều khiển PIC | 
|  | 
|  | Ðiều Chỉnh | Xếp Bài | 
|  16-09-2011, 11:01 AM | #1 | 
| Nhập môn đệ tử Tham gia ngày: Oct 2010 
					Bài gửi: 2
 : | 
				
				Giúp e cái code encoder này với mọi người ơi
			 E muốn đọc tốc độ từ encoder nhưng không biết sai ở đâu cả.Hixhix.Cả nhà giúp e với.E muốn đọc 2 encoder dùng 1 pic 16f877a.Dùng ngắt ngoài INT_EXT và TIMER0 tín hiệu vào là chân RB0 và RB1 e đã làm được rồi nhưng dùng ngắt RB thì ko biết lỗi ở đâu cả.Cả nhà test hộ e với. Đây là code ạ: #include <16f877a.h> #fuses HS, NOWDT,NOPROTECT , NOLVP #use delay(clock=20000000) #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8) #include <Lcd_lib_4bit.c> #include <stdlib.h> #include <stdlibm.h> int32 dem; int32 counterb; float speed; #INT_RB void encoder_ISR() { counterb++; // printf("\n\r%lu", counterb); } #INT_TIMER1 void Sampling_Time() { set_timer1(59286); ++dem; if(dem==5000) { dem=0; speed=(float)counterb/10; } } void main(void) { set_tris_B(0xFF); //counterb = 0; // port_b_pullups(TRUE); enable_interrupts(INT_RB); enable_interrupts(GLOBAL); enable_interrupts(INT_TIMER1); setup_timer_1(RTCC_INTERNAL|T1_DIV_BY_2); LCD_init(); //LCD_PutCmd(0x05); printf(LCD_PutChar,"Speed wind"); LCD_PutCmd(0xC0); printf(LCD_PutChar,"Speed %u v/s",speed); while (true) { } // disable_interrupts(INT_RB); //disable_interrupts(GLOBAL); set_timer1(59286); //port_b_pullups(TRUE); } | 
|   |   | 
|  03-10-2011, 12:12 AM | #2 | 
| Nhập môn đệ tử Tham gia ngày: Apr 2011 
					Bài gửi: 4
 : | Chu viet the thi chay the nao duoc | 
|   |   | 
|  | 
| 
 | 
 |