What is supposed to be ATAN ?

BESQUEUT

Senior Member
It seem to be an implementation of Arctan from a post by Technical
ArcTan-Approximation
In Picaxe manual, section 2, page26, I can read :
As the arctan input is always a value between 0 and 1,
and
ATAN is supposed to work from 0 to 45 degrees

But when I simulate it, answer is always
0 from 1 to 50,
and 45 from 51 to 100

Unfortunately, the only example is
let b1 = atan 100 (answer b1 = 45)

From simulator :
atan(150)=63
atan(260)=72
atan(350)=76
atan(460)=79
....
atan(1000)=84
 
Last edited:

Pongo

Senior Member
I agree with your result that atan does not simulate correctly (or rounds the output to the nearest 45 degrees if you prefer). I suggest you test it using an appropriate chip and sertxd in which case it does work correctly. Note that atan takes a number between 0 and 100 * and returns a value between 0 and 45 degrees so using any number greater than 100 is out of the range of the command.

Code:
#picaxe 20x2
#Terminal 9600
#No_Table
#No_Data

Again:
for b16 = 0 to 100
    b17 = atan b16
    sertxd("atan ",#b16," = ",#b17,13,10) 
    Pause 200
next b16
Goto Again
*The real arctan function takes a number between 0 and 1 but the picaxe can only handle integers so the input is multiplied by 100, in effect a percentage - conveniently the same way road gradients are described in the U.S.
 
Last edited:

BESQUEUT

Senior Member
I agree with your result that atan does not simulate correctly (or rounds the output to the nearest 45 degrees if you prefer). I suggest you test it using an appropriate chip and sertxd in which case it does work correctly. Note that atan takes a number between 0 and 100 * and returns a value between 0 and 45 degrees so using any number greater than 100 is out of the range of the command.

Code:
#picaxe 20x2
#Terminal 9600
#No_Table
#No_Data

Again:
for b16 = 0 to 100
    b17 = atan b16
    sertxd("atan ",#b16," = ",#b17,13,10) 
    Pause 200
next b16
Goto Again
OK : simulation is not correct. I have to try with a real Picaxe.
Thanks
 
Top