Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

LabjackPython Reading Thousands of Counts from Counters


  • Please log in to reply
1 reply to this topic

#1 Strill

Strill
  • Members
  • 27 posts

Posted 14 January 2013 - 02:53 PM

I'm trying to record pulses from a water flow sensor which outputs a 5V pulse for every 10 gallons it measures. It's connected to a house's water supply. The positive lead is hooked to FIO0, and the negative lead is hooked to ground.

This is my relevant section of code for reading from the pulse counter.


d = u6.U6()
d.configIO(EnableCounter0=True)
previousCount=0
f = open("log.txt","w")

while(True):
	
	s, = d.getFeedback(u6.Counter(counter=0, Reset=False))
	s = s - previousCount
	previousCount = s
	if(s != 0):
		f.write(str(s)+"\n")
	time.sleep(10)

I'm currently getting the following results in my output file.

1
1
1
1
1
1
2
1
1
6
1
1
1

Most of the readings appear to be reasonable, but I occasionally get upwards of six pulses from a single 10 time span. This suggests to me that the labjack is measuring multiple pulses when it should only register one. Do you have any idea what might cause this?

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 15 January 2013 - 01:39 PM

Can you provide a link with electrical details for the signal produced by the sensor?

Perhaps there is bounce if the sensor uses a mechanical switch output, or if solid-state perhaps it is noisy or the edges are too slow.

http://labjack.com/s...s-guide/2.8.1.3

How about rather than a counter, use a timer in "Firmware Counter Input With Debounce" mode. To figure out what debounce period to use, we need to know the minimum time you ever expect between 2 pulses.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users