PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > PIC - Thiết kế và Ứng dụng

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Bài Trong Ngày Vi điều khiển

PIC - Thiết kế và Ứng dụng Ý tưởng cho các sản phẩm sử dụng PIC/dsPIC và các sản phẩm của Microchip

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 08-05-2011, 04:06 PM   #1
friend_1990
Đệ tử 3 túi
 
Tham gia ngày: Apr 2011
Bài gửi: 56
:
cần giúp đỡ đọc nhiệt độ từ pic 16f877a hiện thị lên matrix

chào các bác!!!!!!!!!!!!11111
tui gặp vấn đề truyền dữ liệu từ pic 16f877a xuống led matran
vấn đề là khi tui đọc nhiệt độ từ lm 35 nhưng không biết khai báo sai o đâu mà không xuất dữ liệu được
bác nào cao tay ấn chỉ giúp dùm chỗ sai nha!!!!!!!!!!!!11
sau dây là code mình:


#include<16f877a.h>
#fuses nowdt,noprotect,nolvp,xt,put
#device 16f877*=16 ADC=8
#use delay(clock=4000000)
#use fast_io(a)
#use fast_io(d)
#use fast_io(c)
#byte porta=0x5
#byte portd=0x8
#byte portc=0x7
#bit data=portc.2
#bit shcp=portc.0
#bit shtp=portc.1
#bit hl0=portd.0
#bit hl1=portd.1
#bit hl2=portd.2
#bit hl3=portd.3
#bit hl4=portd.4
#bit hl5=portd.5
#bit hl6=portd.6
#bit hl7=portd.7
void doc_adc();
void xoahang();
void quetcotdo();
int chuc,donvi,nghin,bienhang,dem,i,j;
void hienthi();
int maquet[18];
void xuathang();
int8 const maso[] = {
0x0FF,0x7B,0x7D,0x0,0x7F,0x7F,0x0FF,0x0FF
0x0FB,0x1D,0x5E,0x5E,0x6D,0x73,0x0FF,0x0FF
0x0BD,0x7E,0x7E,0x76,0x76,0x89,0x0FF,0x0FF
0x8F,0x0B7,0x0BB,0x0BD,0x0E,0x0BF,0x0FF,0x0FF
0x0FF,0x0B8,0x7A,0x7A,0x7A,0x86,0x0FF,0x0FF
0x0FF,0x87,0x73,0x75,0x76,0x8E,0x0FF,0x0FF
0x0FF,0x0FE,0x0FE,0x0FE,0x6,0x0FA,0x0FC,0x0FF
0x0FF,0x89,0x76,0x76,0x76,0x89,0x0FF,0x0FF
0x0FF,0x0F1,0x6E,0x6E,0x6E,0x6E,0x81,0x0FF
};

void main()
{float x;
set_tris_a(0b000001);
set_tris_d(0);
set_tris_c(0);
xoahang();
while(1)
{
doc_adc();
x=read_adc();
x=x/2.049;
hienthi();
}
}
void xoahang()
{
hl0=1;
hl1=1;
hl2=1;
hl3=1;
hl4=1;
hl5=1;
hl6=1;
hl7=1;
}
void doc_adc()
{
setup_adc(adc_clock_internal);
setup_adc_ports(AN0);
set_adc_channel(0);
delay_us(100);
}
void hienthi()
{float x;
int chuc,donvi,nghin,bienhang,dem,i,j,y;
chuc=0;
donvi=0;
y=x;
chuc=y/10;
donvi=y%10;

quetcotdo();

}
void tramaquet()
{
maquet[0]=maso[donvi*8];
maquet[1]=maso[donvi*8+1];
maquet[2]=maso[donvi*8+2];
maquet[3]=maso[donvi*8+3];
maquet[4]=maso[donvi*8+4];
maquet[5]=maso[donvi*8+5];
maquet[6]=maso[donvi*8+6];
maquet[7]=maso[donvi*8+7];
maquet[8]=0x00;

maquet[9]=maso[chuc*8];
maquet[10]=maso[chuc*8+1];
maquet[11]=maso[chuc*8+2];
maquet[12]=maso[chuc*8+3];
maquet[13]=maso[chuc*8+4];
maquet[14]=maso[chuc*8+5];
maquet[15]=maso[chuc*8+6];
maquet[16]=maso[chuc*8+7];
maquet[17]=0x00;
}
void quetcotdo()
{
data=0;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=0;
xuathang();
delay_us(500);
xoahang();


data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=1;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=2;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=3;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=4;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=5;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=6;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=6;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=7;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=8;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=9;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=10;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=11;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=12;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=12;
xuathang();
delay_us(500);
xoahang();


data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=13;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=14;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=15;
xuathang();
delay_us(500);
xoahang();


data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=16;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=17;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=18;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=19;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=19;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=20;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=21;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=22;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=23;
xuathang();
delay_us(500);
xoahang();

data=1;
shcp=0;shcp=1;
shtp=0;shtp=1;
bienhang=24;
xuathang();
delay_us(500);
xoahang();
}
void xuathang()
{
if(bit_test(maquet[bienhang],0))
{
hl0=0;
goto hang1;
}
hl0=1;
hang1:
if(bit_test(maquet[bienhang],1))
{
hl1=0;
goto hang2;
}
hl1=1;
hang2:
if(bit_test(maquet[bienhang],2))
{
hl2=0;
goto hang3;
}
hl2=1;
hang3:
if(bit_test(maquet[bienhang],3))
{
hl3=0;
goto hang4;
}
hl3=1;
hang4:
if(bit_test(maquet[bienhang],4))
{
hl4=0;
goto hang5;
}
hl4=1;
hang5:
if(bit_test(maquet[bienhang],5))
{
hl5=0;
goto hang6;
}
hl5=1;
hang6:
if(bit_test(maquet[bienhang],6))
{
hl6=0;
goto hang7;
}
hl6=1;
hang7:
if(bit_test(maquet[bienhang],7))
{
hl7=0;
goto hang8;
}
hl7=1;
hang8:;
}



do kỹ năng còn yếu kém mong được sự giúp đõ từ các pro hay những người đã từng làm
thanks các bác nhiều!!!!!!!!!!!!!!!!!!!!!!!!!!
dưới là file protuse kèm theo
File Kèm Theo
File Type: rar protues.rar (35.1 KB, 55 lần tải)
friend_1990 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 


Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 02:56 PM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam