AdvancedHMI Software
General Category => Support Questions => Topic started by: DBTechServ on September 18, 2014, 03:28:20 PM
-
I am trying to use the up/down buttons on TempController.vb to raise/lower the property "PLCAddressValueSP" value without having to create plc tags and logic for increase and decrease which would then be associated with "PLCAddressClick3" and "PLCAddressClick4" properties. Is there an easy way to do this in the TempControl.vb code?
Maybe by using an inc/dec value set in the properties?
-
One way to do it is to handle the MouseDown events for the buttons:
Private Sub TempController1_Button4MouseDown(sender As System.Object, e As System.EventArgs) Handles TempController1.Button4MouseDown
Dim Value As String
Try
Value = ModbusRTUCom1.Read("40001", 1)(0)
Try
Value += 1
ModbusRTUCom1.Write("40001", Value)
Catch ex As Exception
MsgBox("Failed to write")
End Try
Catch ex As Exception
MsgBox("Failed to read - " & ex.Message)
End Try
End Sub
-
Thanks Archie. I'll give it a try.
I am assuming that I would use my CompactLogix tag reference instead of the ModbusRTUCom1.read as shown in your example.
FYI, your solution for the digital panel meter limits was perfect. Simple paste and run. THANK YOU :)
-
with this modified code, I get the 'failed to write' error - (the original code is commented out)
Private Sub TC_Seal_Button4MouseDown(sender As System.Object, e As System.EventArgs) Handles TC_Seal.Button4MouseDown
Dim Value As String
Try
'Value = ModbusRTUCom1.Read("40001", 1)(0)
Value = TC_Seal.PLCAddressValueSP
Try
'Value += 1
Value = Value + 1
'ModbusRTUCom1.Write("40001", Value)
TC_Seal.PLCAddressValueSP = Value
Catch ex As Exception
MsgBox("Failed to write")
End Try
Catch ex As Exception
MsgBox("Failed to read - " & ex.Message)
End Try
End Sub
I tried the " value +=1 " first with same result and then commented out to try current version
-
Add this to get more details:
Catch ex As Exception
MsgBox("Failed to write - " & Value & ". " & ex.message)
End Try
-
The error is a conversion issue -
msg - Conversion from string "HMI_SealTemp" to type 'Double' is not valid
-
I completely over looked this. You don't want to get the tag name and try to increment it, but to get the Value:
Value = TC_Seal.ValueSP
-
Ok the display increments on each click but then reverts to original value of TC_Seal.PLCAddressValueSP
this is current code -
Private Sub TC_Seal_Button4MouseDown(sender As System.Object, e As System.EventArgs) Handles TC_Seal.Button4MouseDown
Dim Value As String
Try
'Value = ModbusRTUCom1.Read("40001", 1)(0)
Value = TC_Seal.ValueSP
Try
'Value += 1
Value = Value + 1
'ModbusRTUCom1.Write("40001", Value)
TC_Seal.ValueSP = Value
Catch ex As Exception
'MsgBox("Failed to write")
MsgBox("Failed to write - " & Value & ". " & ex.Message)
End Try
Catch ex As Exception
MsgBox("Failed to read - " & ex.Message)
End Try
End Sub
-
Private Sub TC_Seal_Button4MouseDown(sender As System.Object, e As System.EventArgs) Handles TC_Seal.Button4MouseDown
Dim Value As String
Try
Value = TC_Seal.ValueSP+1
Try
EthernetIPForCLXCom1.Write(TC_Seal.PLCAddressValueSP ,Value)
Catch ex As Exception
MsgBox("Failed to write - " & Value & ". " & ex.Message)
End Try
Catch ex As Exception
MsgBox("Failed to read - " & ex.Message)
End Try
End Sub
-
A very big thank you.