# Quadrature encoder in Labjack U6

**URL:** <https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101>\
**Category:** Support\
**Created:** [September 7, 2021, 2:12pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101 "2021-09-07T14:12:26Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [September 7, 2021, 2:12pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/1 "2021-09-07T14:12:26Z")

</div>

Hi Chris,

One other request that has gotten to be a bit of a high priority for us.  
(I’m sorry if this is a duplicate: I thought I had sent this to you around July 17th but I can’t find any record of that, so I’m resending.)

We would like to use the quadrature encoder mode of the labjack counter. Is this something you could easily add for us?  
Ideally, we’d have a counter on FIO4/FIO5 configured to count up and down in quadrature input mode.

Thanks,  
Mark

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [September 7, 2021, 2:16pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/2 "2021-09-07T14:16:47Z")

</div>

Hi Mark,

Yes, I could add that. Lindsey’s version of the U6 plugin uses quadrature input (which I believe I added, although my memory is hazy), so it should be straightforward to add it to yours, too. How soon do you need it?

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [September 7, 2021, 2:31pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/3 "2021-09-07T14:31:42Z")

</div>

Hi Chris,  
Thanks!

This quadrature input feature is the highest priority item for us right  
now. Not an emergency, but Josh is waiting on it to try some experimental  
things.

Mark

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [September 13, 2021, 7:32pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/4 "2021-09-13T19:32:08Z")

</div>

Hi Mark,

I’m working on this now. Quick question:

> Ideally, we’d have a counter on FIO4/FIO5 configured to count up and down in quadrature input mode.

Currently, FIO4/FIO5 are used for lever2 and lever2\_solenoid. Are you saying you want me to remove those and replace them with the quadrature input?

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [September 13, 2021, 7:39pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/5 "2021-09-13T19:39:35Z")

</div>

Yes. That would be fine. Thanks. Mark

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [September 15, 2021, 12:26pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/6 "2021-09-15T12:26:04Z")

</div>

Hi Mark,

This is implemented now (code on [this branch](https://github.com/cstawarz/LabJackU6-hist/tree/quadrature)). It seems to work correctly, except that the first quadrature transition is not reported. For example, if the initial state of the input pins is 0/0, transitioning to 1/0 does not result in a reported change to the quadrature value. However, subsequently transitioning to 1/1 causes the quadrature value to increment by 1 as expected, and all subsequent transitions work as well.

It’s possible that there’s a bug in the code somewhere, or that this is somehow expected behavior. However, it also reminds me of the counter issue you reported recently, where MWorks doesn’t receive the first counter update. In any case, I’m going to investigate further. In the meantime, if Josh wants to start testing/using the code as is, that should be fine, as long as he bears this issue in mind.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [September 15, 2021, 2:23pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/7 "2021-09-15T14:23:11Z")

</div>

Excellent, thank you!

And yes, that first tick issue is reminiscent of our counter issue. In the counter case, the counter starts at 0, and the first transition to 1 isn’t reported in MWorks. The next event we see is the transition to 2. So presumably something is keeping track of the transition to 1 that happens, it’s just not getting reported.  
Let us know if we can provide additional information about that or other issues.

Mark

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [September 30, 2021, 5:13pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/8 "2021-09-30T17:13:00Z")

</div>

ps thanks for this - we are testing!  
Let us know if we can help you track down this issue.

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 1, 2021, 1:57pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/9 "2021-10-01T13:57:37Z")

</div>

Hi Mark,

I haven’t made any progress on the first transition issue. Have you seen it, too? My next step is to get in touch with LabJack to see if it’s expected behavior, but I haven’t done that yet.

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 1, 2021, 8:42pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/10 "2021-10-01T20:42:02Z")

</div>

We have seen that transition issue with the counter. It seems to have cropped up in the last year or so, so I don’t think it is a hardware issue. Do you have an old mac you could try it with? I really don’t think it’s a hardware input issue the way the pulses are timed, but we could ask Bradley to measure the input pulses if needed.

thanks!  
Mark

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 4, 2021, 5:59pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/11 "2021-10-04T17:59:37Z")

</div>

Hi Mark,

> We have seen that transition issue with the counter. It seems to have cropped up in the last year or so, so I don’t think it is a hardware issue.

Sorry, I was referring to the first quadrature transition issue, which I [mentioned previously](https://mworks.tenderapp.com/discussions/suggestions/514#comment_49389189). If you’ve tested the quadrature stuff, have you seen that issue, too?

I haven’t observed the missing first counter update in my testing.

Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 4, 2021, 6:37pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/12 "2021-10-04T18:37:47Z")

</div>

> I haven’t observed the missing first counter update in my testing.

Hmm. In a few weeks we’d like you to remote in and take a look, then. I don’t know what could be going on.

Re: the quadrature transition issue, which may or may not be related, we’ll let you know this week if we see it.

thanks,  
Mark

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [October 5, 2021, 2:50pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/13 "2021-10-05T14:50:15Z")

</div>

Hi Mark,

> In a few weeks we’d like you to remote in and take a look, then. I don’t know what could be going on.

OK. In the meantime, if you want to send me an experiment that exhibits the missing-first-counter-update issue, I can try some more to reproduce it on my end.

Thanks,  
Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 19, 2022, 7:01pm UTC](https://mworks.discourse.group/t/quadrature-encoder-in-labjack-u6/101/14 "2022-07-19T19:01:13Z")

</div>

Closed on July 19, 2022, 7:01pm UTC


