Reading from a HX711


+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default Reading from a HX711

    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 ?

    Code:
    For i = 0 To 15
       High clock
       Hx711Cnt = Hx711Cnt <<1
       Low clock
       if dataa=1 then Hx711Cnt=Hx711Cnt+1
     Next

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: Reading from a HX711

    try this way
    Attached Files Attached Files
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Sep 2006
    Posts
    747

    Default Re: Reading from a HX711

    hello,

    Thanks for your code, but I am not playing around with assembler language.
    Have done it in picbasic ?

    Cheers,

    Ken

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: Reading from a HX711

    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
    This is more entertaining than Free to Air TV

  5. #5
    Join Date
    Sep 2006
    Posts
    747

    Default Re: Reading from a HX711

    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

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: Reading from a HX711

    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
    This is more entertaining than Free to Air TV

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    1,945

    Default Re: Reading from a HX711


    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 ?


    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
    This is more entertaining than Free to Air TV

Similar Threads

  1. HX711 driver code
    By povulon in forum General
    Replies: 4
    Last Post: - 28th April 2021, 10:39
  2. help reading adxl312
    By cluster in forum Serial
    Replies: 11
    Last Post: - 5th October 2012, 20:30
  3. Reading eeprom
    By Lotondo in forum Off Topic
    Replies: 1
    Last Post: - 21st February 2007, 18:37
  4. Reading ID Value
    By charudatt in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd May 2006, 06:16
  5. adc reading ac
    By Ruben Pena in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th December 2005, 22:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts