0
Answered

Internal variable false but result true

Rich Saunders 1 month ago in IQANdesign updated by Gustav Widén (System support) 4 weeks ago 6

My internal variable is false but my result is true and it is not a latching function? 

Image 4207

GOOD, I'M SATISFIED
Satisfaction mark by Rich Saunders 4 weeks ago
+1

I think it is best to also set the false.

so, then EmStop := true else Emstop := false

The value of non-static variables are undefined between cycles. In this case it retained its value, but that may not always be the case. 


As Ed suggest, it should be set before use in each cycle.

I tried that and still did not return to false, changing the IDC from Q code to object list solved it. I have also had another case with a piece of software recently updated to design 6, trying the suggested did not help. 

This is working via the simulator, if you start to measure with the non static variables as false then the result will be false, once you enable the output it seems to latch on and not return to false even if all the variables return to false. 

Image 4244

In your code, the variables are only assigned the value true; to build it up like this you also need to set to false. 

You could achieve this with an else statement for each variables. 

A more compact way of always assign the variables would be something like this

js1active := outside(inputs.js1, 117, 137)
js2active := outside(inputs.js2, 117, 137)

Result := js1active or js2active

Alternatively, you could avoid the named variables and assign your result directly, like this

Result := outside(inputs.js1, 117, 137) or _
outside(inputs.js2, 117, 137)


As yet another option, you could use a classic object list instead

Image 4249

+1

Thank You Gustav

The code as posted worked OK on the Design 5 projects, I guess I need to tidy this up going forward, for some reason I put the code as an IF statement in this instance.