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

Encoder Reading


  • Please log in to reply
2 replies to this topic

#1 nsilva

nsilva
  • Members
  • 10 posts

Posted 19 March 2013 - 04:09 AM

Hi, I'm new using labjack. But I'm doing a project and I will need to read two rotary encoders. But for now I'm focused on one - Encoder HEDL 5540. I have conect channel A and B to FI04 and FI05, respectively. I can read each channel as '0.000' and '1.000'. I use the U3simple.cpp example C++ code for read the channels. I configure FI04 and FI05 as digital inputs. Then to read use the function: AddRequest (lngHandle, LJ_ioGET_DIGITAL_BIT, 4, 0, 0, 0) AddRequest (lngHandle, LJ_ioGET_DIGITAL_BIT, 5, 0, 0, 0) And to get the result I use the getfirstresult function as in the example. Now I'm not understanding how to do the countings as I move the encoder and know position. In each encoder rotation an object is moving forward or backward. I was reading the manual information and I saw that I should use timers for that. But I'm really not undertanding how can I use them. Can you help me understand how to work with those channels? Thanks for the attention. Neuza

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 19 March 2013 - 09:37 AM

The U3 has 2 timers that can be used to do quadrature counting. Search labjack.com using the term "quadrature" for lots of related hits:

http://labjack.com/search

What you want to do is enable 2 timers (Timer0 & Timer1), set the pin offset to 4 so they appear on FIO4 and FIO5, and set the mode of both to quadrature:

http://labjack.com/s...s-guide/2.9.1.8

I suggest you initially try it using the test panel in LJControlPanel.

In the VC6_LJUD archive, check out the example "UE9_Quadrature", which you can very easily adapt for the U3.

#3 nsilva

nsilva
  • Members
  • 10 posts

Posted 20 March 2013 - 03:52 AM

Hey, Thank you very much for the quick and very clear answer. I've follow the suggestiong of adapting the Quadrature example of UE9. Its working with my encoder and labjack. Thanks again. Kind Regards, Neuza


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users