Author Topic: Reading a single bit form a SLC500  (Read 1126 times)

sds5150

  • Newbie
  • *
  • Posts: 14
    • View Profile
Reading a single bit form a SLC500
« on: April 18, 2016, 04:49:11 PM »
I need to trigger a SQL insert based on a bit in the PLC.
I can make everything function with a pushbutton, but I have not figured out way to monitor a bit.
I have a timer set up at a half second and the code will be within this "tick"


I am using the EthernetIPforSLCMicroCom driver and my bt is B11:0/13

My plan was to declare a boolean variable and read the value from the plc at the rate of the timer.
Then trigger the SQL insert if the variable was equal to 1
After closing the connection write back a 0 to the same location as a handshake to the PLC.
Any advise will be appreciated.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Reading a single bit form a SLC500
« Reply #1 on: April 18, 2016, 05:13:24 PM »
- Add a DataSubscriber to the form
- Set PLCAddressValue to B11:0/13
- Double click the DataSubscriber to get back to the code
- Add this code
Code: [Select]
If e.values(0)="True" then
'* insert your code here
. ..
EthernetIPForSLCMicroCom1.Write("B11:0/13",0)
End If

sds5150

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Reading a single bit form a SLC500
« Reply #2 on: April 19, 2016, 04:18:00 PM »
Thanks Archie!
That helped me out!
I managed to get it working.

Private Sub xP2DataSubscriber_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles xP2DataSubscriber.DataChanged
If xP2DataSubscriber.Value = "True" Then