alanmanson Posted June 24, 2019 Share Posted June 24, 2019 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? Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 25, 2019 Share Posted June 25, 2019 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.) Quote Link to comment Share on other sites More sharing options...
alanmanson Posted June 25, 2019 Author Share Posted June 25, 2019 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) //************************************************ Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted July 8, 2019 Share Posted July 8, 2019 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.