Picaxe equivalent of Map() function?

artswan

Member
Picaxe equivalent of Arduino Map() function?

Arduino has a Map() function that allows you to adjust adc input so that it reads the full scale, say 0 to 255 or 0 to 1023. As an example say you have a sensor that's output range is from 0.25V to 4.5V. Well, if inputted directly to say readadc10, you will only be working with a range of values something like 35 to 996 (estimated), instead of 0 to 1023. With the Map() function, it WILL output 0 to 1023! Does Picaxe have a similar function? Or is there a formula you must use?
 
Last edited:

KTarke

Senior Member
Don't know how it is done in Arduino, but it can't be mathematical...
If the sensitivity of adc stays the same, a certain voltage area could not be streched to values 0-1023.

I have struggled with the same thing, and learned the following:
-normally adc is referenced against rails (0V and 5V). If these reference voltages are altered, one could get just what You wanted.
-In Picaxe x2-parts it is possible to set external voltage references with two voltage dividers (4 resistors)
-There is a internal resistor-ladder which can create one reference voltage, and it can be set ,but only in 20X2...

Instruction ,how to setup a external reference, can be found in this thread:
http://www.picaxeforum.co.uk/showthread.php?t=15239
 
Top