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 Oct 21, 2018 7:43 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Thu Oct 11, 2018 10:36 am 
Offline

Joined: Tue Sep 25, 2018 7:32 pm
Posts: 8
I have the Compile and Insert_Input methods of a function block, and they both take as input a VAR_IN_OUT of type UDT_DIs:

Attachment:
Compile method.PNG


Both methods work fine by themselves, but after adding a line to Insert_Input to call Compile, there is a program exception as shown.

Attachment:
insert_input method - doesn't work.PNG


Attachment:
errors.PNG


I've read through the documentation on methods.
I've tried to use THIS^.xxxx
I've tried to assign Data to a temporary local variable and passing this to the Compile method.
What am I doing wrong?


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Thu Oct 11, 2018 3:27 pm 
Offline

Joined: Mon Oct 01, 2012 8:33 am
Posts: 40
I think the problem is with your Data/IN_OUT parameter. Under the hood, IN_OUT parameters are essentially pointers so you must declare an instance of UDT_DIs somewhere and then pass that instance to your methods.

If you define Data in the main body of your function block, it will be defined in and accessible from all methods.


Top
   
PostPosted: Fri Oct 12, 2018 1:35 am 
Offline

Joined: Tue Sep 25, 2018 7:32 pm
Posts: 8
Hi rickj,
Thankyou for your reply. Yes you're right - one must take care with IN_OUT. Unfortunately this is not my particular problem:
I have exported the FB and imported it into a blank project, and it works fine, even with apparently all external conditions the same. Maybe it's project corruption, but I have already done clean all/rebuild. Might need to rebuild the project from scratch using export/import.


Top
   
PostPosted: Fri Oct 12, 2018 5:48 am 
Offline

Joined: Tue Sep 25, 2018 7:32 pm
Posts: 8
So it turned out to be an issue with the UDT_DIs that was being passed to the Insert_Input method (even though the test program was doing the same thing.....). I worked around the problem by copying the UDT_DIs structure to a temporary UDT_DIs, passing this, then copying the temporary UDT_DIs back to the original (with Codesys.... sometimes you need to tell yourself it was a bad dream and move on....)

Just to reiterate, you *can* do the method call I showed in the original post; I don't believe there is any fundamental issue with it.


Top
   
PostPosted: Fri Oct 12, 2018 7:46 am 
Offline
User avatar

Joined: Fri Jan 19, 2018 3:38 pm
Posts: 54
Hi, just a small question off topic question out of sheer curiosity, what flavour of IDE are you using? (....e Automation Platform)

_________________
https://github.com/Aliazzzz


Top
   
PostPosted: Fri Oct 12, 2018 8:28 pm 
Offline
Frequent User
Frequent User

Joined: Wed May 04, 2016 6:00 pm
Posts: 254
Have you try to change the name of compile?

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


Top
   
PostPosted: Mon Oct 15, 2018 4:36 am 
Offline

Joined: Tue Sep 25, 2018 7:32 pm
Posts: 8
Hi Aliazzz, I'm using Codesys V3.5 SP13 Patch 1. "Machine automation platform" is the name of the project.


Top
   
PostPosted: Mon Oct 15, 2018 6:38 pm 
Offline
User avatar

Joined: Fri Jan 19, 2018 3:38 pm
Posts: 54
LOL (slaps his own head) :roll:

_________________
https://github.com/Aliazzzz


Top
   
PostPosted: Fri Oct 19, 2018 1:01 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 20
Did you tried to just clean and rebuild all ? Pointers can be corrupted with online/partial edit


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

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


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