View Full Version : Reading from a HX711
lerameur
- 16th November 2021, 00:58
hello
I am having issues reading the 24bit data from a Hx711 module.
I used the program given here :
http://www.picbasic.co.uk/forum/showthread.php?t=23816
The datasheet mentions that when the data pin goes to 1, when can start reading the 24 bit.
Issue 1 : Why use 15 loop when the datasheet mentions 24 bits are to be read ??
Issue 2 : Why start the shifting immediately, shouldn't the data be fetch first, then do the shifting ?
For i = 0 To 15
High clock
Hx711Cnt = Hx711Cnt <<1
Low clock
if dataa=1 then Hx711Cnt=Hx711Cnt+1
Next
richard
- 16th November 2021, 01:14
try this way
lerameur
- 16th November 2021, 01:19
hello,
Thanks for your code, but I am not playing around with assembler language.
Have done it in picbasic ?
Cheers,
Ken
richard
- 16th November 2021, 01:35
you may need to take a closer look , the hx711 part is pbp code
with a smattering of asm for the display , its all pbp compiled
lerameur
- 16th November 2021, 03:18
Hi,
I know you are trying to help. And I appreciate it. I dont understand that code you sent.
I really wanted just the answers to those two issues so i can do 100% in PBP.
Ken
richard
- 16th November 2021, 04:51
The datasheet mentions that when the data pin goes to 1, when can start reading the 24 bit
the opposite in fact
data sheet
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 be low. 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 is 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.
Issue 1 : Why use 15 loop when the datasheet mentions 24 bits are to be read ??
good question , its not in keeping with the spirit of the data sheet , but obviously the intent is to keep only
the 15 or 16 high order bits and tolerate the lower resolution so incurred
Issue 2 : Why start the shifting immediately, shouldn't the data be fetch first, then do the shifting ?
no its read in msb first, the msb will be positioned correctly at the end of the sequence
my code maintains the maximum resolution that can be adequately managed by pbp and fully completes the read cycle
that allows the chip gain and analog channel to be managed
richard
- 16th November 2021, 04:59
I know you are trying to help. And I appreciate it. I dont understand that code you sent.
I really wanted just the answers to those two issues so i can do 100% in PBP.
here is my code to read hx711 , what part is not pbp code ?
read_hx711:
WHILE HX_OUT : WEND ;data ready
for HX711_bits = 23 to 0 step -1 ;read data
HX_SCK = 1
@ NOP
@ NOP
HX711_reading.0[HX711_bits] = HX_OUT
HX_SCK = 0
@ NOP
@ NOP
@ NOP
@ NOP
@ NOP
@ NOP
NEXT
;set_hx711_gain
for HX711_bits = 0 to hx711_gain; send GAIN
HX_SCK = 1
@ NOP
@ NOP
@ NOP
HX_SCK = 0
@ NOP
@ NOP
@ NOP
NEXT
return
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.