Production Shift/Run Time/Down Time Logging

Recommended Posts


I'm rather new to all this and I have downloaded the trial version of DAQFactory and purchased a EDAM 9050 DAQ Unit from a local supplier. (

I have configured the unit and can set an output and read the inputs etc.

I have three questions, which are as follows:

On the EDAM 9050 I have set a counter, which requires two items which I seem to have to set in the hardware config tool supplied with the unit, these are:

Start the counter and reset the counter

My question is two-fold, how do I do this through DAQFactory

Or is there a smart way to do this within DAQ Factory?

I have spent some time reading through the various threads on this forum and also have a question regarding time which is:

My factory operates the following shifts:

06:00 - 14:00

14:00 - 22:00

22:00 - 06:00

So at the end of each shift I would like to reset counts etc, change my logging to a new file etc.

Would I need to do a sequence for each time or is there a clever way of doing this all in one sequence.

The third question relates to Running Time/Downtime logging:

I would like to log time cumulatively when the machine is running and the switch to another timer when say a breakdown or a changeover or a material shortage appears

Any help and examples etc you could let me know would be gratefully received.



Link to comment
Share on other sites

1st question: depends on the device. I'm assuming that's a Modbus device. You'll need to check their manual to see if they have a modbus register or coil that when set resets the counter.

2nd question: assuming you figured out the first one and create a channel to reset the counter: You just need one sequence:

private lasttime = formatdatetime("%H",systime())
   if (formatdatetime("%H",systime()) != lasttime)
	  lasttime = formatdatetime("%H",systime())
	  if ((lasttime == "6") || (lasttime == "14") || (lasttime == "22"))
		 resetcounter = 1

I'd probably run that at priority 0.

3rd question: you need two variables, one for running time, one for down time. If you want to persist it through DAQFactory restarts, I'd just use a Test D to A channel, set the history to 1 and the Persist to 1. Then create a sequence that checks each time:

private lasttime = systime()
private thistime
while (1)
   thistime = systime()
   if (systemUp)
	  uptime = uptime[0] + thistime - lasttime
	  downtime = downtime[0] + thistime - lasttime
   lasttime = thistime

systemUp is some flag or expression that evaluates to true if the system is running. uptime and downtime are the channels I described.

Link to comment
Share on other sites

Thanks very much for your reply, point 2 and 3 work great.

I still am a little confused regarding the counter, if I read the documentation and look at the quick mod application I see that the counter on my DAQ unit sits on Channel 10 (Digital Input 5)

The unit is set up as a Modbus TCP over Ethernet device

Reading through the Modbus part of the documentation it says to Start the counter its address is 00053 - Start(1)/Stop(0) - To clear the counter is Address 00054 - Clear counter (1). As I am new to this, what command should I send to the unit to achieve either of these instructions??

I have currently set up a test channel and at each change if shift recording the counter figure and then mathmatically taking this figure from the count as the next shift starts manufacture.

I have my unit linked up to a test unit and am happily recording data, I have set up the following channels as test channels D to A with 1 history/1 Persit as per your previous message.

I am using the figures recorded to report the accumulating time and formatting this number using the following:

formatdatetime("%H:%M:%S", SysTime() - (Shift * 3600))

Where Shift is a test channel where I am setting the start of the shift hour as per your previous message i.e. 6/14/22

If I wanted to calculate how many parts I should have made ie if my run time equalled 5 hours and I made at the rate 0f 10 per minute it would be 300 minutes x 10 parts = 3000 parts.

When I try this I have for example a running time of approx. 1271653526 ?

My next query is I have a graph which shows my accumulating part count over time, is it possible to do the following:

Set the bottom Axes to start from the shift start time and the automaticall extend to the current time?

I am also interested in reporting OEE (Overall Equipment Effectivness), I have not found any threads relating to this on the forum, is there and samples available that may cover this?

I have three sites located in three different areas of the UK, each site is connected via the internet and I am able to ping my DAQ device from each of the sites.

When I roll out my Data Aquisition programme I would like to cover all three sites and be able to offer to the ability to review all sites through one system.

Do some rough calculations I have the following requirements in each site:

Site 1 - 300 channels

Site 2 - 100 channels

Site 3 - 200 channels

Would I need to put a seperate run time version of DAQ at each site and then collect data from these three versions into a central runtime to enable a central view to be taken of all sites. Can DAQ Factory handle that many channels

Is there an idiots guide to setting up a network based on the above brief outline?

Once again many thanks for your assistance so far.


Link to comment
Share on other sites

Counter clearing:

You'll have to check the manual. I don't know if those addresses are coils or holding registers. You'll want to set the appropriate one to the value specified (1 or 0)

Running time:

1271653526 sounds like a total time, not a delta Time. There is an error somewhere in your calcs. Probably a 0 somewhere.

Graph scaling:

change the ScaleFrom to the variable with the shift start time. Change the scaleTo to systime()

Remote monitoring:

The easiest and best solution is to actually use DAQConnect ( However, you can do it with multiple copies of DAQFactory provided you have static IP's on the remote sites. There are, however, security issues with exposing those systems, thus the reasons I recommend DAQConnect instead.

Link to comment
Share on other sites

Thanks again for the information.

I have managed to reset the counter using the following command, I will post it below as someone else may find this information helpful:

device.mydevice.ForceCoil(moduleID,holding register number,1)

I am now recording all 12 channels of my DAQ unit and about 12 channels set up as test which record running/downtime etc. I have sorted out me graphs, gauges etc, I am now looking to move forward to the next step which is logging information and alarms.


I currently run a system which is controlled via a Access 2003 database linked to a GPRS Modem. This is currently used to receive inbound SMS messages sent via production controllers and it lists the available engineers. Once a message is received the system allocates each job in order to the next available engineer.

I have a test panel linked to my DAQ unit with a push button that is linked to a digital input on my DAQ unit:

In the event that this is pressed and the input activated I would like to post a set of information to the pending jobs table in the access database.

The information I need to post is as follows with an example in {}:

A Default Telephone number {+4412121211212}

Work Centre Code {6000}

Processing Code {B}

A Message {Any Text Suitable}

Processed Flag {0}

Date/Time {20/04/2010 17:45:00}

I currently have none of the above stored in channels in DAQ Factory, how would I achieve this and how would I ensure that it is only sent once (The Channel timing is set to 1 second)?

With regard to logging data, I have set up a logging set and added all my channels. I would ideally like all channels to be logged once a second with the date/time followed by each of the readings (I am logging to an access database table). The way I have set this up logs date/time then the channel status followed by the next channel.

Can I achieve one date and all of channels in one log?

Your earlier post in response to resetting events at 3 specific times during the day which is as follows:

private lasttime = formatdatetime("%H",systime())


if (formatdatetime("%H",systime()) != lasttime)

lasttime = formatdatetime("%H",systime())

if ((lasttime == 06) || (lasttime == 14) || (lasttime == 22))

Shift = lasttime,53,1)

Y303DT = 0

Y303BD = 0

Y303RT = 0

Y303MT = 0

Y303QT = 0





I had to remove the "" from the hours in the second IF statement as I was getting an error message relating to a string

Removing the brackets works for all but 6 am, this sequence fires every second unit 7am. In the sequence above I have added a leading zero to the 6 to see if this makes any difference, can you indicate if I have anything wrong in the sequence?

Apoligies for the length of post but I have tried to provide as much information as possible, once again many thanks for your quick response to my questions this makes my evaluation of your product so much easier.



Link to comment
Share on other sites


use a channel event. To find the edge (i.e. when channel goes from 0 to 1):

if (mychannel[0] && !mychannel[1])

// do whatever


I'd then use the db.execute() function and the appropriate SQL statement to write to your database. This will give you total control over what gets into the database.


Not sure what you are asking. Logging sets should put everything on one line if the time stamps are the sign. You might try using snapshot mode.

Earlier post:

sorry, typo on my part. lasttime should be declared as a string:

private string lasttime = formatdatetime("%H",systime())

then leave everything else the same, except maybe changing the "6" to "06".

Link to comment
Share on other sites

Thanks for response

The Channel event has done the trick and works great

The shift change works great to with the "06"

I managed to get logging working, was my mistake not reading the help text correctly!!!

My last task to carry out relates to 3D Graph's with a particular view to creating a water fall chart.

I have the following channels which when healthy record a 1 and when activated record a 0:


Y303DI0 - Machine Running

Y303DI3 - The operator has selected a button to trigger a Breakdown request

Y303DI4 - The operated has selected a button to stop processing for Quality Control reasons

Y303DI4 - The operator has selected a button to stop processing for Material shortages

Y303DI8 - Sensor to signal raw material has run out

Y303DI6 - Sensor to signal that the filler infeed has run out of cans

Y303DI7 - Sensor to signal that the filler outfeed is blocked

Y303DI9 - Sensor to signal the end of line packed is stopped

Y303DI1 - Signal to say the emergancy circuit on the work centre has been activated

I have all of the above channels set with a history of 28800 and a timing of 1 second.

What steps do I need to create a waterfall graph, I have attached a sample of the graph for information. I cannot seem to find any details either on the forum or on the help system to give instruction on this.

Do you have a sample application which uses a waterfall graph so it would be possible to see this in action and understand the workings.

I have a couple of graph sample jpg's which is what ideally I would like to recreate, hope you can help.

Many thanks




Link to comment
Share on other sites

Those aren't really waterfall graphs. Waterfall graphs are for 3 dimensional data. To create what you describe you probably need to create a channel for each color, filling it with 1 or 0 depending on whether you want it active or not. Then create a regular trend graph, using all three channels as separate traces and set the axis plotting type as Area.

Link to comment
Share on other sites

  • 1 year later...

Guru, I'm using an adaptation of this solution as well:

global strLastError
global gUptime
global gDowntime
private lasttime = systime()
private thistime
	  thistime = systime()
		 gUptime = uptime[0] + thistime - lasttime
		 gDowntime = downtime[0] + thistime - lasttime
	  lasttime = thistime

Today, I'm getting a strange result from my existing uptime Variable Value Component which outputs the result. Its command is:

FormatDateTime("%H:%M:%S", gUptime)

The results in the Watch Window for both globals are slowly incrementing numbers, (example = 2.001260757446) which alternate incrementing with the gSysProcessing variable going from true to false, as I would expect them to. But what the heck has happened to my clock? I'm expecting hrs mins secs, i.e. 00:00:00, instead, now I get a frozen 00:00:02. The formatting is all screwy.

I checked systime() and it reads correctly, example 16:34:05, incrementing as it should.

Please help me figure this one out.


Link to comment
Share on other sites

If gUptime is 2.00126 then that's only 2 seconds, so the format will display 00:00:02.

Simplify the problem and have the variable control just display gUptime. You can simply comment out the existing if you want:

gUptime // FormatDateTime("%H:%M:%S", gUptime)

Link to comment
Share on other sites


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