Logic Machine Forum
simple closed loop control - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: simple closed loop control (/showthread.php?tid=3685)



simple closed loop control - khalil - 16.11.2021

hello 
I used grp.checkwrite command in a resident script to write a true/false value on a switch actuator  
but some times due to power issue or other issues the command value is true while the F/B value is false (real Status), so the grp.checkwrite command will not write true on this value, while it should.

what is the best solution for this issue


RE: simple closed loop control - Daniel - 16.11.2021

You can set some periodical pooling on this object. There is parameter like this on the object.


RE: simple closed loop control - Erwin van der Zwart - 16.11.2021

That is logical behavior, if you write to the switch object for example 1/1/1 and your feedback is 1/2/1 then you need to know the value of 1/2/1 before writing to 1/1/1..  

grp.checkwrite checks in this case the internal value of the controller of 1/1/1 so the last sended value and this does not check the actual value of the feedback object 1/2/1.. the same counts for Daniels solution, this will get the value of 1/2/1 but writing to 1/1/1 does not change by it.

What you might want to do is send write always to the bus and use grp.write.

If you want to make the write depending on the feedback you need to send the feedback cyclic from the actuator, and make in your script a condition where you compare 1/2/1 with the new value you want to write to 1/1/1.


RE: simple closed loop control - admin - 17.11.2021

You can specify the status object address for grp.checkwrite:
https://openrb.com/docs/lua.htm#grp.checkwrite


RE: simple closed loop control - Erwin van der Zwart - 17.11.2021

Sorry, missed that one (oeps)….  Big Grin


RE: simple closed loop control - khalil - 17.11.2021

Thank you all 
Danial, Erwin, Admin
great feature I also missed it 
if I want to execute the command regardless delta 
I use this: grp.checkupdate('32/1/1',true,_,'32/1/2') !


RE: simple closed loop control - khalil - 21.11.2021

(17.11.2021, 08:50)khalil Wrote: Thank you all 
Danial, Erwin, Admin
great feature I also missed it 
if I want to execute the command regardless delta 
I use this: grp.checkupdate('32/1/1',true,_,'32/1/2') !

is it right to use underscore (_) here or not.
and what to use if I want to neglect the delta?
best regards,


RE: simple closed loop control - admin - 22.11.2021

Better use nil because if _ is defined as a global variable somewhere then the code might not work. But it only matters for numeric values, for boolean values delta is not used so it can be anything.


RE: simple closed loop control - khalil - 22.11.2021

(22.11.2021, 06:59)admin Wrote: Better use nil because if _ is defined as a global variable somewhere then the code might not work. But it only matters for numeric values, for boolean values delta is not used so it can be anything.

Thank you admin
appreciate your time and effort helping us 
best regards,