Read HX711


Today 11:49
Forum: The Lounge
Starter: Oldhack
Views: 0
Replies: 41
Today 09:08
Forum: The Lounge
Starter: normnet
Views: 0
Replies: 1
Today 00:13
Forum: The Lounge
Starter: _Gabi_
Views: 6753
Replies: 24
+ Reply to Thread
Results 1 to 10 of 10

Thread: Read HX7111560 days old

  1. #1
    Member basparky's Avatar
    Join Date
    Oct 2006
    Posts
    199
    Thumbs Up
    Received: 14
    Given: 10
    Total Downloaded
    473.14 MB

    0 Not allowed!

    Default Read HX711

    Hi,

    I would like to add a HX 711 module to a pic 18f2550. This to add a weigh scale to my project.
    Datasheet: http://www.dfrobot.com/image/data/SE...11_english.pdf
    I need to read the 24 bits from the device but have no idea where to start. Has anyone used this module before?

    At this moment i have the following loop to read the 24 bits from the module:
    Code:
    main:
    While Dout = 1 
    Wend
    For j = 1 To 3
        For i = 1 To 8
            High Slk
            SetBit DataDWord,i*j
            Low Slk
        Next
    Next
    High Slk
    DelayMS 10
    Low Slk
    
    
    DelayMS 2000
    HRSOut Bin DataDWord,"\r\n"
    GoTo main
    But how do i get readable data form this?

    Thanks for any help!
    Last edited by basparky; 1st September 2014 at 21:34.

  2. #2
    Member basparky's Avatar
    Join Date
    Oct 2006
    Posts
    199
    Thumbs Up
    Received: 14
    Given: 10
    Total Downloaded
    473.14 MB

    0 Not allowed!

    Default Re: Read HX711

    If i follow the manual i get something like:
    Code:
    main:
    Dout = 1
    Slk = 0
    DataDWord = 0
    Count1 = 0
    While Dout = 1 : Wend
    
    
        For i = 0 To 24
            High Slk
            Count1 = Count1<<1
            LoadBit DataDWord,i,Dout
            Low Slk 
            If Dout = 1 Then Inc Count1  
        Next
    High Slk
    Count1 = Count1^0x800000
    Low Slk

  3. #3
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    178
    Thumbs Up
    Received: 9
    Given: 24
    Total Downloaded
    6.70 GB

    0 Not allowed!

    Default Re: Read HX711

    H
    I Basparky,
    Did you managed to read your HX711. Would you like to share your code?
    Yves

  4. #4
    Member basparky's Avatar
    Join Date
    Oct 2006
    Posts
    199
    Thumbs Up
    Received: 14
    Given: 10
    Total Downloaded
    473.14 MB

    0 Not allowed!

    Default Re: Read HX711

    Hi Yvesmazzon,

    Yep , i did managed to get my project running with the HX711. I used 2 modules. Ech connected to a load cell.
    This is a piece of code to get the data and scale it into whatever you want. It is possibel to use one module for 2 loadcells. I tried but without succes (because of the weird gain differences in the channels).

    I hope this helps. It was made for a 18F2620. Any further help needed, just let me know. succes!

    Code:
        Symbol DoutA         = PORTB.0
        Symbol SlkA          = PORTB.1
        Symbol DoutB         = PORTB.2
        Symbol SlkB          = PORTB.3
    
    
    '>>>LoadcellA<<<
        LoadCellA:
        DoutA = 1
        SlkA = 0
        Hx711Cnt = 0
        While DoutA = 1 : Wend
        For i = 0 To 23
            High SlkA
            Hx711Cnt = Hx711Cnt <<1
            Low SlkA
            If DoutA = 1 Then Inc Hx711Cnt
        Next
        High SlkA
        Hx711Cnt = Hx711Cnt^0x800000
        Low SlkA
        Return
    
    
    '>>>LoadcellB<<<
        LoadCellB:
    ;HRSOut "loadcell"
        DoutB = 1
        SlkB = 0
        Hx711Cnt = 0
        While DoutB = 1 : Wend
        For i = 0 To 23
            High SlkB
            Hx711Cnt = Hx711Cnt <<1
            Low SlkB
            If DoutB = 1 Then Inc Hx711Cnt
        Next
        High SlkB
        Hx711Cnt = Hx711Cnt^0x800000
        Low SlkB
        Return
    '>>>CalculatieA<<<
    ' Nu op 2 kilo..
        CalculateA:
        aReading = 8068660;8285167; laagste uitgelezen waarde hier
        aLoad = -100;240; minimale geschaalde waarde
        bReading = 8718181;8501674; hoogste uitgelezen waarde hier
        bLoad = 100;780 maximale geschaalde waarde
        LoadA = (((bLoad - aLoad) /(bReading - aReading)) * (Hx711Cnt - aReading) + aLoad) ;+ correctieA;
    ;LoadA = LoadA * 2
        If LoadA > 100 Then LoadA = 100
        If LoadA < -100 Then LoadA = -100
    ;HRSOut "A = ", Dec Hx711Cnt,"\r\n"
        Return
    
    
        CalculateB:
        aReading = 7979750;8204124; laagste uitgelezen waarde hier
        aLoad = -100;240;-100
        bReading = 8652872;8428498;
        bLoad = 100;780;100
        LoadB = (((bLoad - aLoad) /(bReading - aReading)) * (Hx711Cnt - aReading) + aLoad) ;+ correctieb; + 58.2
    ;LoadB = LoadB * 2
        If LoadB > 100 Then LoadB = 100
        If LoadB < -100 Then LoadB = -100
    ;HRSOut "B = ", Dec Hx711Cnt,"\r\n"
        Return

  5. #5
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    178
    Thumbs Up
    Received: 9
    Given: 24
    Total Downloaded
    6.70 GB

    0 Not allowed!

    Default Re: Read HX711

    Hello Basparky,

    Many thanks for sharing your code. Just one more thing the chip doesn't seem to be wildly distributed , where did you get yours? I'm situated in Zimbabwe Harare,

    Regards,

    Yves

  6. #6
    Member basparky's Avatar
    Join Date
    Oct 2006
    Posts
    199
    Thumbs Up
    Received: 14
    Given: 10
    Total Downloaded
    473.14 MB

    0 Not allowed!

    Default Re: Read HX711

    Hi Yves,

    I got them from Ebay. I have no idea if this is an option for you...

  7. #7
    MERSOZ
    Guest MERSOZ's Avatar

    0 Not allowed!

    Default Re: Read HX711

    Device 16F877A
    XTAL 20


    ALL_DIGITAL On
    Include "MODEDEFS.BAS"
    Declare LCD_TYPE = 0
    Declare LCD_DTPIN PORTB.4 'DATA girişi PORTC'nin 4. ucundan başlayacak
    Declare LCD_ENPIN PORTB.3
    Declare LCD_RSPIN PORTB.1
    Dim Hx711Cnt As DWord


    Dim i As Byte
    Dim c As Bit
    Dim gram As Float
    Output PORTB.2
    PORTB.2=0
    Input PORTD.4
    Output PORTD.5

    Symbol dataa = PORTD.4
    Symbol clock = PORTD.5
    Symbol DoutB = PORTD.6
    Symbol SlkB = PORTD.7

    Cls
    Print At 1,1, "LOADCELL"
    i=0


    LoadCellA:
    dataa = 1
    clock = 0
    Hx711Cnt = 0
    While dataa = 1 : Wend
    For i = 0 To 23
    High clock
    Hx711Cnt = Hx711Cnt <<1
    Low clock
    If dataa = 1 Then Inc Hx711Cnt
    Next
    High clock
    Hx711Cnt = Hx711Cnt^0x800000
    gram=8388608-Hx711Cnt
    gram=gram-124000
    Low clock
    Print At 2,1, Dec gram
    GoTo LoadCellA
    Last edited by MERSOZ; 26th January 2016 at 19:19. Reason: THİS CODE WORK..

  8. #8
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    178
    Thumbs Up
    Received: 9
    Given: 24
    Total Downloaded
    6.70 GB

    0 Not allowed!

    Default Re: Read HX711

    Hello Basparky,

    Sorry of my ignorance but what is the purpose of the "Hx711Cnt = Hx711Cnt^0x800000" ?

    regards,

    Yves

  9. #9
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    67
    Thumbs Up
    Received: 42
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Read HX711

    After using Mersoz code I get fluctuating values .how I can get stable values?

  10. #10
    Member yvesmazzon's Avatar
    Join Date
    Jul 2006
    Posts
    178
    Thumbs Up
    Received: 9
    Given: 24
    Total Downloaded
    6.70 GB

    1 Not allowed!

    Default Re: Read HX711

  11. Quote Originally Posted by amod View Post
    After using Mersoz code I get fluctuating values .how I can get stable values?
    Hi Amod,being a 24 bit values which is a very large number you will notice quite lot variations on the low digits, but when you convert it into grams or kg or what ever unit you are using these variations are insignificant. with a 3kg loadcell I get 1 grams with a standard deviation of +/-0.05 gram which is pretty good for my application. I suggest you do 10 times averaging and you also ground the loadcell body.

    Yves

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. CF read speed ?
    By Richard in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 31st January 2010, 18:29
  2. Read GPS
    By dmTulsa in forum GPS
    Replies: 5
    Last Post: 19th December 2007, 18:59
  3. REad PWM/Duty
    By chuckieboy in forum The Lounge
    Replies: 5
    Last Post: 16th November 2007, 16:03
  4. Read configuration 18F452
    By bill9399 in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 2nd October 2007, 13:39

Members who have read this thread since 30th November 2018, 14:39 : 1

Actions :  (Set Date)  (Clear Date)

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

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