necati
Joined: 12 Sep 2003 Posts: 37 Location: istanbul
|
hx711 |
Posted: Tue Mar 24, 2015 4:43 pm |
|
|
Code: | #include <main.h>
#include <stdio.h>
#ZERO_RAM
#define HX711_DO PIN_B15
#define HX711_CLK PIN_B14
int32 measurement(void);
void main()
{
int1 test=0;
unsigned int32 Count,BUFFER[30],offseeet=0,mied=0;
unsigned int8 i=0;
while(TRUE){
while(i<10){
Count=measurement();
BUFFER[i]=Count;
mied+=BUFFER[i];
i++;
}
i=0;
mied/=11;
if(test==0){
offseeet=mied;
test=1;
}
//Count=measurement();
mied-=offseeet;
//printf("data=%lu \n\r",Count);
printf("mied=%lu \n\r",mied);
//delay_ms(1);
//printf("\f");
}
}
//********************************************
int32 measurement(void){
unsigned int32 Count;
unsigned int8 i,A_1,A_2,A_3;
output_bit( HX711_DO, 1);
output_bit( HX711_CLK, 0);
Count=0;
while(input(HX711_DO));
for (i=0;i<24;i++){// gain 128
output_bit( HX711_CLK, 1);
Count=Count<<1;
output_bit( HX711_CLK, 0);
if(input(HX711_DO)) Count++;
}
output_bit( HX711_CLK, 1);
Count=Count^0x800000;
output_bit( HX711_CLK, 0);
//************************
A_1=MAKE8(Count, 0);
A_2=MAKE8(Count, 1);
A_3=MAKE8(Count, 2);
A_2=(A_2 & 0b11111000);
Count= MAKE16(A_3, A_2);
return(Count);
}
/*http://www.ebay.com/itm/New-Weighing-Sensor-AD-Module-Dual-channel-24-bit-A-D-Conversion-HX711-Shieding-/400567204760?pt=LH_DefaultDomain_0&hash=item5d43aa7b98
http://www.ebay.com/itm/Electronic-Scale-Sensor-HX711-ADC-Bridge-Weighing-Anti-Jamming-For-Arduino-AVR-/171217937819?pt=LH_DefaultDomain_0&hash=item27dd62659b
*/ |
|
|