CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sun Dec 16, 2018 3:50 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Oct 24, 2018 5:40 pm 
Offline

Joined: Sat Oct 06, 2018 10:00 am
Posts: 7
Hello.

We are using Codesys v3.5 sp10 in some of our applications, and we have noticed that some variables declared as global variables with a nonzero value, tend to get turned into zero for no reason. Having cross referenced the variables multiple times, we have found nothing in our code that alters the value of the mentioned variables. Also we have run the code both in a PLC and in the simulation mode, but the problem persists in both cases. This only happens to some of the global variables defined in that global variable block, and when we change the name of those variables, the error temporarily cedes. When we change the type of the variable, it starts to turn to zero of that variable type. (e.g. False for Boolean) When we write values to those variables in the code, the value immediately turns to zero. When we write values into the variable in the debugging mode, the value turns to zero again, immediately after pressing “write values”. When we force values, the value of the variable in the code remains to be zero. When we use pointers to write values, the value stored in that variable becomes a very small number. (Something close to 3e-305)

Althought we may delete the variable and write another variable with a different name to work-around this problem, we are worrying about this situation might be happening to some of the system variables that we would not be able to detect or it may spread to other variables over time, so we want to figure out the cause.

Thanks in advance for your replies.


Top
   
PostPosted: Sat Oct 27, 2018 5:54 am 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 259
Hi.

It could be cause by an array of variable types diferent than the problem variables running outside his limits, or a pointer to a variable of diferent kind pointing to bad.

Sent from my Moto G (5S) Plus using Tapatalk


Top
   
PostPosted: Tue Nov 06, 2018 6:47 pm 
Offline

Joined: Sat Oct 06, 2018 10:00 am
Posts: 7
Josep M. Rams wrote:
Hi.

It could be cause by an array of variable types diferent than the problem variables running outside his limits, or a pointer to a variable of diferent kind pointing to bad.

Sent from my Moto G (5S) Plus using Tapatalk


Hello.

Thank you for your reply. I am not sure if you got the point correctly or not. These variables have exact values at the begining and they are not being changed during the initialization of the program. Nevertheless, they are turning to zero unexpectedly.


Top
   
PostPosted: Tue Nov 06, 2018 8:46 pm 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 259
Hi.

Imagine you have declared an array of 100 integers, and after its you declare two reals.

Imagine that the compiler put your array beguining on memory position 1000, it will end on position 1199, and your first real will be on position 1200 and the second on 1204.

If you write something on the array index 102, you are writing over the exponent of the first real.

Sent from my Moto G (5S) Plus using Tapatalk


Top
   
PostPosted: Tue Nov 06, 2018 9:54 pm 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 259
Hi.

I don't know if that is the cause, but if in the exponent are wrote an big negative number your real will be a value near 0.

Could be....

Sent from my Moto G (5S) Plus using Tapatalk


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited