This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-F28379D: Hooking up Sensor Module HX711

Part Number: LAUNCHXL-F28379D


Tool/software: Code Composer Studio

Hello,

This is my problem statement: I want to hook up this sensor module (https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide/all) to my launchpad so that I can read the loadcell output signals as weight readings on my computer screen. I do not know how to do this.

This is what I know so far: First I connected the loadcell to the sensor module. Then I connected the sensor module to an Arduino. I uploaded the Arduino code available on the Sparkfun web link mentioned above. The library linked to this code came from github: https://github.com/bogde/HX711 . From this I can tell that the loadcell and the sensor module are working fine, as I am able to read the weights on serial monitor of the Arduino IDE. Coming to the Launchpad, I have used it successfully to control LED’s as shown in this video (https://www.youtube.com/watch?v=bcSSB_yHfoc). What is cool is that I was able to open the generated codes using Code Composer Studio and flash it onto the Launchpad and it still works! So, I am basically focusing on using Simulink’s Embedded Coder to program the Launchpad and it is working fine so far.

Here is what I tried with respect to my problem statement: Looking at the datasheet of the sensor module (http://image.dfrobot.com/image/data/SEN0160/hx711_english.pdf) I understood that I need two GPIO pins on the Launchpad to hook it up to the CLK and DOUT pins of sensor module. Additionally, I need 3.3V supply to power the module. Referring to the Launchpad user’s manual I can use GPIO pins for this purpose. I connected two jumper wires from the module’s CLK and DOUT pins to the Launchpad’s GPIO123 and GPIO2 pins respectively. After powering the module with the 3.3V pin on the Launchpad, I used the Simulink’s Embedded Coder to upload a code onto the Launchpad. Although Simulink successfully generates the code and uploads it to the launchpad, nothing happens when I apply physical force on the load cell. Attached codes that were generated using Simulink, for reference.

As far as Simulink’s Embedded Coder is concerned, I have explained this issue to Mathworks as well and I am waiting for a response from them. What I want to know from you is would it be naïve to say that the library files used in Arduino can be directly used in my Launchpad? If no, then will the library work with minor modifications?TI_C2000_trial3_ert_rtw.zip

  • Hi Ashirwad,

    I'll have someone from Mathworks reply here about the Simulink part of your question.

    Ashirwad Gad said:
    What I want to know from you is would it be naïve to say that the library files used in Arduino can be directly used in my Launchpad? If no, then will the library work with minor modifications?

    I don't believe this will work, unless the library was somehow made to be generic for both. C2000 devices are quite different than Arduinos (the registers of the devices won't match up), software will not be compatible between them by default.

    Best,

    Kevin

  • Hi,

    The Arduino library is perhaps doing more by reading the signal on the GPIO pins and based on this deriving the loadcell values.

    When working from Simulink we need to model this algorithm around the GPIO blocks. I am not sure if this is taken care.

    From the generated code please try to compare the code from Arduino with Simulink and see if they both are matching from Algorithm perspective.

    You can always contact MathWorks support (I see you have done it already) and shared model and other details.

    We can help you from there.

  • Hello Kevin,

    Thanks for your response.

    I am not sure if the library is generic. At least it is not mentioned to be a generic one on the github page where I found it. 

    So to take this forward, what do I need to know in order to translate this library so that C2000 devices understand it? Asking for someone who has just scratched the surface of Arduino Programming. And what would be a reasonable timeline to bring this to fruition?

    Answers to these questions will help me modify my plan for the project I am currently working on.

    Best Regards
    Ashirwad Gad

  • Hello Venkatesh,

    Thanks for your response.

    You are right, the arduino library is doing more and I may have not taken this into account while creating the model in simulink. I will modify the model so that the entire algorithm is taken into account. Should I have any issues even after doing this I will get back to this thread.

    Venkatesh and Kevin,

    The reason I am going with Simulink Code Generation is clearly because it is easier to translate an algorithm into codes using just block diagrams, and also because I lack the knowledge of programming a C2000 device using "traditional" means. This is of course under the assumption that the Code Generation caters to the required features of the C2000 device and is faster than writing the needed codes in CCS.

    Best Regards
    Ashirwad Gad

  • Hi Ashirwad Gad,

    I'm not too familiar with the MATLAB / Simulink code generation tool. Venkatesh and the MATLAB team will be able to better assist you.

    If you have any questions specific to the C2000 device please let us know.

    Best,

    Kevin