T7 Pulse counter - Newbie question | LabJack
 

T7 Pulse counter - Newbie question

7 posts / 0 new
Last post
bwilliamson
bwilliamson's picture
T7 Pulse counter - Newbie question

I'm pretty hopeless with programming and am struggling to get my T7 to count incoming pulses from a flow meter. The pulse width is adjustable from 50% duty,0.5ms, up to100ms on the device. I would ultimately like to be able to count pulses on two channels (it's a pair of instruments) and work with the pulse counts in DaqFactory to display total elapsed volumes to the user.

This seems like it would be straightforward but it's had me stumped for hours... =\

Thanks for any help!!

LabJack Support
LabJack Support's picture
Start by testing in the

Start by testing in the Register Matrix in Kipling.  See the "Example" section on the following page:

https://labjack.com/support/datasheets/t7/digital-io/extended-features/i...

If that is a success and you see counts when you tap the GND wire, try with your actual signal to see if it gives counts.  If so, move on to DAQFactory.

As for DAQFactory, we actually got a notification from their forum for a post that looks like it is from you.  AzeoTech is correct in that you are trying to use a UD example but the T7 is an LJM device.  Start on the following page:

https://labjack.com/support/software/examples/ljm/daqfactory

The quickest way to get the counter going in DF is:

1.  Configure in the Register Matrix of Kipling.
2.  Go to the Power-Up Defaults tab in Kipling and save your configuration.
3.  Read the register "DIO0_EF_READ_A" in DAQFactory, per the help on the DF-LJM page linked above and the LJM_Basic.ctl example.

bwilliamson
bwilliamson's picture
OK

OK

I got the counter to work in Kipling easily. Now I'm trying to get that value into DF in a way that it can be used in calculations and displayed... Here's what I've got (which gives me nothing in DF).

Using("device.labjackm")
   LJM_eWriteName(0, "DIO0_EF_ENABLE", 0)
   LJM_eWriteName(0, "DIO0_EF_INDEX", 8)
   LJM_eWriteName(0, "DIO0_EF_ENABLE", 1)
   LJM_eReadName(0, "DIO0_EF_READ_A")

I'd like to put the register commands in DF since we have two T7's and it would be nice to be able to swap them around as needed.

Thanks again for addressing such basic questions!!

LabJack Support
LabJack Support's picture
Your first 3 lines look good

Your first 3 lines look good to configure the counter.  Then you have a 4th line that reads the counter, but:

1.  It does not seem to put the value anywhere.  You would want to do something like CounterRead=LJM_eReadName(0, "DIO0_EF_READ_A").

2.  Then you would want to have a loop or something that causes that read to happen repeatedly.

3.  Then you would want to display CounterRead somewhere.

I'm actually working on updating the LJM_Basic.ctl example.  It now does a counter on FIO0.  The counter is configured in the Configure sequence, and then the counter value is read once per second using a DF Channel defined in the Channel Table View, and then that DF Channel is displayed on Page_0 using a Variable Value Component.

The one thing about this example is if you power cycle the device you will start getting errors because the counter (and other things) is no longer configured.  Same if some other application talks to the T7 and changes the configuration.  We are working on adding the logic to reconfigure when needed, and then will post this on the DF-LJM page, but the current version is attached here. 

File Attachment: 
bwilliamson
bwilliamson's picture
OK

OK

I broke something.

I added a sequence with the following content to the above demo .ctl file:

global CounterRead
  while(1)
   CounterRead=LJM_eReadName(0, "DIO0_EF_READ_A").
   delay(0.1)
   endwhile

And for whatever reason, I had it working and made some changes here and there and now I get the error below when I run it:

: Unable to open LabJack M: LJME_DEVICE_NOT_FOUND: CounterA Line 3 - Uncaught error in sequence CounterA

What have I done?

Thanks

LabJack Support
LabJack Support's picture
Make sure no other software

Make sure no other software is running that might have claimed your T7 connection.  Reboot your computer if nothing obvious (e.g. Kipling) is running.

LabJack Support
LabJack Support's picture
Note that what you are doing

Note that what you are doing is redundant.  In the new example I attached there is already a DF Channel ("FIO0Counter") linked to DIO0_EF_READ_A that is reading is ever 1.0 seconds.  Just change that timing to 0.1 and it will be doing what you want, and you can use that channel name ("FIO0Counter") wherever you want rather than the new CounterRead variable you are trying to define.