codesys "object reference not set to an instance of an object"

lesmar96

Lifetime Supporting Member
Join Date
May 2017
Location
PA
Posts
520
SoMachine v.4.3 which is Schneider's version of Codesys.

I am writing a small program. One POU is in SFC But this message box pops up and says "object reference not set to an instance of an object" I get this message any time I try to build the program or log into the controller.

Everything works fine in all the POUs and it builds just fine until I add the program call for the SFC POU. Then I start getting this message. The SFC POU builds just fine without any errors, and it is only after I add the program call under task configuration that I start getting this message.

Any help on what is wrong?
 
I haven't used SoMachine but I do use TwinCAT (Beckhoff) which is also based on Codesys. I believe the "object reference not set to an instance of an object" error may have to do with instantiation of function blocks. You can't use a function block without creating a variable instance of it... in other words you can't just put a TON in your program, you have to create a variable myTON of type TON and call that. You likely know that already but it's something to double check.

I've found with TwinCAT that a program or FB isn't fully checked/verified during a build unless it's included in a call from the main POU. That may explain why the error doesn't show up until you add it to your task.
 
Not versed in TwinCAT but do you have a target specified. Going from memory but I have seen this message before and I seem to remember it coming up when there was no target hardware specified.
 
I haven't used SoMachine but I do use TwinCAT (Beckhoff) which is also based on Codesys. I believe the "object reference not set to an instance of an object" error may have to do with instantiation of function blocks. You can't use a function block without creating a variable instance of it... in other words you can't just put a TON in your program, you have to create a variable myTON of type TON and call that. You likely know that already but it's something to double check.

I've found with TwinCAT that a program or FB isn't fully checked/verified during a build unless it's included in a call from the main POU. That may explain why the error doesn't show up until you add it to your task.


I talked to Schneider tech support and they told me basically the same thing as this.

I was trying to find the issue and made some changes and the error has gone away, but I wasn't 100% sure which change I made caused the difference.
 

Similar Topics

Hello, I am using a Hitachi Micro EHV+ for a small project, and I wanted to have a Web visu, done with Codesys V3.5 SP13 Patch 2. I test the...
Replies
6
Views
273
Hello, I have a requirement to manage the text alignment dynamically. So, for example: 1. English Texts should be displayed from Left in...
Replies
0
Views
88
Hello, I am new to Codesys, and am trying to learn about it for a project we're developing. I've got a couple questions, but first a little...
Replies
1
Views
134
Hi everyone, as this is my first experience with Rockwell Software i would like to know what's the best way to make Enumerations?
Replies
10
Views
491
I am trying to get Codesys to work with a couple of Moxa ioLogik E1200 series DIO devices (E1210 and E1211). I am able to write to the E1211 DOs...
Replies
2
Views
165
Back
Top Bottom