|
Tài trợ cho PIC Vietnam |
Giao tiếp USB, CAN, I2C, SPI, USART... Những giao tiếp được tích hợp trên PIC |
|
Ðiều Chỉnh | Xếp Bài |
21-05-2010, 08:43 AM | #1 |
Đệ tử 1 túi
Tham gia ngày: Dec 2009
Bài gửi: 24
: |
Sht71
xin mọi người xem giúp phần code cho SHT71 viết cho PIC6f88 sao không chạy? không bít sai chỗ nào nữa.ma mô phỏng toàn sai thôi!
Thank! code: #include <16f88.h> #include "def_88.h" #include <stdio.h> #fuses xt,nowdt,nolvp,noprotect #use delay(clock=4000000) #include "flex_lcd.c" #use i2c(master,sda=pin_a1,scl=pin_a0) #use rs232(baud=9600,parity=n,xmit=pin_a4,rcv=pin_a5) #use fast_io(a) #use fast_io(b) unsigned int tempH,tempL,doamH,doamL; float tempI,doamI; float tempF,doamF,doamFI; //hien thi so BCD void lcd_putnum(int8 x) { long y,z,t; //y=x/10; //lay hang chuc //z=x-y*10; //lay hang don vi //t=x*10-y*100-z*10; //lay phan le y=x/100; z=(x%100)/10; t=(x%100)%10; //chuyen qua ma ACSII lcd_putc(y+48); lcd_putc(z+48); lcd_putc(","); lcd_putc(t+48); } void main() { lcd_init(); trisa0=0; //cho cam bien on dinh delay_ms(15); //reset qua trinh i2c_start(); i2c_write(0xff); while(true) { i2c_start(); delay_ms(5); i2c_stop(); output_low(pin_a0);//keo SCK xuong muc 0 //phat mot lenh do nhiet do tempH=i2c_write(0x03); //doi cam bien do nhiet song trisa1=1; while(ra1==1) {} //doc gia tri nhiet do tra ve tempH=i2c_read(1); tempL=i2c_read(1); //tinh gia tri cua nhiet do tempI=tempH << 8 ;//dich sang trai 8 bit de lay bit cao tempI=tempI+tempL;// ghep thanh so 16 bit tempF=(tempI*0.01-40.1); //truyen ra cong noi tiep // tempF=(int8)(tempF*10); // trisb=0x00; // portb=tempF; lcd_gotoxy(1,1); lcd_putnum(tempF); //doc byte checksum cua SHT71 i2c_read(1); delay_ms(1000); } } thay đổi nội dung bởi: chungcb86, 21-05-2010 lúc 10:18 AM. |
21-05-2010, 12:47 PM | #2 |
Đệ tử 1 túi
Tham gia ngày: Dec 2009
Bài gửi: 24
: |
có ai giup đệ với!
Thank@@ |
04-05-2011, 05:57 PM | #3 |
Nhập môn đệ tử
Tham gia ngày: Oct 2010
Bài gửi: 1
: |
chào mọi người!
hiện mình đang cần một con SHT71, ai có bán thì liên hệ với mình nhé. sđt:01275834018 hoăc gmail:giang49ctu@gmail.com thanks! |
06-05-2011, 04:01 PM | #4 |
Nhập môn đệ tử
Tham gia ngày: Mar 2010
Bài gửi: 10
: |
Sao bạn lại dùng giao tiếp i2c để truyền giữa VDK và sht71? Trong datasheet của SHT71 có ghi rõ là (trang 2): The serial interface of the SHTxx is optimized for sensor readout
and power consumption and is not compatible with I2C interfaces. Bạn có thể xem driver giao tiếp với SHT71 trên forum của CCS nhé. |
06-12-2011, 05:25 PM | #5 |
Đệ tử 1 túi
Tham gia ngày: Mar 2011
Bài gửi: 15
: |
Ngu thế ko dùng giao tiếp I2c thì dùng ji dúng là ...)
|
07-12-2011, 01:36 PM | #6 |
Đệ tử 2 túi
Tham gia ngày: Aug 2010
Bài gửi: 42
: |
bạn đừng bao giờ bảo ai ngu... và đừng phán bừa...
đây là tin tức trên datasheet: The serial interface of the SHT7x is optimized for sensor readout and effective power consumption. The sensor cannot be addressed by I2C protocol, however, the sensor can be connected to an I2C bus without interference with other devices connected to the bus. Microcontroller must switch between protocols. (trang 4/11) bạn có thể đọc và hiểu chứ. |
|
|