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.


Quadrature Triggered Analog Read

Quadrature Analog In

  • Please log in to reply
7 replies to this topic

#1 ChrisL

  • Members
  • 4 posts

Posted 09 July 2014 - 05:10 PM



In my application I monitor a quarature encoder and trigger an analog read at certain count values.  I seem to be losing encoder counts while the analog read takes place.  If I reduce the A/D Settling Factor from 8 to 1 the problem is improved but not fixed.


More specifically, I am using a surface encoder on a larger, rotating drum and I am taking 36 measurements per drum revolution and continuing this for five revolutions.  As the code runs now, it takes a little more than one revolution to complete each group of 36 measurements so I precess a little on each measurement group.  As I mentioned above reducing the settling factor improves performance.  Commenting out the analog read section of the code fixes the problem and there is no precession. 


Here is the measurement loop.  If I comment out the section in red there is no precession.  So it appears the quadrature counter stops while the analog read takes place.


trigcnt is a vector of trigger points.  For example if the encoder produced 3600 counts per drum revolution and I wanted to make 36 measurements around the drum trigcnt would equal [100, 200, 300, . . .2600]


I am using a Labjack U6 and it is up to date.


    for j in range(0, num_revs):
        for i in range(0,num_pts):
            while count <= trigcnt[i]:
                count1 = u6d.getFeedback( u6.Timer0( UpdateReset = False, Value = 0 ) )
                count = count1[0]
                if count > 2**31:
                    count = 2**32 - count
                count = abs(count)
                # endWhile
            if i == num_pts-1: #reset counter each rev
                count1 = u6d.getFeedback( u6.Timer0( UpdateReset = 1, Value = 0 ) ) #Reset Counter
            ADC_val = u6d.getFeedback( u6.AIN24(0, ResolutionIndex = 7,
                                    GainIndex = 0, SettlingFactor = 1,
                                    Differential = True ) )
            temp_ADC = u6d.binaryToCalibratedAnalogVoltage(0, ADC_val[0])
            run_out[i][j] = 20*(temp_ADC)
            count_tab[i][j] = count

            print "Rev. ", j+1, "Measurement ", i+1, " is ", run_out[i][j], "um", "at", count

        count = 0


#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 09 July 2014 - 11:01 PM

Please try the new firmware 1.41. It will prioritize counter/timer operations over AIN to reduce missed counts. There may be a small AIN performance reduction and some slight variability added to AIN timing.



#3 ChrisL

  • Members
  • 4 posts

Posted 10 July 2014 - 07:20 AM

Thanks for the quick reply!  I upgraded to Firmware 1.41.  The download and upgrade were successful, but appear not to be fully functional.  After the upgrade, my SW could not communicate with the U6 so I connected to the Labjack with LJ Control Panel (2.32) and received the following errors in the Test Panel:


Main IO GoOne error: Communications Failure

Main TC GoOne error: Communications Failure

DAC Go error: Communications Failure


My HW version is 2.00, Bootloader is 6.150, Serial Number 360009761 and I am running Windows 7.


I reverted to  Firmware 1.39 and the errors went away and I am able to communicate with the U6 from my SW.

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 10 July 2014 - 11:08 AM

Sorry about that. The U6 firmware is undergoing changes to make it compatible with LJM. There must be a switch missing somewhere. I'll let you know as soon as I find it.

#5 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 14 July 2014 - 11:37 PM

I did some testing on this today and 1.41 is working well for me.


*What is your driver version? (Shown in control panel when you first open it)


*Try updating to 1.41 then power cycling the U6 before attempting to communicate with your device.

#6 ChrisL

  • Members
  • 4 posts

Posted 15 July 2014 - 05:18 AM

My driver is 3.43.  I'll have an update on the power cycle later in the day.

#7 ChrisL

  • Members
  • 4 posts

Posted 19 July 2014 - 08:09 AM

Power cycle after programing did not help.  Still has the above mentioned communication failures with 1.41.

#8 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 21 July 2014 - 03:59 AM

OK, good news and bad news. Good news is firmware 1.42 should not completely fail on you. Bad news is some of the interrupt blocks I removed to improve your quadrature readings were necessary. I added back in the critical ones which are ~4.2 us long each. Hopefully the short blocks won't cause count issues.


A couple other solutions to this issue:

1) Stop the system so that no pulses are being generated while measuring AINs.

2) Move the system very slowly and avoid direction changes (or vibration) during AIN measurement.

3) Upgrade to a T7. The T7 has a faster processor with more hardware acceleration so it does not have this limitation.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users