8:28 am
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
8:36 pm
March 12, 2015
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.
8:55 am
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
3:02 am
March 12, 2015
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.
7:31 am
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
14
1 Guest(s)