Run time recording


Recommended Posts

Hi,

I'm a new user to DAQFactory, just a poor electrician with very basic programming skills. So please make allowences for me :)

I have a Labjack U3 with DAQFactory Express. I have set this up to record reducing weight of ink verses metres of material run through a print press, to give average coverage. This part seems to work ok, what I would like to know is, how to get a display and log of machine run time, ie I want to record how long the machine is actually running. I will use a spare contact on the run contactor to switch a digital input. I have tried playing with various settings but none give me the result I'm looking for.

I found another topic in this forum from a German guy with a similar request but I couldn't get it to work.

Hope you can help.

Link to comment
Share on other sites

Machine runtime can be a little tricky because its only really accurate if DAQFactory is running whenever the

machine is running.  There are two methods you can do this within DAQFactory.  The first is to look at when the digital input changes state (to off) and add the difference from when it turned on.  This doesn't work nearly as well as the second method, which is to accumulate with each read when the digital is on.  First, you'll need a variable to store the total.  Create a global variable in an autostart sequence and init it to 0:

[code]global timeon = 0

Then, in the event for the digital input channel (which I'll assume you called "power") put:

if (power[0] == 1)
   timeon += power.time[0] - power.time[1]
endif

That is actually all you need to calculate the machine time. Of course this will reset to 0 when you restart DAQFactory. You could get around this by using a registry variable, but you'll need to multiply by 10 or 100 if you want better than 1 second precision. I'd probably just change the event to this:

if (power[0] == 1)
   timeon += power.time[0] - power.time[1]
   registry.timeon = timeon * 10
endif

and the autostart variable initialization to:

global timeon = registry.timeon / 10

The reason for using two variables is that the global variable will have microsecond precision. You may not need it, but since we are adding values with every reading, you can accumulate large errors if your tally is not precise.

Registry variables aren't exactly the fastest to write, so I wouldn't set the Timing on my power digital channel to anything less than 1.

Link to comment
Share on other sites

Archived

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