Shop OBEX P1 Docs P2 Docs Learn Events
Memory overflow issue with 9 axis motion sensor module — Parallax Forums

Memory overflow issue with 9 axis motion sensor module

alex93alex93 Posts: 11
edited 2017-09-25 20:19 in Robotics
Hello everybody,

I am a french student in internship at university of Miami , who is using an activitybot robot kit in the context of a project.
I bought an LSM9DS1 9-axis motion sensor module in order to get accelerations of my robot.
However, when i am calling function to read accelerations (imu_readAccelCalculated(&ax, &ay, &az)) , i got a memory overflow issue during compilation.
The issue that i got is :

Project Directory: /Users/deniz/Desktop/Robot project/
/Applications/SimpleIDE.app/Contents/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld: cmm/V3_9AXIS.elf section `.bss' will not fit in region `hub'
/Applications/SimpleIDE.app/Contents/propeller-gcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/bin/ld: region `hub' overflowed by 944 bytes
collect2: ld returned 1 exit status
Done. Build Failed!

Your program is too big for the memory model selected in the project.


Could you help me about this issue ?

Furthermore , I would like to know where are saved library/function files and how to recompile them if I modify them.

Thanks in advance,

Alex

Comments

  • The 32K RAM size is a limiting factor with C on the Prop. The biggest memory users are SD file I/O, floating point and formatted output using printf/sprintf. The size for formatted output can be reduced by using "Simple printf" with the compiler or "Tiny Lib" with the linker. However, this doesn't help if you use sprintf or fprintf. If you use those functions you will need to write smaller version of them that support only the formats that you need.

    Floating point should be avoided if possible. If you do need floating point make sure you select "32bit Double" in the compiler options.

    The size for SD file I/O can be reduced by using code based on the FSRW Spin object.

    If you post a zip file of your project we can get a better idea of where you can save memory.
  • First of all , thank you for your reply Dave Hein.

    The fact is that I need and I am using all the points you quoted : SD file I/O , fprintf.

    To explain quickly , I have to record distance reached by each wheel , datas from motion sensor (accelerometer , magnetometer and gyroscope) into the SD card , and avoid all obstacles.
    Actually , the first part is working well , i am avoiding obstacles , recording distance reached by each wheel in ticks number.
    Now , the problem is the datas recording from the motion sensor.
    The purpose of the project is to create a 2D map of the environment of the robot .

    Please find attached my project.

    Thank you for your help.

    Alex

  • I had to comment out the '#include "lsm9dls.h"' line and also the references to imu_xxx to get it to build. These files were missing from the zip file. Without those references the resulting binary was 27K in size, so I can understand that the binary could be over 32K when the rest of the code is included. I added the attached printf.c file to the project, and it saved 8K of memory. Try including the attached printf.c file to see if that works OK with your program.
    c
    c
  • alex93alex93 Posts: 11
    edited 2017-09-26 17:13
    Thank you very much Dave Hein ! it works well with your file

    However , now when i am reading datas into SDcard , the display in the text file is bugged.

    The display is like this :

    distLeft[ (lot of space)1] = (lot of space) 224, distRight[(lot of space) 1] =(lot of space) 224
    left rotation = (lot of space) 1, right rotation =(lot of space) 0

    Whereas it was like this before :

    distLeft[1] = 224, distRight[1] = 224
    left rotation = 1, right rotation = 0

    I guess it is due to your print.c file , have you an idea please for this issue ?

    Thanks again
  • Use this version of printf.c instead. I disabled printing the leading blanks.
    c
    c
  • alex93alex93 Posts: 11
    edited 2017-09-26 18:09
    Perfect , everything works well !

    Thank you very much Dave Hein :)
  • fprintf and many other library functions are very generic, and support lots of options. If you only need very specific formatting, you'd be better off writing a function that does exactly what you need without all the other options. That, or possibly compiling in a different memory model - I'm not sure if you're doing this already, but compiling as CMM instead of LMM gains a significant amount of space at the cost of a significant amount of speed. Depending on your project, you may need the space more than the speed.
Sign In or Register to comment.