• AVR Freaks

Load cell 1000kg and hx711 interfacing with pic 18f4550 w

Author
BEN9
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2017/01/23 11:02:43
  • Location: 0
  • Status: offline
2018/03/21 12:35:02 (permalink)
0

Load cell 1000kg and hx711 interfacing with pic 18f4550 w

I am working on the load cell it has four wire i am using hx711 module to get the data from it but i am getting confused with the data it send, hx711 module send the 24 bit data , my first problem is how can i get that data in my pic mcu as hx711 does not use spi nor i2c it just send the 24 bit data and second problem is the 24 bit data is in 2s complement how can i convert it into the binary and digital value
#1

12 Replies Related Threads

    jack@kksound
    code tags!
    • Total Posts : 3203
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/03/21 13:58:28 (permalink)
    +2 (2)
    The HX711 sends the 24 bit data in response to a clock input. This operation is well defined in the HX711 datasheet.
    The data is a signed 24 bit integer value.
    #2
    qɥb
    Monolothic Member
    • Total Posts : 3332
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/03/21 15:37:42 (permalink)
    +1 (1)
    You did not mention which C compiler you are using (or if you are writing in assembler).
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #3
    BEN9
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2017/01/23 11:02:43
    • Location: 0
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/03/21 20:17:44 (permalink)
    0
    qɥb
    You did not mention which C compiler you are using (or if you are writing in assembler). 
    xc8 version 1.33
    #4
    BEN9
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2017/01/23 11:02:43
    • Location: 0
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/03/21 20:20:17 (permalink)
    0
    jack@kksound
    The HX711 sends the 24 bit data in response to a clock input. This operation is well defined in the HX711 datasheet.The data is a signed 24 bit integer value.
    thank you jack but i am little bit new in this field and i dont know how to get this data bit by bit in mcu and combine it to form single variable if someone help me with small code it will really be helpful
    #5
    timijk
    Super Member
    • Total Posts : 1216
    • Reward points : 0
    • Joined: 2007/11/26 00:30:07
    • Location: Taiwan
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/03/21 21:05:54 (permalink)
    +1 (1)
    You can try bit-banging the control and clock signals and read in the data.  Or see if you can use the SPI module to do it for you.
    #6
    Mysil
    Super Member
    • Total Posts : 3330
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/03/21 22:15:05 (permalink)
    +3 (3)
    Hi,
    There is example code in datasheet for HX711.
    Timing requirements for HX711 is such that if system clock frequency is not higher than 20 MHz,
    corresponding to instruction frequency 5 MHz or lower,
    then there will be no need to worry about timing or additional delay in reading bits from HX711.
     
    You may try something like:
    #define    ADDO_PORT          PORTDbits.RD5    /* If ADC Data Input is connected to RD5 */
    #define    ADDO_SetHigh()     LATDbits.LATD5 = 1
    #define    ADDO_SetLow()      LATDbits.LATD5 = 0
    #define    ADDO_GetValue()    PORTDbits.RD5
    #define    ADDO_TRIS          TRISDbits.TRISD5
    #define    ADSCK_LAT          LATDbits.LATD0    /* If ADC Clock signal is connected to RD0 */
    #define    ADSCK_TRIS         TRISDbits.TRISD0
    #define    ADSCK_SetHigh()    LATDbits.LATD0 = 1
    #define    ADSCK_SetLow()     LATDbits.LATD0 = 0
    signed long ReadCount(void)        /* Function to read measurement from HX711 */
    {
        signed short long Count; 
        unsigned char i;
        ADDO_TRIS = 1;                /* Data line is Input to PIC */
        ADSCK_TRIS = 0;                /* Clock line to Output from PIC */
        ADSCK = 0;                     /* Clear Clock line to start conversion */
        Count = 0;
        while (ADDO_GetValue());      /* Wait for measurement conversion. */
        for (i=0; i<24; i++)
        {
            ADSK_SetHigh();           /* Clock signal High */
            Count = Count << 1;       /* Shift value left */
            ADSK_SetLow();            /* Clock signal Low */
            Count = Count | ADDO_GetValue();  /* Read result bit from HX711 */
        }
        for (i=0; i<3; i++)           /* Resolution bits to HX711 */
        {   ADSK_SetHigh();
             NOP();
            ADSK_SetLow();
            NOP();
        }
        return (signed long)Count;
    }  

     
    #7
    Vasquez
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/03/20 11:57:50
    • Location: COSTA RICA
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/05/05 20:37:17 (permalink)
    0
    I was left with a project at the university to make an hx711 data acquisition in asm with the pic16f877a. I ask if anyone can help me. I would really apreciate it.
    #8
    qɥb
    Monolothic Member
    • Total Posts : 3332
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/05/07 13:11:29 (permalink)
    +1 (1)
    Help you with what?
    Do you know how to write assembler for a PIC16F877A?
    Have you read the datasheet for the HX711?
    These are all things that the university course is evaluating if you have learnt.
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #9
    Vasquez
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/03/20 11:57:50
    • Location: COSTA RICA
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/05/07 13:42:40 (permalink)
    0
    qɥb
    Help you with what?Do you know how to write assembler for a PIC16F877A?Have you read the datasheet for the HX711?These are all things that the university course is evaluating if you have learnt. 

    to write the code it is necessary to enable spi or i2c. nothing more, I just need to know. what is the best way to communicate it in asm. I do not want to do it in C ... and I just need to do it in asm. He asked me if they can help me. I'm still new and I really like programming.
    #10
    qɥb
    Monolothic Member
    • Total Posts : 3332
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/05/08 13:13:51 (permalink)
    +2 (2)
    I suspect you are expecting too much from "enabling SPI or I2C".
    "Enabling" them is simply writing a couple of fixed values to a couple of registers. That is trivial.
    However, both modes require a lot of supporting code from you. They are much more work than USART where the hardware handles most of the protocol.
     
    So if you need help, you need to tell us exactly how much you can already do yourself.
    Are you at a level where you an make an LED connected to a GPIO pin flash at a one second rate?
    Don't laugh, being able to do that is a big first step to writing anything in assembler.
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #11
    Vasquez
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/03/20 11:57:50
    • Location: COSTA RICA
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/05/08 14:49:19 (permalink)
    0
    If you're right. I just needed a guide why I ignored the usart ... if I'm going to write asm with the registers and also a counter 24 pulses as the datasheet tells me ... I'll let you know how it goes ... thanks.
    #12
    Vasquez
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2018/03/20 11:57:50
    • Location: COSTA RICA
    • Status: offline
    Re: Load cell 1000kg and hx711 interfacing with pic 18f4550 w 2018/05/12 07:29:16 (permalink)
    0
    I already wrote the routine hx711 in assembler for a pic16f877a everything went well ... the microcontroller has a crystal of 20Mhz ... Thank you very much for your support.
    #13
    Jump to:
    © 2019 APG vNext Commercial Version 4.5