Page 1 of 1
Which setting? Bytes,Integers, voltages etc etc
Posted: Tue Apr 02, 2019 1:37 pm
by JDR04
Hi, the aim of this program is to sense a certain heat or temperature level with a 10K NTC thermistor and then turn on a fan IF the temperature heat level exceeds the set maximum set by the 10K potentiometer.
I've got the circuit working but am wondering if it is best to "read as Voltage" settings for the " thermistor and the Potentiometer. (10K Thermister NTC and 10K Potentiomer used)
It would be great if somebody could explain to me when and why to use intergers, bytes ,read as voltage etc. This would help greatly.
All help and advice is appreciated. I have attached the program. Thanks very much...John
Re: Which setting? Bytes,Integers, voltages etc etc
Posted: Thu Apr 04, 2019 12:17 pm
by Benj
Hello,
Read as byte returns an 8-bit value in the range 0-255. Useful if you are using limited RAM or want high speed calculations on the value.
Read as int returns a 10-bit (0-1023) or 12-bit (0-4095) reading based on the capabilities of your device. This uses a bit more RAM but has much higher resolution. Again calculations are going to be fairly fast but not as fast as 8-bit (on an 8-bit device).
Read as Voltage does an int read of the ADC and then converts to a floating point voltage. This will use a fair amount of RAM and will also require more processing to perform the floating point maths. However it gives you a real number if you want to display the voltage or do more complex calculations.
Re: Which setting? Bytes,Integers, voltages etc etc
Posted: Sat Apr 06, 2019 6:53 pm
by JDR04
Thanks benj, so in terms of my program, would you say I have correctly set this up or not?
Re: Which setting? Bytes,Integers, voltages etc etc
Posted: Mon Apr 08, 2019 8:32 am
by LeighM
Hi,
Your program is going to work, yes, but you now need to think about hardware.
The simplest solution is to use the thermistor in series with another fixed resistor to form a potential divider for the ADC input.
The voltage will be non-linear with respect to the temperature, so you need to look up the resistance/temperature curve for the NTC thermistor and determine the resulting voltage and if the 8 bit resolution (full scale 256 steps) is accurate enough.
i.e. the step size at your threshold temperature.