Go Down

Topic: Code time inaccuracy (Read 504 times) previous topic - next topic

Robin2

The change suggested in Reply #11 is a good idea but it is not going to solve to your problem. That change will just prevent accumulated errors of a few millisecs creeping in.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Dragonsired1

The change suggested in Reply #11 is a good idea but it is not going to solve to your problem. That change will just prevent accumulated errors of a few millisecs creeping in.

...R
I want to make one thing clear. Is Arduino Mega capable of doing so many thing at once? Are there any limits? For example if I use all digital pins, all analog pins reading everything at the same time. I know I have many libraries, but I don't have skills to write for e.g. my own or manipulate with PORTs directly.

Robin2

I want to make one thing clear. Is Arduino Mega capable of doing so many thing at once? Are there any limits?
The fact is that it can only do one thing at a time. But it can do things very quickly so it can appear to be doing severla things at a time. Using digitalRead() takes a few microseconds. Using analogRead() takes about 100 Āµsecs IIRC.

The limits start to emerge if you are asking it to do so many computations that it cannot jump from one task to the next fast enough. And, unfortunately, some of the libraries have been written very carelessly with no thought for minimising the time they take to complete their tasks.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Dragonsired1

[SOLVED] The problem wasn't surprisingly in code but in hardware part. The issue was discussed here: https://forum.arduino.cc/index.php?topic=236974.15 I just added 10K ohm resistor VCC on HX711 PCB and now I increased SPS from 10 to 80 and there's no second skipping anymore. Thank all of you for providing me help and tips. Really appreciate.

Robin2

[SOLVED] The problem wasn't surprisingly in code but in hardware part. ...
I wonder if the real problem was the way the HX711 library was implemented? Presumably it starts a reading and waits until it finishes. With many of those sensors it is possible to separate the code for starting a reading from the code for collecting the answer so that other stuff can be done by the Arduino while the reading is in progress.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Coding Badly

I wonder if the real problem was the way the HX711 library was implemented?
This part certainly looks troublesome...
https://github.com/bogde/HX711/blob/master/HX711.cpp#L50-L57


Dragonsired1


Robin2

Should I delete this section?
Not unless you know how to replace it with something better.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up