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.


Labjack UE9,Servo Motor,Encoder..Help needed

labjack UE9 servomotor encode

  • Please log in to reply
2 replies to this topic

#1 lan1990

  • Members
  • 2 posts

Posted 29 May 2014 - 03:20 PM


I am not an electronics student so all this very new and overwhelming for me.I badly need help with Labjack UE9 for research where I need to check inputs from a qaudrature encoder and control a servo motor based on the input from the encoder(Pics attached).


I have searched the forums for hours but cannot find any specific tutorials.Really appreciate it if you could point me to the right threads and help me out on how to manually connect the encoder and the servo to the Labjack and control the motor using MATLAB.


Accomplished till now:I have attached the encoder to the F103,F102 and Vs for supply.When I manually twist the shaft of the encoder I can see the values for the counter change in LJControlPanel. I am unaware on how to code/read the values into MATLAB and once a position is reached I want to send a pulse to the servo to rotate for 1min. 




Attached Thumbnails

  • Capture.PNG
  • Capture2.PNG
  • Capture3.PNG

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 29 May 2014 - 03:57 PM

Take a look at the timer/counter example in the MATLAB examples and the UD driver timer/counter pseudocode for help with coding:





You mention using a counter for seeing the pulses from your quadrature encoder, but you may want to use quadrature timers as it shows direction. You can first test this timer mode in LJControlPanel to see if it is more suitable for you, then in code you can configure 2 adjacent pair timers for quadrature mode. Quadrature timer mode is documented here:




Someone will followup shortly regarding the servo control side of your question.

#3 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 29 May 2014 - 04:36 PM

Normally you give a servo pulses with an update rate of 50 Hz or so.  The width of the pulse tells the servo what position to go to, where 1-2 ms corresponds to 0-90 degrees.  Do you have a different kind of servo where some kind of signal controls continuous movement somehow?  According to Wikipedia there is such a thing and the 1-2 ms pulse likely corresponds to 0-MAX speed:




Use a timer in PWM16 mode to create the pulses:




Again, this is something you can try using the test panel in LJControlPanel.  Use the 48MHz clock base with a divisor of 15, which gives you a PWM frequency of 48.83 Hz, which is a period of 20.48 ms.  For a 1-2 ms pulse, you want a low time of 19.48 to 18.48 ms, which is a timer value of 62336 to 59136.


Also, you might be able to use the 5 volt supply from the LabJack (VS) to power the servo, but in general I would not recommend it. We have found the servos draw a big surge current when they move, which can cause the supply voltage to droop and might cause the LabJack to reboot.

2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users