Periodic Logging and Reset Command


develer

Recommended Posts

I want to log values from an EtherNet device that I have set up and communicating to DAQFactory. Modbus registers 16384 and 16385 would be logged every hour and then register 17409 for need to be set to 3 and then to 0 to reset the values.

I also wish to log 16384 divided by 16385 for the hour's average part rate. I imagine once I understand how to do the logging these calculations should be clear but I am jsut starting out so its all new for now.

Link to comment
Share on other sites

OK, you'll want to use an export set for the logging so that you can log a single line triggered from a sequence. In the export set, you'll put MyChannel[0] for your expressions, where mychannel is the names of your channels. You can do the math for you calced value here too. Just create another line in the export set and put the math: MyChannel[0] / MyOtherChannel[0]. Then go to the details page and select Fixed Interval and Snapshot.

Now you can write a little script to log and do the reset. This will be in a sequence like such:

while(1)
   delay(3600) // wait an hour
   beginexport(myexportset)
   delay(1) // give the export set time to run
   myresetchannel = 3
   delay(0.1)
   myresetchannel = 0
endwhile

You can adjust the delay's as needed. I don't know how much time you'll need between sending the 3 and sending the 0.

Link to comment
Share on other sites

Alright,

It's working, but I want to set exactly to reset the count at the beginning of each production shift, or at least once a day (beginning of 1st shift at 5 am). And, everyday should log data (or export) with a different file name (.csv). Could be easily identified with the current date.

I set one timing channel with 60s (this channel receives the data of total production). I want to set a visual alarm (some display in the page) that opens a timecount if after 60 seconds the data received from this channel is the same as before (mychannel[-1] = mychanne[0]). Once machine starts run again, It just export this time to some file or delete.

Can you help me with that?

Basicaly, is set a Daily report that come up with informations like: Total uptime, Total downtime and total runtime, but not just sum downtime. Records the time that it started and ended. And total parts per day or shift.

Link to comment
Share on other sites

The help file describes how to do things precisely once a day. There are a number of ways to do it. If you are going to do it at 5am, the way I do it is using % (modulus):

private lasttime = systime() % 86400 / 3600
private curtime
while (1)
   curtime = systime() % 86400 / 3600
   if ((curtime == 5) && (lasttime != 5))
	   // do my log
   else
	  delay(1)
   endif
endwhile

As for the other calcs, just use global variables and put your logic in the above loop, probably outside the if so it calcs always. Note that [-1] is not correct. To get the next most recent point you want [1]. The bigger the number inside the [] the farther back in time you go.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.