Sign in to follow this  
Followers 0
vaibaras

Twincat PLC control

7 posts in this topic

Hey, when I declarate new local variable in function block Verw_P760_TRR in TwinCAT PLC control and try download this block to PLC receive message see in the picture. It is ok? I hope someone can help me. And thanks for your time in advance. Edited by vaibaras

Share this post


Link to post
Share on other sites
Never seen this message in TC2 so I guess you are working in TWinCAT 3. Anyway, I've suffered what this message explains several times: when you change a function block and there are pointers involved the best you can do is rebuilding the project and LOAD ALL in order to start from 0 avoiding misaligned pointers. a problem in your pointers can put your PLC in an invalid state as it can go to a PAGE FAULT. if you face this situation then you can only restart the PLC to continue working. Pointers are extremely powerful, but they have their own problems and you need to be careful when using them. Hope this helps.

Share this post


Link to post
Share on other sites
Hello, Thanks for answer. I am working TC2, but I find in MAIN(PRG) declaration Verw_P760_TRR : Verw_P760_TRR. Maybe this is reason?

Share this post


Link to post
Share on other sites
Didn't know that would even compile... If I've seen it right, you are declaring variables using the same name for the variable itself than for the variable type... What I would recommend you is to use a different name in the variable name than in the variable type e.g.: fb_Verw_P760_TRR : Verw_P760_TRR; PS: If you are declaring variables that way in order to get a special behavior, could you please describe what you get doing that? thanks. Hope this helps. Edited by Joan Murt

Share this post


Link to post
Share on other sites
In my factory started new line with TwinCat system. I started to study this plc program, tryed to modifie and got this problame. I dont know why is done like this. Maybe they done it speciale that would be more dificult to modifie. Or maybe are some other reasons? Thanks for answer.

Share this post


Link to post
Share on other sites
I've just tested this implementation methodology... Just compiled it and I've seen that the function block can't receive parameters if you work that way... Probably that was their intention but it differs a little bit from what the function blocks are designed... this looks like a "static class" in C++... Of course it has it's reasons, but it is too much constraining: If you don't want to be able to pass parameters to your FB simply don't add INPUT variables. If you want more than one instance of that function block, naming it different than it's own definition name it's mandatory. Can't understand why they've chosen this architecture... they will have their own reasons...

Share this post


Link to post
Share on other sites
it is a warning to tell you the variable is rewritten somewhere else in your program, if you have any pointers directing to it, they will be pointing wrong place. as i do not use any pointers (i hate them) no problems with them. if the var is not pointed just carry on.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0