special problems with global variables | 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
special problems with global variables
October 6, 2015
2:14 pm
Avatar
Adrian
Guest
Guests

Hi community,

i try to develop an arduino (uno, nano, mini) sketch with the ESP-8266 (ESP-01) Wifi modul. at the end it would be a Wifi data logging system and an actor controler. (TCP Server with Errorhandling maybe with web server if i have enough flash space)

For the UART communication i have two global variables. The first one is for data writing ("string") and the other for data reading (uint8-array).

When i will use the read Data in the following SUBvis, the arduino have some different problems.

I wrote a string-parse function to analyse the data (each line) from ESP8266 modul in a while loop and set special flags. This string-parse-function was stored a a SUBvi. When i request the data outside of the while loop in this VI and convert to string, the string is empty inside the while loop. So the Match Pattern Function can not find anything. Sometime the Arduino will crash as well.

When i only connect the uint8 array line to the while loop and convert to string inside the loop, the string is empty too. On this case the arduino will crash very often.

When i request the global uint8 array and convert to string inside of the loop, it will work. The Match Pattern Function works correctly. But at this case i have sometimes the problem that the SUBvi did not work correctly. A new string was collected and the Match Pattern Function did not find anything and i don't know why.

My free SRAM space is about 800b and all other function after that works correctly. 

I hope you understand my problem. It is a bit difficult to describe. 

Hardewareinformations: Arduino Uno SMD R3, Wifi modul ESP8266/ version 01 with AT command 0.9.5, UART speed = 115200, 4x20 character LCD i2C Display, 4x ADC inputs and an I2C temperature sensor

the hole sketch use arround 25kb flash and arround 650byte global SRAMspace.

October 6, 2015
3:03 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

This sounds like a memory issue. When you have fragmented or low RAM things will act strange.  But can you post your VI and I will try to take a look to see if that's the case?  Be aware that strings and arrays use dynamic memory allocation from the heap so that space is not allocated til runtime and is suceptable to fragmentation. 

October 6, 2015
11:06 pm
Avatar
Adrian
Guest
Guests

hello,

thank you for your fast answer.

i had found the first issue. the global variable for wifi data (uint8 array) had no size. at every cycle the array had an other size from 5 to 50 bytes. now i initialize this array at every cycle to 40 bytes. the arduino didn't crash.

But i can not understand the problem with my UART data global. This array is initialized with a 100 byte array. this is the maximum UART packet size too.

The string-parse-function only work fine, when  the global request is inside the loop.  But i can not see the difference between  the request inside and outside of the loop.

maybe you can see it in my VI. some variables have german names. i hope that is not a problem...:)

October 6, 2015
11:16 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Can you zip and send the whole project?  This is calling many subVIs that were not included.  Also, please specify exactly where you are having the global issue with the UART data global.  It could be an issue with the German variable names.  There are characters in here that the Compiler doesn't support and it is quite possible that is an issue.  We recommend using the Compiler with Windows set to English as there are limitations to what can be interpreted in non-English languages without translations.

October 7, 2015
4:59 am
Avatar
Adrian
Guest
Guests

Hi Steffan,

okay...that is a good information. But the compiler comes with no error after compilation...?? Is that right?

I will check all global names and all VI names for non english characters.

Do you have a list of non allowed characters?

I think in one of my globals i use the name "byte"....i will check out...i think there is my error.

Many thanks

Adrian

October 7, 2015
10:53 pm
Avatar
Adrian
Guest
Guests

Hi Steffan,

your tip was right. i had two global names with non english characters. This was the solution. i have changed all names and now the arduino do not crash.

But the first global problem with the UART global is always the same. inside of the loop it works fine....but not outside.

October 7, 2015
10:59 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Ok good.  Not sure exactly why it compiles unless we decompile the VIs.  But lets focus on your second issue.  Can you zip and send your whole project so I can look into it further?  If you dont want to post you can also send to support@geverywhere.com.

October 14, 2015
6:10 pm
Avatar
Adrian
Guest
Guests

Hi Steffan,

sorry for my late answer. now i have two projects. the first one is in ok.zip and works fine. The global "UART read" is inside of the loop in "suche in UART.vi".

The secound ZIP "error.zip" is the other project with the global "UART read" outside of the loop in "suche in UART.vi". 

I hope you can analyse my projects. I have tested both on my Arduino UNO SMD R3.

If you have questions please ask me. I hope you can find the issue.

Many thanks

Adrian

October 14, 2015
11:20 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Adrian,

I took a look at both zips and in "suche in UART.vi" there is no reference to the "UART read" global variable.  In fact, I could not find a reference to that global in the entire project.  Please clarify.

UART-read.pngImage Enlarger

sp_PlupAttachments Attachments
October 15, 2015
5:06 am
Avatar
Adrian
Guest
Guests

 Hi Steffan,

i took a look too. in my project (the both zips) i have found the references......??....but you are right. when i search all references from the global variable in the project there is no result. When i open the vi "suche in UART.vi" and search references from "UART read" i got the result below.

may be this will be the issue.....but the "ok" project works fine on Arduino.......??

 search-referenz.pngImage Enlarger

sp_PlupAttachments Attachments
October 15, 2015
2:29 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Adrian said

sorry for my late answer. now i have two projects. the first one is in ok.zip and works fine. The global "UART read" is inside of the loop in "suche in UART.vi".

Are you referring to the variable "UART read" or "UART data"?  Above you said "UART read", which I can't find a reference to.  But your image shows you are searching "UART data".  Which variable is it you are concerned about?  Please send a screenshot of the exact piece of code from the error project that is causing a problem.

October 15, 2015
5:13 pm
Avatar
Adrian
Guest
Guests

oh sorry....that was my fault.

you are right....i mean "UART data"! this variable is declared in the vi "global UART read.vi"

i took three screenshots. first one from project explorer, the second from vi "suche in UART.vi" with the issue (there is a note inside the vi) and the third from the same vi with no error (there is a information note too).

i hope you see what i mean.

project.jpgImage EnlargerUART-data-global-variable-error.jpgImage EnlargerUART-data-global-variable-OK.jpgImage Enlarger

October 15, 2015
5:56 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Ok, thanks for the images.  Ill will take a look and let you know.

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

Adrian,

We identified this as an issue with how optimization is handled in certain cases involving loops and strings.  We have opened Case 127 for your reference.  As you found, a workaround is to pull the Global Read inside the loop.  It appears you can actually leave the global outside the loop and pull just the Byte Array to String inside the loop before your Match Pattern and that should also work.  Sorry for the inconvenience.

Steffan

October 16, 2015
8:13 am
Avatar
Adrian
Guest
Guests

Hi Steffan,

thanks a lot. i have found some other problems in the last weeks. I hope i will find them in my code.

Thanks for your very good work! the compiler is really really nice!

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