- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am working on CYBLE-416045-02 EZ-BLE Module and HX711 24-Bit Analog-to-Digital Converter (ADC) for Weigh Scales.
As per datasheet link----https://cdn.sparkfun.com/assets/learn_tutorials/5/4/6/hx711F_EN.pdf
https://cdn.sparkfun.com/assets/learn_tutorials/5/4/6/hx711F_EN.pdf
Serial Interface
Pin PD_SCK and DOUT are used for data retrieval, input selection, gain selection and power down controls. When output data is not ready for retrieval, digital output pin DOUT is high. Serial clock input PD_SCK should below. When DOUT goes to low, it indicates data is ready for retrieval. By applying 25~27 positive clock pulses at the PD_SCK pin, data is shifted out from the DOUT output pin. Each PD_SCK pulse shifts out one bit, starting with the MSB bit first, until all 24 bits are shifted out. The 25th pulse at PD_SCK input will pull DOUT pin back to high (Fig.2). Input and gain selection are controlled by the number of the input PD_SCK pulses (Table 3). PD_SCK clock pulses should not be less than 25 or more than 27 within one conversion period, to avoid causing serial communication error.
Reference Driver(C)
//-------------------------------------------------------------------
sbit ADDO = P1^5;
sbit ADSK = P0^0;
unsigned long ReadCount(void){ unsigned long Count; unsigned char i;
ADDO=1;
ADSK=0;
Count=0;
while(ADDO);
for (i=0;i<24;i++)
{ ADSK=1;
Count=Count<<1;
ADSK=0;
if(ADDO)
Count++;
}
ADSK=1;
Count=Count^0x800000;
ADSK=0;
return(Count);
}
_______________________________________________________________________________
For Arduino sample code:
/* This program takes 10 samples from LC + HX711B at
1-sec interval and then computes the average.
*/
unsigned long x = 0, y=0;
unsigned long dataArray[10];
int j = 0;
void setup()
{
Serial.begin(9600);
pinMode(A1, INPUT); //data line //Yellow cable
pinMode(A0, OUTPUT); //SCK line //Orange cable
}
void loop()
{
for (int j = 0; j < 10; j++)
{
digitalWrite(A0, LOW);//SCK is made LL
while (digitalRead(A1) != LOW) //wait until Data Line goes LOW
;
{
for (int i = 0; i < 24; i++) //read 24-bit data from HX711
{
clk(); //generate CLK pulse to get MSB-it at A1-pin
bitWrite(x, 0, digitalRead(A1));
x = x << 1;
}
clk(); //25th pulse
Serial.println(x, HEX);
y = x;
x = 0;
delay(1000);
}
dataArray
}
Serial.println("===averaging process=========");
unsigned long sum = 0;
for (j = 0; j < 10; j++)
{
sum += dataArray
}
Serial.print("Average Count = ");
sum = sum / 10;
Serial.println(sum, HEX);
// float W = (float)0.90*(sum-901002)/946560 + 0.75;//0.005331 * sum - 1146.176;
//W = (float)W / 1000.00;
Serial.println(W, 2);
}
void clk()
{
digitalWrite(A0, HIGH);
digitalWrite(A0, LOW);
}
-----------------------------------------------------------------------------------------
while the development of a similar code. I am struggling to access HX711 serial pin via ADC as input and output. I am looking for support of the HX711 sample code with ADC or GPIO pin configured to configured HX711 in your project.
Best Regards
Deepak Aagri
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Deepak,
You can try to copy Pin settings and code from the HX711 custom component, made for PSoC4 and PSoC5
HX711: 24-bit Delta Sigma ADC interface for weight scale
The component has not been tested on PSoC6, but some portions of it might work on M0 processor.
You might also be interested using the median filtering instead of the moving average, as it is better discriminates spikes from load/unload.
MedianFilter: sliding window median filter component
The code can be directly copied from the datasheet attached.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Deepak,
I could not find any ported example code in our repository. We can help you with the problems while you port the code. Let us know what is blocking you.
Best Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Deepak,
You can try to copy Pin settings and code from the HX711 custom component, made for PSoC4 and PSoC5
HX711: 24-bit Delta Sigma ADC interface for weight scale
The component has not been tested on PSoC6, but some portions of it might work on M0 processor.
You might also be interested using the median filtering instead of the moving average, as it is better discriminates spikes from load/unload.
MedianFilter: sliding window median filter component
The code can be directly copied from the datasheet attached.
/odissey1