code optimization functionality in arduino compatible compiler | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
code optimization functionality in arduino compatible compiler
October 27, 2015
8:28 am
Avatar
Adrian
Guest
Guests

Hi,

is there any functionality for code optimization in Arduino compatible compiler included? if yes how it works?

i have some SUBVIS in my project which use different space of flash. There are VI's that will use around 2kb Arduino flash when i compile them separate. If i use them in combination the flash consumption of each VI is higher. Sometimes some VIs needs 1.5-2x of flash space (3 to 4kb).

maybe there is a very simple description.

many thanks!

Adrian

October 27, 2015
8:36 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Yes, the compiler has some forms of memory optimization.  This is mainly for variable optimization in RAM though.  Please read the Important Considerations section titled "Memory Management" of the user manual for this.  What you are referring to is Flash.  There can definitely be differences when compiling in a larger project based on how the SubVIs are called and the code usage in the main VI.  But I don't think you can tell which VI is consuming what quantity of space when compiled in a larger VI.  Not sure what you mean by "the flash consumption of each VI is higher".  You would need to provide an example and we might be able to tell you what is going on.

October 28, 2015
8:55 am
Avatar
Adrian
Guest
Guests

Hi Steffan,

thanks for your response. The SRAM optimization is a very good "tool" to save a lot of SRAM at execution time but it takes a lot of CPU cycles to resize an array or string. Sometime it makes the target a bit slow but there are some ways to solve this problem.

Thanks for your information about the flash. So all in all there is no functionality in the compiler for code optimization. That is good to know.

Thanks for your help!

Adrian

October 29, 2015
3:02 am
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Yes, thats why it is recommended to limit use or eliminate use altogether of arrays and Strings.  Due to the nature of LabVIEW functionality of arrays and Strings (ability to build arrays, concatenate, auto-index, etc.) those datatypes had to be implemented using dynamic memory allocation, which require constant de-allocation and re-allocation from the heap, which causes fragmentation and longer processor cycles.  The tradeoff is the ability to user a seamless compiler for LabVIEW on Arduino targets.  If your applications become more complex, consider using an Arduino Due, which has much more horsepower and memory.  This is also described in the user manual.

October 29, 2015
7:31 am
Avatar
Adrian
Guest
Guests

Hi Steffan,

yes...the due is very good. An Arduino MEGA256 is also good for this but i would like to have a very small system. My application should run on a Arduino Nano, mini or micro with the ATMEGA328P.

It should be a wifi data logging system (onboard ADC and sometimes an additional 16bit I2C ADC) with actor controling and some small observation functions including with an LCD Display. I would use all of the program memory (flash). Now my project use around 29500byte and works really fine. I always have around 500-600byte of free RAM.

I solve the array resizing "problem" with fixed sized arrays. My data array for UART communication use always 100 byte. At one point in my application i delete this array to get more free RAM for the following functions. only at this time i burn CPU cycles.

The actual cycle time of my application is between 900µs to 1ms at normal mode. For the "UART fast mode" i ensure, that the cycle time is always faster than 500µs per cycle. (UART buffer of 64byte at 115200byte/s UART speed needs ~550µs for overflow) 

One actual open problem is the handling of the wifi multi connection. All of my solutions needs to much flash or RAM...so i have to think about to find a better solution for this.

For the central control system i would use the due or MEGA256 or an Raspberry Pi. I am not sure. I think the due i better for this.

Many thanks,

Adrian

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
6
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356