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.


PWM measure with Labjak U6

  • Please log in to reply
4 replies to this topic

#1 user1979

  • Members
  • 62 posts

Posted 23 February 2015 - 06:14 AM



I am reading a 1 kHz pwm signal using a Labjack U6 and the labview "U6 PWM16 and Duty Cycle.vi" example. I would like to calculate the impact of the accuracy of the measure on my final data. I was simply going to calculate the time between to samples : 1/48000000 since, as far as I know, the clock frequency is 48 MHz. But when looking at the program 48000000 is first divided by 18. Could you tell me why so that I understand the reason for this?


Could you also confirm that the default settings in the Vi are the best ones to make the most accurate measure of a 1 kHz pwm signal using the Labjack U6? There is no other way to make a more accurate measure (for my futur projects) ? 


By the way, I would like to avoid spending time sending a PWM signal output on pin FIOO as in the example's program. I am not quite sure how to do this? I have tried deleating several things but then the PWM measurement doens't work anymore.


Thank you very much for your help,


Best regards.






#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 23 February 2015 - 04:50 PM

What do you want to measure about the input signal?  Duty cycle (high-time and low-time)?  If so, then using the Duty Cycle Measurement Mode 4 is the best option.


If you use the 48MHz clock with a divisor=1, then your resolution is the best ... 20.83 ns per clock tick.  So why would you use a divisor>1?  The reason is that the values for the high-time and low-time are only 16-bit values, so can only vary from 0 to 65535.  If you use a 48MHz clock, then 65535 clock ticks is 1365us.  In your case that would be fine, because you know the high-time + low-time = 1000us, so neither can be greater than 1000us.


See the 3rd paragraph here:





To modify the example you should have a feel for how the UD library interacts with timers & counters:




... but even more important, you should understand eTCConfig and eTCValues:




If you still can't get the VI modified as desired, take a screenshot (Alt-PrintScreen) and post it here, and let us know what it is not doing right.


If you don't need Timer0, I suggest you leave the PWM16 in there.  It does not take any time or use any resources, and is useful if you need to remove your signal and connect something known to test the duty-cycle input.

#3 user1979

  • Members
  • 62 posts

Posted 20 April 2015 - 01:58 AM



Thanks for your detailed and very clear answer. I haven't had much time since I posted my question but I have run some quick tests with your solution : divisor set to 1 since I am not recording for long. Adn it works fine. Could you confirm  that the 1365us resolution is infact the accuracy of the measure ?


Best regards,



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 20 April 2015 - 10:43 AM

No, 1365us is not the accuracy:


1365us => Maximum period of the signal you are measuring.  In other words, the frequency of the signal must be 733 Hz or higher.


20.8ns => Resolution.  Each clock tick is this much, so this is your resolution or precision.


30ppm => Accuracy.  This is the accuracy of the clock at room temperature from Appendix A.




... also see the following about the difference between resolution and accuracy:



#5 user1979

  • Members
  • 62 posts

Posted 21 April 2015 - 01:36 AM

Thanks for the explanation. I have made a quick calculation : if I am measuring a 30% duty cycle signal I should be getting a value between 29.99874% and 30.00126 %, which is accurate enough of course, by far.


29.99874% = [High time (+)  /  [ High time (+) + Low time (+) ]] *100


With :

High time (+)    =  High time measured by Labjack unit + 30 ppm           worse measurment possible

Low time (+)     =  Low time measured by Labjack unit + 30 ppm           worse measurment possible

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users