Comments (16)
I have study this code. Now I quite understand your code. The issue is that you try to get all bits in one cyclus of the main function loop. This cause trouble and the CPU Idle a lot and this slow my other code down.
Now i have started a new approuch one bit each cycle.
const byte hx711_data_pin = A7;
const byte hx711_clock_pin =A6;
bool bOut,bOut1,bOut2;
bool bIn,newData,readingHX;
byte data1,data2,data3;
unsigned long currentTime;
unsigned long lastUpdate1,lastUpdate2;
int i,d,j;
long int dd;
void setup() {
// put your setup code here, to run once:
pinMode(hx711_clock_pin,OUTPUT);
pinMode(hx711_data_pin,INPUT);
// digitalWrite(hx711_data_pin, HIGH);
Serial.begin(9600);
readingHX=1;
}
void loop() {
if(readingHX){
if(bOut2){
bOut2=0;
digitalWrite(hx711_clock_pin,0);
}else{
bOut2=1;
digitalWrite(hx711_clock_pin,1);
bIn=digitalRead(hx711_data_pin);
j=23-i;
if(i<24){
dd |= bIn<<(j);
}
i++;
}
}else{
i=0;
}
if(i==24){
readingHX=0;
dd ^= 0x80;
Serial.println(dd,BIN);
dd=0;
digitalWrite(hx711_clock_pin,0);
}
}
from hx711.
Would it not been easier to use
if (scale.is_ready()) Lvalue = scale.read() ;
from hx711.
@leszek77 do you still need any help with this?
from hx711.
yes, but i try to figure out by my self.
from hx711.
Hi.
@leszek77, did you finalise your version?
from hx711.
i didn\t continue to work on it
from hx711.
@bogde I'm facing the same issue. Is there a way to increase the speed at which the data is fetched?
from hx711.
For anyone reading this in the future, that while (!is_ready());
in read()
caused the code to block and would waste a lot of processor cycles so I modified it by removing the while loop, and instead repeatedly checking in the main loop if chip is_ready()
. I created separate functions read_direct()
[Without the blocking while loop], and get_units_direct()
[Which calls read_direct() directly] and added this to my main loop:
if (scale.is_ready()){
tension = scale.get_units_direct();
}
from hx711.
@Srijal97 Hey there, i'm facing the same problem with the while (!is_ready()); function. I'm not a programmer and can't figure out how to change the while loop to an if function. Could you give some more detail on how you have set up your code? I'm using the multi-library to connect 4 loadcells:
https://github.com/compugician/HX711-multi/blob/master/HX711-multi.cpp
Thanks a lot :-)
from hx711.
@MugetsuX Hey, if you could just drop me an email on the ID from my GitHub profile, I'll send you the modified library and example code showing what I mean!
from hx711.
@Srijal97 Hi Sir, I tried your way of fixing this problem, however i'm not quite getting it done. could you also send me the modified libraby?
thanks a lot
from hx711.
@Srijal97 could you send me your modifications to the library. thank you very much.. im doing a rapid acquisition from the load cell, and i need to get the value as fast as possible. Thank you very much..
from hx711.
@Srijal97 could you send me your modifications to the library. thank you very much.. im doing a rapid acquisition from the load cell, and i need to get the value as fast as possible. Thank you very much..
Please find the files here: Srijal97/HX711
from hx711.
from hx711.
@Srijal97 thanks for sharing the code. If i can suggest...you should make fork of this project and publish your code on your github profile, that's what github is for...
from hx711.
@Srijal97 thanks for sharing the code. If i can suggest...you should make fork of this project and publish your code on your github profile, that's what github is for...
I have done that now, thank you!
from hx711.
Related Issues (20)
- Creep effect removal. Load cell storage over long time HOT 5
- Arduino 2 support
- Formula to find hx711 output of load cell voltage output HOT 1
- Arduino MKR 1010 Upload failure
- Arduino freezes after about 1 hour of continuous reading
- serial monitor freezes on arduino uno when data or clock from HX711 is connected to the arduino digital data pin
- Should function "scale.tare();" need a parameter? HOT 2
- add NRF to compatible boards list
- Verify my wiring (HX711 with four strain gauges) HOT 2
- Multiple HX711 with one clock HOT 1
- warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
- Reason behind using D2 and D3 pins HOT 1
- HX711 only reads once on startup HOT 2
- How to check load cell is connected or not
- What are possible values for scale.set_scale(2280.f); HOT 2
- 71
- self-calibration of load cell
- HX711 not thread safe?
- HX711 high current consumption
- Error on `make build-all` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hx711.