Math Function

ZeroScope

New Member
Just had a look through manual 1 and 2 and couldnt find the answer.
Does BASIC have a natural log command and an indices command?
 

ZeroScope

New Member
Ok, thankyou for the reply. I am very new to PICAXE so im not sure what the uFPU is. I have looked it up, but would this be integrated into say a breadboard for example along with the 18X?
What i need to do is convert the voltage from a potential divider consisting of a 5k thermistor and a 5k resistor. I can convert the output of the ADC into a resistance and then i would be putting this into an arrangement of the steinhart equation in order to convert this resistance to a temperature.
Am i going about this the wrong way, is there an easier way to do the conversion?
 

BeanieBots

Moderator
There is no pre-made PCB for use with PICAXE and uFPU. Besides, that is NOT the direction you want to take with a simple temperature device.
One option would be a simple lookup table which has several break points to linearize the values and then basic sums to scale it.
Personally, I prefer the DS18B20 which returns values in degC in a digital form to the nearest degree. There is also the readtemp12 command which is degC*16 or in other words has a resolution of 0.06C. Plenty of examples of its use on this forum.

Do you NEED to convert to degC?
If all you want do is control to a specific temperture (and not display the actual temperature) then just work with the raw values. That will also give the most accurate result as there will be no mathematical rounding/calculation losses.
 

ZeroScope

New Member
I've been trying to use the DS18B20 but i can't as the title of the project itself is using a thermistor as a temperature controller, which is a shame.
Also i do want to display the current temperature but im looking into just having a digi thermometer to do that so thats not a problem.
I'm not sure about the look up table thing. Im pretty new to the picaxe thing so ill check around for using the tables. Thankyou for replying !! hopefully ill sort it soon.
 

tikeda

Member
As others mentioned, you don't have to calculate the Steinhart-Hart equation to display the temperature. A lookup table with interpolation between points is one way. Another is to use a polynomial interpolation (something akin to: T = a + b(R) + c(R)^2 + d(R)^3 + ...). The Pixaxe can manage multiplication.

Tracy Allen of EME Systems has several pages describing interpolation and table lookups for approximating 'difficult' curves on the BasicStamps. One page is here. A specific application with thermistors is down the page (here). Tracy also describes logarithm calculations in the same page. His examples can be translated to the Picaxe.

(I must be old: We had to memorize log tables in school).
 
Last edited:

profmason

Member
Log function

You can also implement a log function using successive approximation. See exercise 24 in chapter 1.2.2 of Donald Knuth's, "Art of Computer Programming" This can be done in about 9 lines of code and so won't require nearly the memory for a lookup table. Plus you will get to feel like a champ. (Do they still make CS majors go through Knuth?)

have fun!
mmason

EDIT:
OR tikeda was writing at the same time I was and just follow his link!
 
Last edited:
Top