Hello, I'm completely new to the LabJack U3 and I have a very simple first project: I need to count the negative edges on ~5v square waves as pictured in the attached pictures. After scouring the forums I'm not quite sure how to accomplish it. The last (purple) trace in both the attachments are the ones I'm trying to count the negative edges on. This trace is a TTL output from an 'analog' geiger counter, and the negative spikes are particle detection events. I'm looking to count them using the negative (falling) edge of each pulse. Each negative pulse lasts between 10 and 60 microseconds. I understand the U3 can count the negative edges at a 32 bit resolution, but after scouring the forms I'm not really sure how to make it happen in Python. I'm looking to poll the U3 once every 250ms to 1s in order to get count results to the computer, depending on what works best. I'd love any amount of help you can provide! Thanks!
The hardware counters on the U3 happen to count falling edges so you should be in good shape:
https://labjack.com/support/datasheets/u3/hardware-description/timers-co...
Start using the test panel in LJControlPanel to make sure it works there. In the "Timers and Counters" box click Config, then Enable Counter0, set PinOffset=4, and then click okay and you now have Counter0 enabled on FIO4. If it does not seem to count your signal you can instead test by connecting a jumper wire to GND and tapping that inside the FIO4 terminal.
Moving on to Python you should find an example in there that enables and reads a Counter.
Thanks for the reply. There's one minor hitch with LJControlPanel, and that is that I'm on a Linux platform with no access to a Windows machine, and as I understand it the control panel isn't available in Linux. I already have the exodriver and Python libraries installed, though. I also forgot to mention this is a U3-LV so I shouldn't need to worry about the offset from the first 4 'ports'.
Thanks. I should have mentioned that I have a U3-LV and am on a Linux system with the Exodriver and the Python libraries installed, but don't have access to a copy of Windows. My best choice right now is to try to figure out how to at least tell the device to start counting. I'm just not familiar with setting modes up and the relationship between the negative edge counter and the timers, etc.
Take a look at the low-level Feedback documentation for Counter#. It has some examples (also in u3.py and its Python doc) on configuring and reading a hardware counter:
https://labjack.com/support/datasheets/u3/low-level-function-reference/f...
The default TimerCounterPinOffset is 4 (FIO4) and valid values are 4-8.
Sorry about the duplicate comments. I didn't see the first one post and figured it was a glitch. I fogured it out since they were posted using an example on your GitHub. I'm not sure if this conforms to best practices or not but here it is in case someone else wants a rough example to start with:
import u3
import time
import traceback
try:
# Init the U3.
d = u3.U3()
# U3 protocol debug.
#d.debug = True
# Set up our I/O
d.configIO(EnableCounter0 = True, TimerCounterPinOffset = 4, FIOAnalog = 15)
while True:
# Measure for 1 second
time.sleep(1)
# Snag results and reset counter.
x = d.getFeedback(u3.Counter0(Reset = True))
# Get on-the-fly CPS and CPM values.
cps = x[0]
cpm = x[0] * 60
# Dump them.
print("--")
print("%s CPS" %cps)
print("%s CPM" %cpm)
except KeyboardInterrupt:
print("Caught keyboard interrupt. Quitting.")
except:
# If we somehow screw the pooch...
tb = traceback.format_exc()
print("Unhandled exception:\n%s" %tb)
finally:
try:
d.close()
except:
tb = traceback.format_exc()
print("Failed to close LabJack U3:\n%s" %tb)
We approve forum posts before they are public, so there is a delay before they are visible.
Thanks for posting your code. If you need to use your FIO4 line afterwards for non counter operations, make sure to disable the counter when you are done using it:
d.configIO(EnableCounter0 = False)