Join us today!

Notifications
Clear all

The uninitialized variable VarName is used for initialization of fb. Use the attribute 'global_init_slot' to change the order of initialisation.

4 Posts
3 Users
0 Reactions
439 Views
Posts: 4
Topic starter
(@unnameduser001)
Active Member
Joined: 1 year ago
Hi,
Error code:
"The uninitialized variable Z_A1_X2_Ethernet [/Z_A1_X2_Modbus_TCP_Master /Z_A14] is used for initialization of fb. Use the attribute 'global_init_slot' to change the order of initialisation."
 
How do I get rid of this error or does anyone know any other elegant way to initialize these variables?
 
[It's an error I get in Codesys, but the same could happen in TwinCAT - I suppose]
 
Screen2
Screen1
Reply
3 Replies
2 Replies
 Alex
(@alex)
Joined: 2 years ago

Eminent Member
Posts: 30

@unnameduser001 may you show your FB_ModbusTCPSlave.... ?

Reply
(@unnameduser001)
Joined: 1 year ago

Active Member
Posts: 4

@alex I can but this error comes 100% from FB_Init. IoDrv... code is system / Codesys library so I can't change it.

Temporary, dirty solution:

Screen
Reply
Posts: 1
(@monkeyd)
New Member
Joined: 1 year ago

In TwinCAT I have had the same problem, but with two global variable lists.

The issue is the order of the initialization of function blocks or global variable lists. Your variable Z_A1_X2_Ethernet is most likely initialized after your fb: Fb_ModbusTcpSlaveDiagnostics.

TwinCAT gives the following instructions on how to explicitly set the order: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2529649291.html&id=

 

In my problem, I used a variable from one global variable list to initialize another variable in a different global variable list.

My solution was to use {attribute 'global_init_slot' := '49992'} at the top of the global variable list that needed to be initialized first and {attribute 'global_init_slot' := '49993'} in the second global variable list.

TinyTake20 11 2023 01 25 47
Reply
Share: