Remove Duplicate Var Declarations.vi | 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
Remove Duplicate Var Declarations.vi
March 11, 2016
3:59 pm
Avatar
codyd87
Member
Members
Forum Posts: 7
Member Since:
March 11, 2016
sp_UserOfflineSmall Offline

 [Image Can Not Be Found]Does anybody have any insight to what causes my code to not compile on occasion and show me this error below?[Image Can Not Be Found]Screenshot-2016-03-11-08.34.45.pngImage Enlarger

It comes up from time to time and I usually end up having to build my code in a slightly different manor then it compiles.  It is becoming more and more of an issue as my compile time is increasing as my code grows on the project.  I am not explicitly using local or global variables and I don't know how to prevent the compiler from generating duplicate variable declarations.  

 

There must be somebody out there who has come across this same issue.  It would be nice to find out what causes this.

March 11, 2016
6:39 pm
Avatar
filipealtoe
Admin
Forum Posts: 98
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Wow; actually it is the first time I see this error message related to the compiler. This is not an error message generated by the Compiler though, it is coming from LabVIEW itself. I did a quick Google search on it and got some hits (below). The LabVIEW error seems to be related to large array allocation that breaks the allocated amount of memory to LV. However, your post indicates that sometimes you are able to download your code to your Arduino target. Does the target behave correctly running your code? The reason why I am asking this is, the Arduino target has much less memory than your dev PC; therefore, if this error is indeed related to large arrays on your dev PC; it will definitely break your target memory also; which will cause the Arduino to behave not according to your code. 

 

http://digital.ni.com/public.n.....B5006B46E1

 

http://digital.ni.com/public.n.....4000834238

Cheers
Filipe

March 11, 2016
7:06 pm
Avatar
filipealtoe
Admin
Forum Posts: 98
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Actually; can you attach a zip with the VI(s) you know it generate the issue?

Filipe

Cheers
Filipe

March 11, 2016
8:42 pm
Avatar
codyd87
Member
Members
Forum Posts: 7
Member Since:
March 11, 2016
sp_UserOfflineSmall Offline

Filipe,

I've attached all required files. Main vi is in folder called PROTO/test1a.vi.  It compiles when I remove case 43 from the case structure in the second last frame so I'm guessing that's the source of the error.  

 

I will spare you with the details of the objective of the code but there shouldn't be anything to complex going on.  It would be a great help to find out what causes this issue.  Let me know if you have any other questions

March 11, 2016
8:46 pm
Avatar
codyd87
Member
Members
Forum Posts: 7
Member Since:
March 11, 2016
sp_UserOfflineSmall Offline

The code runs as expected when it does compile.  The "problem" function is when i am trying to extract 8 bytes from an array of 25 bytes and place those bytes in to a string.

March 11, 2016
10:24 pm
Avatar
codyd87
Member
Members
Forum Posts: 7
Member Since:
March 11, 2016
sp_UserOfflineSmall Offline

I determined my problems occur (or one of the ways this sometimes happens) is when I use a shift register of a while loop with a string being the data type of the register. 

March 12, 2016
5:52 pm
Avatar
filipealtoe
Admin
Forum Posts: 98
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Thanks! This will help us tremendously in chasing the issue. I will keep you posted on what I find.

Cheers
Filipe

March 13, 2016
6:09 am
Avatar
filipealtoe
Admin
Forum Posts: 98
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Hello;

I have taken a look at your code. I have tried to isolate the issue to a string SR; but that wasn't in fact the source of the issue. I have replaced the SR on case 43 of your VI with other data types and the issue persisted. I couldn't find the root cause of the problem; however, your VI is very involved for an Arduino target. There are some subVIs that are floating without data flow dependency and a large sequence structure with nested structures that also contain floating VIs. This is probably pushing the limits of what the optimizer algorithm for the compiler can do for such a small target like the Arduino.

One suggestion would be for you to try and reduce the nestness aspect of your VI and enforcing data flow whenever possible via error cluster. 

Filipe

Cheers
Filipe

March 14, 2016
2:45 pm
Avatar
codyd87
Member
Members
Forum Posts: 7
Member Since:
March 11, 2016
sp_UserOfflineSmall Offline

When my code does compile it only uses up 6% of the available memory on my Arduino and I don't use any arrays that I'd consider large by Arduino standards and hardly any other variables. In earlier instances of my code failing, it happened at stages where my code was around the 4% mark.  I feel something specific in the compiler is very inefficient in how it handles the LabView code.  I've been able to run a similar amount of processes in a similar manor in programming in the Native Arduino language.  It's nice being able to have a visual representation of my code using Labview but its unfortunate that it takes so long to program in a way that the compiler likes.

March 14, 2016
7:18 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Please consider re-architecture your VI(s).  Just like in normal LabVIEW, it is bad practice to put most of everything into one VI in one large sequence structure.  This becomes of even greater importance for a small memory target.

The way the ACC4LV compiles your code is that it process things one VI at a time and each VI gets essentially converter to a function 1 for 1.  So even if your code did compile fast, it would still be pretty sketchy on an Arduino because all the memory allocations (well most since you do have a few subVIs) would be happening on the stack level in one function so to speak.  By modularizing your code you are effectively increasing its performance and memory management since the stack can release memory as the function goes out of scope (automatic variables).  This is discussed in the Important Considerations section of the user manual.

Im guessing the long compile time problem you are facing here has to do with the extensive use of sequence frames and nested structures.  I can tell you we have very complex programs in use running upward of 60% flash usage on Arduino targets and they have very quick compile times.  But they make heavy use of modularizing functionality into smaller functional blocks and subVIs.  You also have a lot of duplicated code, which can definitely take longer to convert and compile.  I would recommend creating a reusable SubVI for similar parts of your VI (like setting the 4 digital outputs) as well as breaking apart each section of your sequence structure into smaller modules/subVIs.

March 14, 2016
7:29 pm
Avatar
codyd87
Member
Members
Forum Posts: 7
Member Since:
March 11, 2016
sp_UserOfflineSmall Offline

Initially I was building lots of sub functions to handle repeated functions however the code wouldn't compile and after many different tries, I found this was the only way my code would compile.  

October 23, 2020
9:07 pm
Avatar
nealpederson
New Member
Members
Forum Posts: 1
Member Since:
May 23, 2019
sp_UserOfflineSmall Offline

I am having crashes with the same point with very simple VIs.  The "Remove Duplicate Var Declarations.vi" appears to go into an infinite loop and eventually crashes with a memory error.  I'm trying to use some simple sub-VIs that have local variables in them for reading previous values (since shift registers don't appear to work in sub-VIs).  I think there is something wrong with the "Remove Duplicate Var Declarations.vi" but I don't want to fix the code included with the Arduino Compatible Compiler for LabVIEW.  Please help if at all possible.

I attached an example.  Load Main.vi for the top level.  Note that I'm programming an Arduino Nano.

I'd also like to know if it is possible to have reentrant VIs used with the Arduino.  I haven't had any luck doing this and it appears that to accomplish the same thing I have to have separately named sub-VIs that do the same thing for each location they are used in (i.e. the EdgeSense VIs in what I am sending).

Is it possible to use shift registers in Arduino sub-VIs?  I haven't had any luck doing that either and is why my EdgeSense sub-VIs use a local variable instead although that doesn't work very well either.

Thanks!

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
13
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