General > General Technical Chat
what's your recent fail?
mindcrime:
--- Quote from: harerod on May 01, 2021, 03:32:32 pm ---mindcrime, if you don't mind a suggestion from an old German guy who went to uni in Konrad-Zuse-Strasse:
No need for float, if you can make sure that your integer accumulator is large enough.
Make sure to tell your MCU in which order to process the numbers. If you don't trust brackets and precedence, do:
int16_t accu; // (adequate till 2^15 / 9 )
accu = maxtemp.readCurrentTemperature();
accu *= 9;
accu /= 5;
accu += 32;
Serial.println( accu );
or:
Serial.println( (int)(( maxtemp.readCurrentTemperature() * (9./5) ) + 32));
--- End quote ---
Don't mind at all! This, and the ensuing discussion, has been enlightening for me. I've learned a new thing or two.
That said, in the actual code that will run on the oven controller, there won't be any need for this conversion stuff at all. Everything will be done in Celsius. This code was only a convenience for me so I could easily "eyeball" the numbers from the thermocouple and see if they looked right or not.
harerod:
mindcrime, thank you for your kind words. I kept my comment es short as possibly, as not to scare you off. Integer arithmetic is a huge and interesting topic, arguably worth a thread in the Microcontroller section.
One huge advantage of integers over floating point hasn't been mentioned yet:
The precision of integer arithmetics can be predicted more easily than that of floats. Automatic mantissa/exponent adjustment might be a good starting point for research.
This all leads to the classic fail, where a newbie compares two floats for identity to exit a loop...
T3sl4co1l, I like your extension to my remark.
I love the reference to 2.048V references even better, knowing that an ADR420A will come with 2.045..2.051V initial output voltage. In that context a REF2920 2.007..2.048..2.089V becomes outright hilarious, especially knowing that many designers won't read past the marketing text on page 1 of the datasheet.
Regarding accu size on integer machines - does anybody remember the DSP56K series? 24bit registers, leaving a lot of leeway for operations on 16bit audio. That was the bee's knees in 1990's embedded audio processing. I remember doing active noise cancelling with those. Taking DSP56K as a reference, doing DSP on a ARM Mx feels like a dream.
harerod:
nctnico, regarding your PCB fail: I would be curious as how you followed up in that PCB issue. Stealthily "optimizing" designs is an absolute showstopper in my book. One of my customers recently found out that a manufacturer had adjusted my layout (fully specified PCB), without giving feedback. That was for a medical device, which carries medical EMI and safety certificates plus ETSI. I can pat myself on the shoulder that the design is robust enough to keep functioning, but this isn't the point. The point is that a manufacturer didn't produce what was ordered and thus potentially endangered patients.
Humanoid:
Small fail recently: Opened up a piece of used audio gear and was a little too forceful with removing a connector and tore the wires out of the solder points. >:D The wires were frayed so I had to replace them anyway and the connector was unscathed, so it wasn't a big deal.
Also snapped a pin off a battery holder, but it was a flimsy piece of #%@^@& so I'm not hurt by it :P
twospoons:
SPI - forgot that MOSI and MISO need to be crossed over (not MOSI to MOSI and MISO to MISO !) . So, another board revision needed. Stupid mistake.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version