终于弄完,累
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sbit HX711_DOUT=P2^6;
sbit HX711_SCK=P2^5;
sbit sda=P2^4;
sbit scl=P2^1;
sbit d1=P1^1;
void delay(unsigned int k)
{
unsigned int i,j;
for(i=0;i<k;i++) { for(j="0;j<100;j++)" {;} } } void delay__hx711_us(void) { _nop_(); delays() {;;} at_start() sda="1;" delays(); scl="1;" at_stop() at_respond() uchar i; while((sda="=1)&&(i<250))" i++; } at_write_byte(uchar i) m; bit n; for(m="8;m">0;m--)
{
n=(bit)(i&0x80);
scl=0;
delays();
sda=n;
delays();
scl=1;
delays();
i=i<<1; } scl="0;" delays(); sda="1;" } void at_write_address(uchar p,uchar address,uchar date) { at_start(); at_write_byte(p); at_respond(); at_write_byte(address); at_write_byte(date); at_stop(); **************************************************** ulong hx711_read(void) ulong count; uchar i; hx711_dout="1;" delay__hx711_us(); hx711_sck="0;" count="0;" while(hx711_dout); for(i="0;i<24;i++)" { hx711_sck="1;" count="count<<1;" if(hx711_dout) count++; return(count); init() delay(1000); main() ulong temp; uchar m,n,i,b[4]; init(); for(m="0;m<20;m++)" temp="HX711_Read();" delay(10); } temp="HX711_Read();" b[i]="(uchar)(temp&0xff);" at_write_address(0xa0,240+i,b[i]); temp>>=8;
delay(2);
}
delay(10);
while(1)
{
temp=HX711_Read();
temp=(ulong)((temp-8381000)*136/147);
d1=0;
if(temp>7000)
{
d1=1;
break;
}
}
n=0;
for(m=0;m<60;m++) { temp="HX711_Read();" for(i="0;i<4;i++) " { b[i]="(uchar)(temp&0xff);" at_write_address(0xa0,n,b[i]); temp>>=8;
delay(2);
n++;
}
}
n=0;
for(m=0;m<60;m++) { temp="HX711_Read();" for(i="0;i<4;i++) " { b[i]="(uchar)(temp&0xff);" at_write_address(0xa2,n,b[i]); temp>>=8;
delay(2);
n++;
}
}
n=0;
for(m=0;m<40;m++) { temp="HX711_Read();" for(i="0;i<4;i++) " { b[i]="(uchar)(temp&0xff);" at_write_address(0xa4,n,b[i]); temp>>=8;
delay(2);
n++;
}
}
while(1);
}</40;m++)></60;m++)></60;m++)></1;></k;i++)></intrins.h></reg52.h>
#include<reg52.h>
#include<math.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sbit sda=P2^4;
sbit scl=P2^1;
void delay(unsigned int k)
{
unsigned int i,j;
for(i=0;i<k;i++) { for(j="0;j<121;j++)" {;} } } void delays() {;;} start() { sda="1;" delays(); scl="1;" stop() respond() uchar i; while((sda="=1)&&(i<250))" i++; write_byte(uchar i) m; bit n; for(m="8;m">0;m--)
{
n=(bit)(i&0x80);
scl=0;
delays();
sda=n;
delays();
scl=1;
delays();
i=i<<1; } scl="0;" delays(); sda="1;" } uchar read_byte() { uchar k,l; for(l="8;l">0;l--)
{
scl=1;
delays();
k=(k<<1)|sda; scl="0;" delays(); } return k; } uchar read_address(uchar p,uchar address) { uchar da; start(); write_byte(p); respond(); write_byte(address); write_byte(p+1); da="read_byte();" stop(); void init() delay(1000); sda="1;" delays(); scl="1;" tmod="0x20;" th1="0xfd;" tl1="0xfd;" tr1="1;" sm0="0;" sm1="1;" conver(ulong temp) uchar yi,qw,bw,sw,wan,qian,bai; yi="temp%1000000000/100000000+0x30;" if(yi!="0x30)" { sbuf="yi;" while(!ti); ti="0;" } qw="temp%100000000/10000000+0x30;" if(qw!="0x30)" } if(qw="=0x30)" if(yi!="0x30)" { sbuf="qw;" while(!ti); ti="0;" } bw="temp%10000000/1000000+0x30;" if(bw!="0x30)" if(bw="=0x30)" sw="temp%1000000/100000+0x30;" if(sw!="0x30)" if(sw="=0x30)" wan="temp%100000/10000+0x30;" if(wan!="0x30)" if(wan="=0x30)" } qian="temp%10000/1000+0x30;" if(qian!="0x30)" if(qian="=0x30)" } bai="temp%1000/100+0x30;" sbuf="bai;" while(!ti); ti="0;" ; main() ulong f; uchar i; init(); delay(5); f="(read_address(0xa0,243)*16777216)+(read_address(0xa0,242)*65536)+(read_address(0xa0,241)*256)+read_address(0xa0,240);" delay(10); conver(f); sbuf="/" while(!ti); ti="0;" delay(5); for(i="0;i<240;i+=4)" f="(read_address(0xa0,i+3)*16777216)+(read_address(0xa0,i+2)*65536)+(read_address(0xa0,i+1)*256)+read_address(0xa0,i);" delay(10); conver(f); while(1); }< code></1)|sda;></1;></k;i++)></math.h></reg52.h>
[修改于 9年8个月前 - 2015/05/25 20:19:30]
数据出来之后,比冲的积分可以用excel来做嘛,所有的采样点加起来,除以采样频率就行了。多谢,你的话使我恍然大悟,这种做法用了微积分的思想
其实,,,,买个采集卡,,,一切都搞定了。。采集卡是什么
200字以内,仅用于支线交流,主线讨论请采用回复功能。