Conversation
|
Hey, About the voltage issue, I would add a setting to You say it does not work yet, in what respect? Are you sure that Perhaps this should be renamed to be more generic like |
|
It is 'not working' in the sense of returning the wrong temperature. I understood NegativeSlope=false as the adc reading increases with the temperature, if so, then this is correct. I will add an assertion to ensure that the slope parameter is actually positive. I agree that the more generic name makes sense, btw. this could be implemented as an InterpolationTable but it would consume considerable more CPU cycles per measurement. |
|
Yes your understanding of NegativeSlope is correct. I don't see any issue with the code itself, I suspect the issue is some sort of misconfiguration or misunderstanding on your side. Do you know that the 'adc' floating point value you get in adcToTemp() is in the range [0,1] (so that its meaning does not depend on the bit width of the ADC)? I don't like the assertion with NegativeSlope since assertions are meant for logically impossible things, perhaps just a warning; if the message constant this can be done like this: But maybe it's better to just implement support for runtime-determined NegativeSlope. I'll probably have some time tomorrow to do that as well as fix the InterpolationTable thing to have configurable voltage. |
|
You can use |
tested with Teensy3: |
|
I couldn't figure out how to create the warning message during startup and/or reload of an invalid configuration. |
not working (yet), but compiles :)
Is there a way to get the scaling of the adc? It is important in this case as the output of these modules = temperature*5mV/K + 1.25V. Hardcoding to 3.3V seems a bit ugly (in case AREF isn't yet available) as it will not work for systems that use 5V for AREF.
Adding another parameter to the module would be somewhat a middle ground between the effort of adding it to each HAL and hardcoding.
BTW: I think that InterpolationTableE3dPt100 has the same issue.