Jump to content


Photo

More counts than should be


  • Please log in to reply
3 replies to this topic

#1 RJE

RJE

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • Location:Ontario, Canada

Posted 07 July 2012 - 05:07 PM

Greetings

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?

Thanks

Randy

#2 AzeoTech

AzeoTech

    Guru

  • Administrators
  • PipPipPipPipPip
  • 4666 posts

Posted 08 July 2012 - 09:24 PM

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.

#3 LabJackSupport

LabJackSupport

    Advanced Member

  • Members
  • PipPipPip
  • 252 posts

Posted 09 July 2012 - 10:33 AM

Perhaps the problem is being caused by noise produced my the mux's switching. Here are a couple things to try.
1) Rearrange your code to look like this:
Enable mux
wait 10ms
enable counter
wait 1s
read counter
disable mux

2) Use a timer in counter debounce mode instead of a counter: http://labjack.com/s...s-guide/2.9.1.6

#4 RJE

RJE

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • Location:Ontario, Canada

Posted 09 July 2012 - 03:30 PM

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.