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

Resetting Counters

reset counter u3 matlab

  • Please log in to reply
5 replies to this topic

#1 unknownsector

unknownsector
  • Members
  • 12 posts

Posted 25 April 2014 - 10:24 AM

Hi, I've run into a problem where my requests to reset the counters is not working.

 

My setup is reading streaming input from 2 counters in MatLab.

 

This is the code that I used when I wanted to stop the stream and reset the counters, the stream stopped but the counters still retained their previous values.

ljudObj.eGet(ljhandle, LabJack.LabJackUD.IO.STOP_STREAM, chanObj, 0, 0);
ljudObj.ePut(ljhandle, LabJack.LabJackUD.IO.PUT_COUNTER_RESET, 0, 1, 0);
ljudObj.ePut(ljhandle, LabJack.LabJackUD.IO.PUT_COUNTER_RESET, 1, 1, 0)

 

Then I tried just re-enabling the counters instead, and this worked:

ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_COUNTER_ENABLE, 0, 1, 0, 0);
ljudObj.AddRequest(ljhandle, LabJack.LabJackUD.IO.PUT_COUNTER_ENABLE, 1, 1, 0, 0);
ljudObj.GoOne(ljhandle);

 

 

What am I doing wrong with the reset method?



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 25 April 2014 - 10:59 AM

After the ePut reset, where do you read the value?  If you do multiple reads, does just the first return the old value and then further read return 0?



#3 unknownsector

unknownsector
  • Members
  • 12 posts

Posted 25 April 2014 - 11:01 AM

As soon as I made this thread, I realized that was my mistake. After reading a value, the reset worked fine. I feel like a fool. Please feel free to delete this thread.



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 25 April 2014 - 11:05 AM

You are not a fool.  There are some details in how counter reset works.  Are you using a U3, U6, or UE9?



#5 unknownsector

unknownsector
  • Members
  • 12 posts

Posted 25 April 2014 - 11:32 AM

I'm using a U3.



#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 25 April 2014 - 01:36 PM

When you do ePut => PUT_COUNTER_RESET, nothing is actually sent to the device.  Rather, the first time after that where you do a GET_COUNTER, the command is actually sent to the U3 that does the read & reset (in that order).  Then the next GET_COUNTER after that would return 0.





Also tagged with one or more of these keywords: reset, counter, u3, matlab

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users