??? 02/07/05 20:28 Read: times |
#86814 - re: the obvious one Responding to: ???'s previous message |
Neil Kurzman said:
Sitting in one interupt so long that multiple interupts are missed in ther interupts. Yeah, like the temperature-control code I fixed once. Basically, there was a timer tick interrupt every so often where a temperature sensor would be read. The original author (a Ph.D. in controls, no less) was doing his PID loop calculations IN THE ISR, and he couldn't figure out why his serial port was dropping characters. Worse was the fact that his PID loop calculations required degrees Centigrade as its input, and its output was volts since the output drove a DAC that set a heater's power. He actually converted the 12-bit temperature sensor ADC value to degrees Centigrade (to three decimal places) and his loop had to convert volts (also to three decimal places) to DAC bits. He originally tried to do all of these conversions using floating point in the ISR, but his programs crashed. He was eventually told that the floating point library (Avocet C) was not re-entrant. So, he came up with this icky multi-byte fixed-point representation for the degrees and the volts and his loop constants, rather than go back to his Matlab/Simulink model and rework it in terms of 12-bit ADC and 12-bit DAC values. -a |