Author Topic: Resetting values to default when communication to PLC is lost  (Read 1049 times)

francis

  • Newbie
  • *
  • Posts: 15
    • View Profile
Resetting values to default when communication to PLC is lost
« on: February 10, 2021, 05:03:51 AM »
Hello Everyone,

I am looking for a way to reset integer values to 0 or bits to off when communication to a PLC is lost and restart reading correct values when communication is regained. What is happening in my application is that when values are read and communication is lost, the values keep on alternating with "ReadTimeout". I am using BasicDatalogger2 to log the values to csv file which I automatically upload to MySQL database with a php application. The values read before loss of communication keep on logging to the csv/database.

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
Re: Resetting values to default when communication to PLC is lost
« Reply #1 on: February 12, 2021, 02:45:51 PM »
This can be done a number of ways, firstly the BasicDataLogger2 has a "ComError" event available which can call a method which you could use to write those 0's you're referring to. Not sure exactly what you're writing or how you're holding the data before sending it to the SQL database but that's on you :).  Alternatively, if you use the "DataReturned" or "DataChanged' events, at the very beginning of the event handler method, you could fill all of your temp variables with 0's prior to populating them from the BasicDataLogger2's data, then if the BDL2 is errored the application would write 0's as opposed to the previous data. Again these are all very vague descriptions since I have no idea your application and how it works.
Still just trying to figure out this thing called Life.