how to reset counter values /start logging from input


Recommended Posts

Hello,

I am a beginner with labjack and DaqFactory express

Q1

I have connected a flow counter on the count input of the LabJack U12.

The counting works well.

But I dont know how to reset the counter value on command ( for example a pushbutton)

I work with daqfactory expess

When I try the example program LJCounter i can see that the reset button is working!

On the labjack forum they suggested to note the current value and subtract it from all future values

Maybe azeotech can give me an example

Q2

I like to start logging when an digital input becomes true.

I can not find a way to get it work

Link to comment
Share on other sites

Q1: yes its usually better not to reset the counter unless you expect very rapid counts (and thus a lot of rollover). The problem with resetting the counter is that for a short period during the reset the counter won't count. So, its better to simply reset in software. Here's how you would do it:

1) Create a sequence called StartUp, mark the AutoStart check box and put this script in it:

global CounterOffset = 0

2) Create a new conversion called CounterReset and put this expression:

Value - CounterOffset

3) Go to your counter channel and select the CounterReset conversion for it

4) create a button to reset the counter. Select the Quick Sequence action and put:

CounterOffset = MyCounterChannel[0]

where MyCounterChannel is the name of your counter channel.

That is about it. Use that same last line of script anywhere you want to reset the counter.

Q2: Use the digital input channel's event. I'll assume the channel is DigInput. To get to the event script, click the + next to CHANNELS in the workspace, then click on the DigInput channel listed. Then click on the event tab. To start logging when the input goes high, do:

if (DigInput[0])
   beginlogging(mylogging)
endif

Note that this won't cause the logging to stop if the input goes low.

Link to comment
Share on other sites

Hello,

First the good news : the input channel,s event is working fine ! :)

The bad news is I am receiving an error on the StartUp sequence. :(

The code in this sequence is " global CounterOffset = 0 " ;(just like jou said).

Do I need to make a channel named "CounterOffset"?? ( I tried to bud no result).

The value in MyCounterChannel is the raw data from the labjack ,

maybe we need to create a channel to put the raw countervalue in , so we can make calculations that won,t be overwritten by the lab jack.

Link to comment
Share on other sites

What release of DAQFactory are you using? That line is correct for the newer releases, so I'm thinking an older release. Try var.counteroffset = 0. You'll have to use var.counteroffset everywhere else too if that works. You might consider upgrading as well.

Link to comment
Share on other sites

  • 2 weeks later...

Hello again!

I am using DAQFactory Express Release 5.40 now

The sequence StartUp

global CounterOffset = 0

Is working now <_< when I start the DAQFactory project , i see that the CounterOffset is set to 0

So i can reset the counter.

When i want to reset the counter for the second time the CounterOffset = the old value ,so a wrong value is displayed in MyCounterChannel [0]

It seems like counteroffsset is zeroed bij the Sequence only at startup.

I like to reset the counter several times , can jou help me ??

Link to comment
Share on other sites

In 5.40 of DAQFactory doing a declaration and assignment like you did will only do the assignment once, so:

global counterreset = 0

will only set counterreset to 0 once. You have to do:

global counterreset

counterreset = 0

In releases 5.70 and newer, this has changed.

Link to comment
Share on other sites

  • 9 months later...

I have tried this counter reset with DaqFactoryExpress 5.83.

And it only does a reset of the counter the first time after

startup of the program.

I tried the last comments also, it did no good. After the initial

reset, and after some counts the reset button only toggles between

two values.

In my application I am counting pulses that drive a motor, and it is

not continuously counting. Only during the sequence of the motor

start and stop.

Link to comment
Share on other sites

  • 1 year later...

There is a LabJack command that will actually reset the counter. It is described in section 10.4 of the DAQFactory LabJack Application guide included with DAQFactory, along with the non-hardware reset method. The command is simply:

AddRequest(id, LJ_ioPUT_COUNTER_RESET, 0, 0, 0, 0)

GoOne(id)

where id is the id of your labjack, and the first 0 is the counter to reset. This follows the command as described in the LabJack documentation. Note for these command to work, you'll need to follow the directions in section 8.1 of the same manual.

Link to comment
Share on other sites

  • 5 months later...

Archived

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