Hi All,
We use Ignition (Vision) at work on a few of our systems where a DCS isn't appropriate and I have started playing around with Perspective at home to automate a few things around the farm. So far I am finding Perspective to be challenging and rather limited compared to what Vision offers, but I am enjoying the challenge.
I'm a little stumped why a specific script I have written doesn't seem to fire when I want it to.
I am sensing the temperature in one of our chicken coops and then using a relay to run a plug-in to turn a heat lamp on and off depending on the temperature in the chicken coop.
I have ignition push buttons to manually control the light, one for on and one for off, and then a toggle switch to put the heat lamp into auto or manual mode. I also have Numeric Entry Fields to enter the setpoints for the on and off variables.
The issue I am having is the script only seems to fire when I toggle the toggle switch from manual and then back to auto again.
The script is tied to the toggle switch (on mouse click) and looks like this:
def runAction(self, event):
while (True):
if system.tag.readBlocking("[default]Viking Coop/Heat_Lamp_Auto_Manual")[0].value < 1:
system.tag.writeBlocking("[default]Viking Coop/Viking_Coop_Heat_Lamp",0)
break
if system.tag.readBlocking("[default]Viking Coop/Viking_Coop_Temp2")[0].value <= system.tag.readBlocking("[default]Viking Coop/Heat_Lamp_ON")[0].value:
system.tag.writeBlocking("[default]Viking Coop/Viking_Coop_Heat_Lamp",1)
if system.tag.readBlocking("[default][default]Viking Coop/Viking_Coop_Temp2")[0].value >= system.tag.readBlocking("[default]Viking Coop/Heat_Lamp_OFF")[0].value:
system.tag.writeBlocking("[default]Viking Coop/Viking_Coop_Heat_Lamp",0)
Currently if the toggle switch is in automatic mode, and the temperature falls below the 'turn heat lamp on setpoint' the light doesn't turn on until I toggle switch to manual and then back to automatic mode. The same thing happens when the temperature increases above the 'turn heat lamp off setpoint'.
I have a similar script controlling the water level in a well pit (on a different view), and it runs in automatic all day long without me having to intervene with it ever.
def runAction(self, event):
while (True):
if system.tag.readBlocking("[default]Well House/Pump_Auto_Manual")[0].value < 1:
system.tag.writeBlocking("[default]Well House/Well_Pit_Pump_ON_OFF",0)
break
if system.tag.readBlocking("[default]Well House/Well_Pit_Level")[0].value >= system.tag.readBlocking("[default]Well House/Well_LevelControl_ON")[0].value:
system.tag.writeBlocking("[default]Well House/Well_Pit_Pump_ON_OFF",1)
if system.tag.readBlocking("[default]Well House/Well_Pit_Level")[0].value < system.tag.readBlocking("[default]Well House/Well_LevelControl_Off")[0].value:
system.tag.writeBlocking("[default]Well House/Well_Pit_Pump_ON_OFF",0)
For the life of me I can't tell the difference between the two. I'm probably missing something obvious.
The only difference I can think of is that the well pit level control is the only script tied to a toggle on the view it is located on whereas the Heat Lamp Control is on a view that also has a 2nd toggle with a script that controls the ambient lighting in the coop based on the time of day (which also works perfectly fine in automatic). I wouldn't think that should have anything to do with it, but who knows.
I'd welcome any feedback, or a cleaner way of accomplishing this in Iginition.