Arduino behaves non-deterministic?

Hello,

after 25 active years of coding, Ive never encountered anything comparable to what happend today.

Using the Adafruit Motorshield v2.3 on the UNO, connected to 4 DC-motors, there were so many "bugs", which are absolutly impossible to happen. But they did.

Like a boolean variable was not set, but the println before and after was executed. Or motor-speeds are only set the first 2 iterations, or the value of a variable was the same from a previous compilation or the assignment of a value only works, if I used a println to control the assignment.

Is this kind of behavior normal? Weve even exchanged the arduino board, which solved some problems but revealed new ones.

We were able to solve some other problems by simple exchanging the order of execution for some independent function calls.

Thats the point, where determinism is lost at all. It cannot be, that the order of excution of int a = 5, int b = 6 reveals different content of a and b. And if I exchange the UNO boards (exactly same revision) and run exact the same code and get different results, what is going on?

Do I have 2 faulty boards? Or is the motor-shield interfering with the Arduino? Or is my Android Studio playing tricks with me?

The AVR processor is perfectly deterministic with only two exceptions: the amount of time needed to write to Flash; the amount of time needed to write to EEPROM. Even those may be deterministic. The datasheet is vague on the matter and, to the best of my knowledge, no one has bothered to run the test.

PoisonNuke: And if I exchange the UNO boards (exactly same revision) and run exact the same code and get different results, what is going on?

Corrupt heap, race condition(s), uninitialized variables.

What other inputs are you using? You may be getting E-M interference.

Or your code is riddled with bugs. Post your code, in code tags.

Pete

run exact the same code and get different results,

And post a circuit diagram of eactly how you have powered and connected the motors, shield and UNO.

Pete

Like a boolean variable was not set, but the println before and after was executed. Or motor-speeds are only set the first 2 iterations, or the value of a variable was the same from a previous compilation or the assignment of a value only works, if I used a println to control the assignment.

These are pretty much classic symptoms of "buffer overrun" errors, where you end up writing "random" values to variables that you didn't think you were modifying. (or the return address of a function, causing it to return to "somewhere else.")

(deleted)

Or is the motor-shield interfering with the Arduino?

If this is a problem, then the way each individual processor or board behaves could well be different.