Using Simulink with load cell and amplifier HX711

I have checked the similar questions and could not find an answer. I am using a load cell and an amplifier HX711 with arduino uno and simulink. I trying to make a S-Function with the help of the library provided https://github.com/bogde/HX711
But so far unsuccessful!! Is there an easier way to do it? if not can someone help me build the S-function? I am quite new to programming and quite bad with C.
I would appreciate any help with this :) thanks

6 Comments

Hi have you solved your problem? I am also trying to connect HX 711 to matlab/simulink but no idea how to process those 2 digital inputs.
Follow the link I gave to read the sparkfun documentation about the HX 711 and calibration.
If you look at the HX 711 project github it appears that readings are linear, but that you need to know the offset and the multiplier through calibration.
well I took some time looking at the files, but the output of two digital pin DOUT and SCK are only binary, human readable data has to processed by one consecutive set of raw data.
The sparkfun documentation or hx 711 github repository show clocking the bits in at arduino level. I would not recommend trying to clock bit by bit at the MATLAB or Simulink level: I would recommend that you have a sketch (C code) on the arduino that calls upon those libraries, calculates the scaled strain, and sends that to MATLAB (or simulink) either as a binary single or as the text representation of a floating point number.
I am not quite sure how to ‘have a sketch (C code) on the arduino that calls upon those libraries.....'. I know that certain functions with existing lib can be built, but I am not sure how. Appreciate it if you could enlighten a bit.
My final goal is to buit the whole model in simulink and read real time data on it.
same problem:(
Any help will be appreciated:)

Sign in to comment.

Answers (1)

However, in order to calibrate the device, you need the libraries I linked to, or the libraries that you linked to. Those libraries run on the Arduino.
If you decide to use readDigitalPin from the MATLAB side, you will probably not be able to sample faster than 4 to 10 Hz, with 1000 Hz as the maximum ever possible with that method because of the way that USB is designed.
If you need more than 4 or so Hz sampling, then you need to have code on the Arduino side that reads multiple samples and sends the group of samples to MATLAB.

Categories

Products

Release

R2018a

Asked:

on 17 Jun 2018

Commented:

on 29 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!