Recommended Posts

I have an if statement in a sequence, here is an example

if ((channel1[0] != 9) && (Channel2[0] != 9))

   DoSomething()

endif

I have at least one of the channels set to 9 and it is still getting to DoSomething().

What am I missing?

Is there some compiled cache somewhere that needs to be cleared and recompiled?

Share this post


Link to post
Share on other sites

There isn't a cache, but if you edit a sequence that is running, you have to stop the sequence and restart it to pick up the changes.  If that isn't it, I'd have to see the rest of the code to know what is happening.  You might have a symbol name conflict (i.e. a private or global variable with the same name as one of your channels.)

Share this post


Link to post
Share on other sites

I closed DAQFactory and reopened it.

All my channel names start with Chn, so I have no variables with the same name. My sequence code is below:

"ChnSystemEstop" is a channel that gets set or cleared when an emergency estop button is pressed on the system. The estop button is physically connected to a controller board that communicates with DAFactory over a serial connection. The controller board is polled for messages, which then sends a reply.

systemEStopSignalled is a global variable which is used to stop the clear estop sequence being called unless an estop has been sent already.

SystemEstopCmd is a sequence which sends an emergency stop request message to all parts of the system.

SystemEstopClearCmd is a sequence which sends an emergency stop cleared message to all parts of the system.

The four channels: ChnCell1Status[0], ChnCell2Status[0], ChnCell3Status[0], ChnFinalInspectionStationStatus contain the status value of the 4 parts of the system, the value 9 on the cells indicates that that particular cell is estopped, and the value 8 on the final inspection station indicates an estop, so we cannot send the estop message.

I had all 4 of these channels in the watch window, so that I could see their latest value. ChnCell3Status[0] was at the value 9, yet it still went into the body of the if statement, which clearly asks for not equal to 9.

This did not happen all the time but it did happen a lot at random.

Hope that makes sense

Could it be that I was writing a channel in another sequence while I was reading it here?

Thanks

//************************************************

while(1)
   
   if (ChnSystemEstop[0] > 0)
      
      if (systemEStopSignalled == 0)
         systemEStopSignalled = 1
         beginseq(SystemEstopCmd)
         while(Sequence.SystemEstopCmd.Running)
         endwhile
      endif
      
   else
   
      // Try hardcoded numbers as we keep getting through
      if (systemEstopSignalled == 1)
         if ((ChnCell1Status[0] != 9) && \
            (ChnCell2Status[0] != 9) && \
            (ChnCell3Status[0] != 9) && \
            (ChnFinalInspectionStationStatus[0] != 8))
            
            systemEStopSignalled = 0
            beginseq(SystemEstopClearCmd)
            while(sequence.SystemEstopClearCmd.Running)
            endwhile
         endif
      endif
   endif
   
   delay(0.01)
   
endwhile

return (NULL)

//************************************************

Share this post


Link to post
Share on other sites

Yes, it may be a threading issue.  You should debug it either by adding a breakpoint or by adding ? statements.  Also, see if it does it if you stop all the other sequences / events.

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