Linear Encoder, Counting Ticks

To all,
I have the VI created for the linear encoder and everything works fine, except when it comes to counting ticks.  When the encoder moves in the positive direction from initial position, the ticks are counted correctly, but when I move the encoder in the negative direction from the initial position, the encoder immediately reads "4.29E+9".  It continually reads this value moving backwards, and will not accurately measure position until the encoder has been moved an equal distance forward, back to its initial position, then it counts forward correctly.  Any speculation as to why it reads this number?  Any suggestions for fixing?
Thanks,
Owen

Could you please make a trial with an example from NI ?
LV Menu >> Help >> Find Examples... >> Hardware Input and Output >> DAQmx >> Counter Measurements >> Position >> Measure Angular Position.vi
You can easily adapt it for a linear encoder but even the original version will allow you to check your setup. Please read the NI-DAQmx help for the default terminals for your DAQ card.

Similar Messages

  • Encoder Counter Intermittently Set to 0

    I am using Labview on a windows XP box with a 6221 DAQ board connected to a 7330 motion controller via a RTSI bus.  I believe I have everything roughly working, but there is a behavior that I would like to explain before I go live.
    I am sampling an analog input in lock step with a counter that is fed by the encoder signal from the motor.  So I have a series of 2 numbers that I record to file, and the sampling starts at the same time, the sampling is done by the same clock.  This all seems to work.
    If I look at my series of #s regarding the counted ticks that the counter has generated from the linear encoder task that I set up to keep track of the encoder position, I'll get what I expect, but once in awhile there will be a 0 stuck in there.
    For example:
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    0
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    I cannot seem to discern when this happens and when it does not.  My first guess is it has to do with motor speed/acceleration and sampling rate of the DAQmx Create Channel T(AI) I used to sample the analog input which is the same sample clock that is used for the DAQmx Create Channel (CI-Position Linear Encoder), but I have not had this behvior be reproducible based on sampling frequency or motor speed.
    I appreciate any ideas.
    Thanks

    Sorry for the delay, I've been working on other items.
      OK so as I understand it you are trying to control a stepper motor (based on that's what the 7330 does) and you have it in closed loop (which is why you have an analog and digital signals) and are reading back the analog and digital position data. 
    Clarification: I am reading the digital position data from the encoder and analog voltage from a force transducer that will vary over the course of the movement (the force will be all over the place during move)
    Both of which are being read back by the 7330 and then the digital signal from the encoder you are passing via RTSI to the DAQ board and that is where you are reading and recording those values. 
    Further Clarification:  Only the digital encoder signal goes back to 7330 and then is routed over the RTSI. The analog signal goes striaght into the DAQ.
                                Additionally, the digital encoder signal gets routes over RTSI to PFIs 8,10,9 that are counter 0's inputs.  I then set up a DAQmx Create Channel (CI Linear Encoder) event to sample the counter in step with the analog input.
        I guess it would be pretty hard to see if there is a missing pulse looking at the TTL signal on the 7330's user defined digital lines...but what if you wire the siganl directly up to the DAQ board? any change?
    Have not tried, and probably won't (I'll explain why I won't try below)
    and in your example the count goes from 12 to 14 and there is the 0 where 13 should be...is this always the case? does it keep the correct count? and is it always at the same number? 
           The count doesn't skip #s, it just goes 12 12 12 12 0 12 12 12 13 13 13 14 14 14  (I need to check this behavior more, will do that next week)
           Count is correct
           Not at the same #
           -Since there is no # skipping, or I can just interpolate what 0 should be, I'm hesitant to rewire things.
    Also, does the analog signal have anything to do with the digital signal you are sending to the counter (other than that you want them to have the same sample clock)
        The signals have nothing to do with each other at this point because I am just debugging the system with a fake input
    Seeing that I am sampling a counter, all I can think of is that there is a mismatch somewhere in the counter sampling event.  That is to say, the counter value is always at a value, when it gets latched and how many times it is sampled and how many times I read it out might give some mismatch where I think that I have recorded X events, but because of timing, only X-1 samples have made it into the buffer?  Could it be something like that, that would be my only explaination of why a 0 gets in there, because as I said I am sampling a counter.
    Thanks

  • Linear Encoder and Configure Logging

    Hi All,
    I am currently using a PCI-6280 M-series board with LV2010.
    I have a Linear Encoder in X4 mode connected to Counter 0 and I was wondering if it is possible to stream the values on the counter as it keeps track of the distance into a TDMS file using "DAQmx Configure Logging" .  I tried this using MAX to configure this, but it does not seem to work, so I'm just wondering if this is even possible as I couldn't seem to find anything online about doing this.
    Thanks,
    Lester
    Solved!
    Go to Solution.

    Hi Lester,
    My apologies, I tried it out on a different board. It can work with yours, too, though. There is an example of a buffered counter task that should allow you to log the data by adding in the Configure Logging VI like we did before.
    Open LabVIEW and go to Help >> Find Examples... it will open the Example Finder. In the Example Finder, expand the folders to get to Hardware Input and Output >> DAQmx >> Counter Measurements >> Count Digital Events >> Count Digital Events-Buffered-Countinuous-Ext Clk.vi
    Put the correct counter channel and PFI channel in the controls, and run the VI to see what it does. Then you can modify the block diagram to add the Configure Logging VI (the same way as before) and run the VI again. You will end up with a TDMS log saved at the path you wire into the Configure Logging VI.
    I hope that helps.
    Regards,
    Daniel H.
    Customer Education Product Support Engineer
    National Instruments
    Certified LabVIEW Developer

  • Do I have to use an external clock with a cDAQ-9188 and NI 9401 to read a linear encoder? I'm seeing error message that implies that but the example code doesn't show it.

    We can set up a task that works on demand but when we go to continuous sampleing we see Error -200303, which claims an external sample clock source must be specified for this application.  However, some of the NI linear encoder example code doesn't show that (uses the cDAQ 80 Mhz clock) and the documentation didn't mention that. 

    It's mentioned in the 918x user manual:
    Unlike analog input, analog output, digital input, and digital output, the cDAQ chassis counters do not have the ability to divide down a timebase to produce an internal counter sample clock.  For sample clocked operations, an external signal must be provided to supply a clock source.  The source can be any of the following signals:
    AI Sample Clock
    AI Start Trigger
    AI Reference Trigger
    AO Sample Clock
    DI Sample Clock
    DI Start Trigger
    DO Sample Clock
    CTR n Internal Output
    Freq Out
    PFI
    Change Detection Event
    Analog Comparison Event
    Assuming you have at least one available counter (there are 4 on the backplane), I would suggest to configure a continuous counter output task and use its internal output as the sample clock.  Specify the internal counter using an "_" for example "cDAQ1/_ctr0".  The terminal to use for the sample clock source would be for example "/cDAQ1/Ctr0InternalOutput".
    Which example uses the 80 MHz timebase as a sample clock?  It is far too fast for a sample clock on the 9188 according to the throughput benchmarks (80 MHz * 4 byte samples = 320 MB/s).  There is also no direct route between the 80 MHz timebase and the sample clock terminal for the counters--making this route would use a second counter anyway.
    Best Regards,
    John Passiak

  • How do you convert the encoder counts to RMP of the motor using a myRIO in LabVIEW?

    My intent is to gain hardware interfacing and general Labview experience. I am using a myRIO to control a Pittman 8222 34V Brushed DC motor (Motor Specs).
    I recently created a code to control the angle of this motor using PID, which was visually implemented using the black disc with a white tick mark on it (see attached picture: "IMG_2523"). 
    I now want to control the speed of this motor againg using PID, but I am not sure how to properly convert the encoder counts to RPM of this motor. I have attached 2 screen shots of my block diagram and my front panel for reference ("Capture" and "Capture2"). In the front panel picture, you can see my "actual" speed of the motor is a very choppy signal when it should theoretically be a flat line. To get the RPM, I currently use a shift register to store the current count value (which I converted to deg, then to radians), and then subtract the previous run's value, then divide by the while loop sampling time (10 ms). This would give me rad/s, which I then wrote a subVI to convert it to rpm. 
    Any help would be greatly appreciated, thanks. 

    Hi,
    One thing you could try doing is verifying that the conversion from rad/s to rpm is working correctly. 
    This tutorial might also be helpful. It's not using the same hardware that you are, but goes through the general steps using PID control. 
    CompactRIO Motor Control Basics Tutorial: http://www.ni.com/pdf/labview/us/compactrio_motor_control_basics.pdf
     

  • Can PCI-6601 pulse signal over RTSI every Nth encoder count?

    Hi All,
    I have a PCI-6601 counter/timer connected to a quadrature angular encoder.   The 6601 is also connected to a PCI-1422 frame grabber with a RTSI cable.
    I want to be able to trigger the frame grabber by sending a pulse over the RTSI cable every N encoder counts (or X degrees).
    How would I go about do this using C++?
    Thanks in advance,
    Brad 

    Hi Brad,
              There are a few resources I think you may find helpful.  First, there's this DevZone article, " Generate and output pulse every no count an encoder traverses".  Generally, the way this would work is:
    If you want to output a pulse every 4 counts, you will need to take the
    total count size of the counter (2^32 bits) and subtract 4 from this.
    This will be the initial count to set, so that after 4 counts, the
    counter will reach Terminal Count and the Counter Output Event pulse
    will be fired. You can then export the Counter Output Event to a PFI
    line, and use this line as the Z index terminal. If you set the Z index
    value to be equal to the initial count, the counter will always reset
    to 4 ticks below the Terminal Count, and will output a pulse on every
    4th tick. The only drawback to this method is that it will require that
    only X1 decoding be used, and that the counter would have to be
    dedicated to sending out the Counter Output Event (if you want to
    actually count the encoder and keep track of position, another counter
    will have to be used).
    As for specifically doing this in C++, I would recommend referencing the DAQmx C Reference Help (Start»All Programs»National Instruments»NI-DAQ»Text Based Code Support»DAQmx C Reference Help).  Hope that helps, for more assistance on the frame grabber portion of your question, I would reference the post you put in the vision forum.  Have a great day! 
    aNItaB
    Applications Engineer
    National Instruments
    Digital Multimeters

  • What is error 200284 with counting ticks?

    Hi,
    I am trying to write a VI that will count ticks of a rotating encoder wheel. I was able to run the test panel in MAX and count total ticks during rotation with no problem.
    Next, I tried writing a VI that would do the same, but, I am getting errors that I do not understand, especially,  " 200284, Some or all of the samples requested have not yet been acquired."  It also tells me to supply an external clock...how do you do that, and how do you know which external clock is the correct one?  I tried many clock options, but, continue to get this error...
    Ultimately, I would like to have a VI that counts ticks per unit time, e.g. ticks/100ms etc.  For now, I am trying just to get it to count total ticks, and I am stuck here.  Really stuck.
    I am using cDAQ 9174 and NI 9401.
    Thanks!!!  Please help!!!
    Dave
    Attachments:
    forum_april_11.vi ‏21 KB

    Hi dav2010,
    An explanation of error -200284 can be found here. Furthermore, I would recommend starting from a shipping example, when developing your counter measurement task. Lastly, the NI cDAQ-917x User Manual contains information about the various counter input applications, starting on page 5-3.
    The default sample mode for the DAQmx Timing.vi is Finite. The sample clock for the counter task(s) may be set to Continuous but if the sample clock is not set to Continuous it is set to the default value (Finite). When the sample clock is set to finite without the samples per channel wired, it will set a default buffer size based on the rate. Once the buffer is full the sample clock stops and the counter task stops latching the counts because the clock source has stopped. The counter task(s) which are set to continuous will continue expecting more clock edges but will timeout giving error 200284 when it doesn't receive any more. Setting the sample clock source to Continuous will allow the clock to continue providing clock edges for the buffered counting task(s).
    Tunde S.
    Applications Engineer
    National Instruments

  • How do I adapt this example to count ticks/unit time?

    I found the attached example in Labview 2012, for counting ticks of an encoder wheel.  I can easily count ticks with this vi and my encoder wheel hardware.
    I would like to be able to count ticks in a fixed time interval, and return a value of ticks/ms etc.  I would like to do this over and over again in WHILE loop structure.
    How do I modify this example to count only for a fixed time interval, e.g. 50ms, output the number of counts, and then start over from zero again?
    Alternatively, I could fix the number of ticks, and measure the time that it takes to count, e.g. count to 100 ticks, and tell me the time it took to get to 100 ticks.  Either way is acceptable for my application.  Both give me "ticks/time"
    Can someone suggest an architecture to do this?  I'm a bit stuck on how to start.  I was looking at the timed loop structure, but, I can't figure out how the counter would reset to zero...it seems like it would add counts with successive iterations.
    I am using cDAQ9174 and NI9401 module.
    Thanks,
    Dave
    Attachments:
    Count Digital Events_example.vi ‏23 KB

    Hi Kevin,
    I got the vi working, but, there is one weird aspect of it.  I am seeing these phantom signals.  Here are three samples of data collected varying the averaging period from 50ms to 1000 ms.  The rate the encoder is moving is about 1 revolution/second, not super fast by any means.  Notice that the phantom signals can be very large or very small
    Phantom1 is 1000 ms period.
    Phantom 2 is 100 ms period (it's hard to see on the picture, the actual frequency measurement is about 120Hz, as seen in the Excel file data)  The spike to 450,000HZ makes the rest of the data look like ZERO, but, it is actually similar to the others, since all three were collected at the same motor speed.
    Phantom 3 is at 50 ms period.
    The frequency is about 120 Hz.  This encoder has 120 ticks/revolution, so 120Hz, is one rev/second.
    Is there a filter that can be added to eliminate these signals.  They are positively definitely and for certain, NOT real.  My system is a simple belt driven encoder from a DC motor at fixed speed for all three collections here...the spikes up and down are impossible.
    I also attached my vi, in case you want to see if I ruined anything adding the WRITE TO SPREADSHEET function.  I will post in the next one..apparently there is  a limit of 3 attachments.
    Thanks,
    Dave
    Attachments:
    phantom1_1000ms period.jpg ‏45 KB
    phantom 2_100ms.jpg ‏78 KB
    phantom3_50ms period.jpg ‏75 KB

  • Linear encoder

    Hi All
    I want to record the position(rotation) signal. If there are 1024 pulse per revolution, I want the position signal to increase linearly(1023,1024,1025......). Shall I use Linear encoder or Angular encoder (From DAQmx creat virtual channel).
    I am using NI-9411.
    Thank you!
    Solved!
    Go to Solution.

    Hi lvymerciqq,
    For Devices without Counters:
    Your module, the NI-9411 doesn't have any on board counters, so unfortunately you cannot use counter functions such as the Linear/Angular encoder DAQmx channel VIs. If you're using a Compact RIO, you can make use of Counters for the device via the use of Scan Mode (You can see this in the NI Example Finder). However, if you're using a Compact DAQ then there are no Counters to make use of so we'd have to implement our own methods in order to clock the signals. For now, I'd think that this application would be limited by being software driven (i.e. making the OS check that a rising edge has occured) however I'm going to do some research and see whether or not there are other possibilities that can be explored; however it won't consist of such a simple solution as just dropping down a single polymorphic VI.
    For Devices with Counters:
    You can configure a Counter task to count the number of rising edges recieved from the encoder; therefore this number will increment on every increased rotation of the encoder. You'll have to be careful with respect to this number rolling over, however. This is when you reach the maximum count of your counter task and then it resets back to 0; this changes from device to device as different counters have different resolutions.
    Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

  • Need help for encoder count program !!!!!!!!!

    I am a new labview user.
    And i am trying to complete a project for my course.
    For a quick background on what I am working with, I am using a NI PCI-73566-Axis Stepper/Servo Motion Controller for PCI, NI UMI-7764 Series, NI USB-6009 and a IDEC SC1B Rotary Encoder.
    I am try to design a encoder count program and a new program to convert the encoder signal to RPM.
    But I just don't know where should I start? How can I get the same block diagram like P11 in the attach file?
    Please check more detail from the attach file.
    Attachments:
    P11.jpg ‏127 KB
    P8.jpg ‏149 KB
    P15.jpg ‏141 KB

    Hello,
    The two objects on the block diagram are DAQ Assistants and can be found under Functions»Measurement I/O»NI-DAQmx. From what I can gather, this is acquirign signals that you should have connected to the USB-6009.
    -Zach
    Certified LabVIEW Developer

  • Encoder counts to controller - error

    Hello everyone,
    Could someone please help me with this LabVIEW program? I thought I was near complete with finishing up this project, but have encountered problems while executing the program with hardware. I am under a very close deadline, so any tips or advice is very much appreciated. 
    About the program:
    I have a sub panel that represents an x-y stage where a mouse cursor navigates about. The x-y stage is controlled by two actuators, and a mouse cursor's movement within the subpanel will allow for the actuators to move about.
    There are three different cases (case structure):
    0: Do nothing
    1: Update mouse coordinates (x & y coordinates are displayed in boxes titled "Local Mouse Coord")
    2: Display absolute position (x & y coordinates are displayed in boxes titled "Encoder counts")
    My program currently works so that the mouse coordinates (in pixels) are updated and displayed ONLY when the cursor is within the panel's bounds. I did this by implementing the In Range and Coerce Function.  
    Screenshots of my current sub panel and block diagram are in the attachments below. 
    (Note: Coord to Encoder on the Front Panel is supposed to be at 500 to attain encoder counts) 
    I have two axes where one axis represents x and one axis represents y. These axes are controlled by actuators connected a Newport MM3000 Motion Controller. 
    Once I had my program running and the controller was turned on, the program would only execute partially for Case 2 (encoder counts). 
    Moving the mouse cursor up and down within the subpanel allowed for some movement on the actuator for axis 1 
    Moving the mourse cursor left, right, and diagnol caused an error on the controller called "Bad Command"; there was no movement on the actuator
    Below is a zoomed in version of my Case 2: 
    The front panel and block diagram for "IEEE Write" is below: 
    As you can see in the front panel of IEEE write, 1pa1000 represents a command that will move the actuators to absolute position, where 1 represents the axis number and 1000 represents the absolute position destination (in encoder counts). 
    I know that no one will probably be able to implement this without the hardware. However, if anyone has dealt with similar issues before, could you please lend me a guiding hand?
    I just need to know what I could do to modify my code to elminate the "Bad Command" I am getting from the controller. 
    Many thanks in advance! 
    Attachments:
    Screen Shot 2012-11-08 at 8.12.01 PM.png ‏105 KB
    Screen Shot 2012-11-08 at 8.14.37 PM.png ‏104 KB

    qpt,
    I would definitely recommend contacting the manufacturers of your Newport MM3000 Motion Controller to check and make sure the commands and the command protocol that you are sending the device are compatible with the controller. They might have some more insight as to why you are recieving this error. 
    Regards,
    Leah
    Regards,
    Leah
    National Instruments
    Applications Engineer

  • Does Stop task reset a quadrature encoder counter?

    I am using an M-Series PCI-6280 board, with one of its onboard counters wired as a quadrature encoder.
    1)I start the counter task, take a set of measurements with the counter, and then stop the task.
    2) The encoder which the encoder counter is monitoring continues to output quadrature encoder signals into the PCI board's counter.
    3) I start the task again, and perform another set of measurements.
    Which of the following occurs?
    Upon starting the task again, the counter's previous value was wiped and the measurements taken in (3) start at 0 counts. 
    The counter keeps the value it had before it was stopped and subsequently started, and the measurements in (3) cumulate on top of the measurements taken in (1). 
    The counter keeps the value it had before it was stopped, continues to increment/decrement position in (2) even after the task is stopped, and when the task is started in (3) the counter value is cumulative with the quadrature encoder pulses in (1) and (2). 
    Thanks in advance for the help. 
    Solved!
    Go to Solution.

    Hello acmap,
    In this case The behavior will be the following:
    Upon starting the task again, the counter's previous value was wiped and the measurements taken in (3) start at 0 counts.
    However, you can specify the initial count value of the counter on the Initial Count terminal of the DAQmx Start Task VI, so it doesn't have to start at zero, and you can implement the behavior described in your second option.
    Daniel

  • Can anyone tell me why the count tick cannot be show?

    Hi All
    I am trying to write a code for speed calculation, so first I am trying to familiar with the timer function. However as shown in my test code, I cannot get the result in front panel. Can anyone help me in this, please?
    Attachments:
    test count tick.vi ‏17 KB

    Hi,
    I've saved the file for 7.0.
    You cannot initialise the tick count sub vi.
    Reading the full help :
    Returns the value of the millisecond timer. The base reference time (millisecond zero) is undefined. That is, you cannot convert millisecond timer value to a real-world time or date. Be careful when you use this function in comparisons because the value of the millisecond timer wraps from (2ˆ32)–1 to 0.
    If you want to fake an initialise, then you're simply finding the current tick count (outside the loop) and adding on 1x10E4 every time you use the tick count from then on, so a difference will actually be the difference plus 1x10E4.
    Make sense?
    Alternatively, use the elapsed time express vi in the execution control palette, which can take a start time.
    Thanks
    Sacha Emery
    National Instruments (UK)
    // it takes almost no time to rate an answer
    Attachments:
    test_timer_fixed.vi ‏73 KB

  • Encoder counts wrong after Firmware update to 7.2?

    Hi,
    I recently updated the firmware of my motion controller card 7344 PCI to 7.2.
    Since then a 360degree-rotation in 15degrees-steps seems to miss one 15degree-step. A 360degree-rotation stopps at 345degrees
    I think that maybe the encoder counts wrong or the move function isn't executed one time.
    Has anybody expierienced similar problems or has any hints?
    Thx.
    PS. Does anybody know a way to downgrade the firmware to the version below? It seems that the firmware update causes the problem.

    saimen54,
    Odd behavior.  Is there anyway you could post the code for a simplified version of your program that exhibits this same issue.  I don't think there will be any other way to troubleshoot your issue without taking a look at the code.
    Thanks,
    Lorne Hengst
    Application Engineer
    National Instruments

  • How to read the position in an linear encoder, model AT112 from mitutoyo?

    Hello,
    any one knows how to read the positon in a linear encoder, model AT112 from mitutoyo, that have the signal out in the sinusoidal form?
    thanks

    Hello Hugo,
    In order to help you efficiency, please contact National Instruments (01.48.14.24.24) with the reference number 409230.
    I will personnally help you to connect your linear encoder.
    Regards.

Maybe you are looking for

  • How can I improve updating email on ipad 2?

    I can't figure how I can get emails updated  into my in box more frequently.  Right now my Inbox hasn't been updated in more that 5 hours.  Sometimes when it updates i get one message.  Then at other times I will get 150 many of which are times befor

  • HELP! How do I enforce a required field

    All I do hope someone can help me with this!!! I have a pdf where I require the person before submitting to check a check box to confirm they understand a key statement. the checkbox is called Confirm. I have seen some javascript here http://forums.a

  • Adding new filter column in customised report

    Hi, I want to add a new value to the filter list in one of our customized report. Afther the report is generated in Admin UI, at the top of the report's page, I want that business users can filter the report by giving the value of the filter column a

  • Is "no compatible slice" warning a concern?

    I have a partition on my MBAir that has Snow Leopard (10.6.8) installed. Weekly I run a backup (SuperDuper) of that volume.  Today, the backup completed successfully but, in checking the log, I see the following message near the end of the log: warni

  • Reorder of book from PDF format

    I need to reorder a book that has already been published, but only have a copy in the PDF file format on DVD. how can I get Apple to publish from this disk and format? Thanks Dr A