More counts than should be


Recommended Posts


I have 5 flow sensors that provide a pulsed signal via a reed type switch. Each sensor feeds a hardware debounce circuit then to a multiplexer which feeds one U3 counter input. I'm using CIO0 - 2 as the address lines and CIO3 as the enable line to the multiplexer.

When I use the LJ control panel and force the CIO lines, scoping the counter input shows a clean square wave with a duty cycle of about 84%. Frequencies range from 7 Hz to 18 Hz. Given the circuits the flow sensors are in, this is what I would expect.

My script is just to cycle through each flow sensor and check for proper flow count. Don't need anything fast here and basically is:

Reset counter

Enable counter

Set CIO0 - 2 for address

Set multiplexer output enable ON

Delay 1

Set multiplexer output enable OFF

Get counter value and show in a V channel

Repeat for next sensor

The script works fine but I am getting too many counts for a 1 second delay, about 4 times as many.

Am I doing this right or is there a more proper way to perform this?



Link to comment
Share on other sites

I can't say completely, but you'll almost certainly need to post your .ctl doc since there are a lot of details that could be missed. I however, am going to pass this off to LabJack since its likely more hardware related with the mux. I'm also moving this to the LabJack part of our forum.

Link to comment
Share on other sites

My 1 run trial script is as follows:

// resevoir flow sensor

eput (ID1, LJ_ioPUT_COUNTER_RESET, 1, 0, 0, 0) // reset counter 1

ePut (ID1, LJ_ioPUT_DIGITAL_PORT, 16, 0, 3, 0) // set S0, S1, S2 to to 0, 0, 0

ePut (ID1, LJ_ioPUT_COUNTER_ENABLE, 1, 1, 0, 0) // enable counter 1

ePut (ID1, LJ_ioPUT_DIGITAL_BIT, 19, 0, 0, 0) // set enable line low

Delay(1) //accummalate counts

ePut (ID1, LJ_ioPUT_DIGITAL_BIT, 19, 1, 0, 0) // set enable line high

eGet (ID1, LJ_ioGET_COUNTER, 1, @Count_0, 0) //get counter value

ePut (ID1, LJ_ioPUT_COUNTER_ENABLE, 1, 0, 0, 0) //disable counter

private flow_0 = ((Count_0 / 3) * 0.307) //calc LPM (3/8" hose factor)

v.RES_Flow.AddValue(flow_0) //update virtual channel

No matter what the Delay is I get the 4 times the real count should be. Funny thing is if I would set the Delay to about 20 seconds or so and measure the frequency with my Fluke meter I would get the same Hz reading (about 4 times as high).

I'll try the above script suggestion and if that doesn't work I'll switch to timers. I have extra ones now that I can take one timer PWM out, push it through a line driver which can drive several PWM controlled analog voltage sources.

Thanks for the help.

Link to comment
Share on other sites


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