Reading a gas meter switch on U6


Recommended Posts

I have a gas meter with a magnetic switch that closes every time the gas meter passes over the 0 mark aka 1 cubic foot of air.

The graph of this is attached ( ). This is just a test run to see the results from the meter. I currently have it plugged into an analog port to see the output.

I want DAQFactory to record a point on the beginning of the square wave (the upslope).

My co-worker recommended using a counter but as you can see from the graph the time delay between samples is very large and can vary greatly from one day to the next. I'd like to set this up one time for all forseeable instances.

Typically I see about 1CF per 10 minutes. At most I'd see 1 CF per minute. At the least it could be as low as 1 per hour.

Is a counter the best option for this, or should I have something that says If change in value > 5v, add 1 CF? Though to me the latter requires a sequence constantly running, draining resources.

Link to comment
Share on other sites

And further, a Counter happening in hardware will not miss edges. You just read the counter value whenever you want and see if it is bigger than last time you read it.

The U6 Counters count falling edges, so sounds like you actually want to use a Timer configured in Firmware Counter Input mode.

As for simply polling a digital or analog input to see if has changed from low to high, that should work fine also and even polling as fast as possible is minimal resource drain on a modern computer.

Link to comment
Share on other sites

I set it up to count the rising edge using a simple sequence

   If(DGM_V - x_old > 3)  // See if the difference is larger than 3 volts to count rising edge
	  DGM_count = DGM_Count + 1
   x_old=DGM_V  // Set current voltage reading to

It works very well for spotting the rising edge, but I have to manually enter the current Dry Gas Meter current reading whenever I open the software.

Is it possible to have DAQFactory store this value between instances?

Would a counter solve this problem by remembering it's current count? How well do counters respond to noise? As you can see from the graph the steady state conditions is noisy with a sinusoidal voltage pattern. My thought on this is that I'd need a low enough frequency to not be disturbed by these variations. Somewhere around .5-.2Hz?

Can you set a threshold limit on counters? AKA only count when the change in voltage is >3v? Or d they just look for the sharp edge of the waveform with LJ_tmRISINGEDGES16?

Link to comment
Share on other sites

I'll let the LabJack folks respond to the later parts of your post concerning hardware. For the first part, if DGM_Count is a channel, you should rewrite the script as:

if (DGM_V[0] - GSM_V[1] > 3)

Then put this script in the event for the DGM_V channel. Specify a Persist length on the DGM_V channel if you want it to recover after restart. Otherwise you'll get a single error on the first reading.

Link to comment
Share on other sites


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