Atan and Atan2 problem comiling
Anubispod
Posts: 42
Hi i try to use atan and atan2 in my code.
here is of what i have :
and that is what he gives me in the compiler
i hope some one knows
Best regards
Oliver .R
here is of what i have :
void sensfusion6GetEulerRPY(float* roll, float* pitch, float* yaw) { float gx, gy, gz; // estimated gravity direction gx = 2 * (q1*q3 - q0*q2); gy = 2 * (q0*q1 + q2*q3); gz = q0*q0 - q1*q1 - q2*q2 + q3*q3; *yaw = atan2(2*q1*q2 - 2*q0*q3, 2*q0*q0 + 2*q1*q1 - 1) * 180 / M_PI; *pitch = atan(gx / sqrt(gy*gy + gz*gz)) * 180 / M_PI; *roll = atan(gy / sqrt(gx*gx + gz*gz)) * 180 / M_PI; }
and that is what he gives me in the compiler
Project Directory: C:/Users/R2D2/Documents/SimpleIDE/testme/ propeller-elf-gcc.exe -o a.out -Os -mxmmc -I . -m32bit-doubles -fno-exceptions -Dprintf=__simple_printf Motor_led_Driver.h Motor_led_Driver.c MPU6050_XS.c MPU6050_XS.h Filter.h Filter.c testme.h pid.h pid.c controller.h controller.c sensfusion6.h sensfusion6.c testme.c C:\Users\R2D2\AppData\Local\Temp\ccQFPoVi.o: In function `_sensfusion6GetEulerRPY': (.text+0xd08): undefined reference to `_atan2' C:\Users\R2D2\AppData\Local\Temp\ccQFPoVi.o: In function `_sensfusion6GetEulerRPY': (.text+0xd68): undefined reference to `_sqrt' C:\Users\R2D2\AppData\Local\Temp\ccQFPoVi.o: In function `_sensfusion6GetEulerRPY': (.text+0xd84): undefined reference to `_atan' C:\Users\R2D2\AppData\Local\Temp\ccQFPoVi.o: In function `_sensfusion6GetEulerRPY': (.text+0xdd0): undefined reference to `_sqrt' C:\Users\R2D2\AppData\Local\Temp\ccQFPoVi.o: In function `_sensfusion6GetEulerRPY': (.text+0xde8): undefined reference to `_atan' collect2: ld returned 1 exit status Done. Build Failed! Check source for bad function call or global variable name `_atan2' C:\Users\R2D2\AppData\Local\Temp\ccQFPoVi.o: In function `_sensfusion6GetEulerRPY': (.text+0xd68):
i hope some one knows
Best regards
Oliver .R
Comments
is this due to not enoughf mem or i am missing some ?? i use a protoboard usb with LMM if its due to lack of mem i have read some about cmm mode but its not in the list of simple ide ??
??? I reached the 32K in lmm , and that sucks since i need more code there and as fast as lmm is , xmm with my epprom is to slow.
Would be sram or 1 MB SPI Flash memory faster the the upper 32k of the epprom ??
If not i would have to go with a diffrent mcu for my hexacopter design.
Best regards Oliver
It does include only the used functions, but due to the way functions are implemented sometimes one function may use another function.
If you're very close to the limit on LMM, try using CMM (compressed memory model). This runs all code in hub memory, but compresses the instructions so more of them fit (you can get about twice as much code). It runs faster than XMM, usually.
Also, try linking with 32 bit doubles. I know you're only using float in the example you gave, but internally the math functions use doubles, so if 32 bits of precision is enough then you can get some smaller/faster code by changing double to 32 bits.
Eric
It already does that.
If you can use 32 math, check the Program Manager->Compiler option "32bit Double" - that is smaller than the 64bit default.
We have considered providing the existing F32 COG features as a C library. The core team just hasn't had time yet. One could try using spin2cpp to create the F32 functions. I'm not completely convinced that an F32 C library would be much smaller than the current math functions though.
1MB SPI Flash is several times faster than EEPROM. There are a few devices currently supported. Windbond SPI chips will work.
But i think i need eather extra hardware sram or so.
Best regards
Oliver.R
If you have SimpleIDE v0-8-5, choose Project Manager -> Project Options -> Compiler = CMM. Works same as LMM except a little slower (still much faster than any XMM solution).
To use SRAM you will need SRAM and SD card. To use regular Flash, you only need one SPI Flash chip. If you want faster Flash and have the pins, you can add 2 QuadSPI Flash parts in parallel and use SSF option.
512 pages,
4KB sectors,
32/64KB blocks,
Fast Write,
Dual SPI
Best regards
Oliver.R
Get a 10 pack of these: http://www.digikey.com/product-detail/en/W25Q80BVSNIG/W25Q80BVSNIG-ND/2815927
Or the same in PDIP8: http://www.digikey.com/product-detail/en/W25Q80BVDAIG/W25Q80BVDAIG-ND/2208452
About the same as what you mentioned except has QuadSPI which allows for faster code if you need it and have P0-8 free + 2 pins. If you don't have pins for the fast 2 chip solution, a single SPI Flash is still much better than EEPROM.
I have some Stamp-Like PCB modules that use dual-QuadSpi if you want some.
and how is it with the spi driver where and how many are needed ?
so far i run an estimate that i will use 6 cogs
0 = Main Loop
1 - IMU (pasm reading and configure IMU includes i2c in pasm is 330 longs)
2 - Motor Driver and LED (pasm pwm fits 420 longs)
3 - Comm ( (pasm or c im not shure yet)Nordic 2.4GHz Telemetrie and Controller Xbox)
4 - SPI for Comm
5 - RX (pasm loop getting data from a RC Reciver as PPM and RSSI)
So i hope the new Hardware does not use more then 1 so 1 is left for later mods
And what are those boards you have some info or pic or price
Best regards
Oliver .R
Only for byte-wide Flash code storage. The solution is roughly 30% faster than SPI Flash. Some comparisons are made below.
>> and how is it with the spi driver where and how many are needed ?
The cache drivers for typical SPI Flash use 4 pins. We have drivers for the Windbond parts and SQI. Any cache driver uses a COG.
>> so far i run an estimate that i will use 6 cogs
Take note that, at the moment Propeller-GCC XMM modes only support multiple COGs with cognew using PASM/GAS or COGC.
Multiple LMM/CMM COGs started with cogstart or _start_cog_thread will not work with XMMC or other XMM modes.
>> And what are those boards you have some info or pic or price
I'll send you some un-assembled PCBs for free in first class mail in the USA. They are entirely surface mount boards except for the edge pins.
Check this thread for more info: http://forums.parallax.com/showthread.php/129713-Introducing-the-SpinSocket(tm)-Concept?p=978250&viewfull=1#post978250
I was looking around and found some performance comparisons: http://forums.parallax.com/showthread.php/136397-Speed-Comparisons-of-Spin-LMM-and-XMMC?p=1057256&viewfull=1#post1057256
According to that table:
instead of printf i use a serial cog what gave me a lot of room kb wise.
But still i have this funky error on compiling its not it self the atan function then more when i pass the pointer back from the float.
i attached the project files so its easy to see.
open project and compile all works well
compiles in LMM with
25976 bytes sent so 6k-+ left for the missing code i need ( SPI /Comm and RC Reciver )
open file :sensfusion6.c go down and uncomment the marked error casing lines
and then compile
as you guys can see the yaw works as long i take it in steps so atan2 works,
atan works but not passing the value back
????
one solution is linking the .o file of the mathlib directly in but of course that makes my ram go puff
I hope its a bug some where
Best regards Oliver .R
Those must be numbers without optimization. With optimization PropGCC LMM is at least 10x faster than Spin, and CMM is usually 2x-4x faster than Spin. I haven't done a lot of benchmarks in XMM, but I'd assume -Os would help quite a bit there (since execution time is often dominated by the time to fetch instructions from external memory).
Eric
Eric
mhhh??? so you can compile???
damm what wrong here
Eric
and it compiles in cmm and lm now thanks a lot so i can continue with my porting of stuff to finish my mockup code and get to my hardware design
Best regards
Oliver.R
I get it now compiled in LMM with mixed optima, and get all the code in 23k so i got 9 k left
Best regards
Oliver .R
Eric, sorry about the old performance numbers. Unfortunately, I can imagine someone quoting an old post like that again.
Smaller floating point will be very welcome.
I forgot about the atan/atan2 bug. I'm guessing the distribution got used because of the outdated info in www.parallax.com/propellergcc .
Id be interested to see those.
I take it you saw this? http://forums.parallax.com/showthrea...l=1#post978250
Don't have time to build them myself just now. PM your address if you want some PCBs.