DAQmx Quadrature Encoder Initial Position

Hello, 
I am building an application that requires trackig the raw counts from a quadrature encoder connected to a NI USB-6212.  In order to count each rising and falling edge of both channel A and channel B, I have configured a DAQmx Linear Encoder Channel for 4X decoding with the units set to ticks.  In order to prevent the counter from rolling over when the ticks become negative, I convert the U32 value from DAQmx Read to I32.  So far this all works as expected.  I would additionaly leik to retain to position of the encoder if the VI is stopped but remains in memory.  For this reason I wire the value of the raw counts to a shift register which is read into the initial position input of the DAQmx Create Channel VI.  For some reason, the DAQmx Create Channel VI quadruples whatever value is wired to the inital position input.  I solve this by deviding the previous counts by 4 before writing to initial position.  However, the problem occours that if the value of the previous count was not an even multiple of 4, the inital position must be rounded to the nearest integer, causing the count to jump when restarting the VI.  How can I reset the inital postition to the exact value of the encoder at the end of the previous iteration?

Yes, It does. In 1X decoding mode, the starting count equal to the supplied initial position, but then I only count 1/4 of the pulses I expect to see.  Perhaps I am misunderstanding the meaning of 'inital position'?

Similar Messages

  • Using a Counter(PC-TIO-10) to Perform Quadrature Encoder Buffered Position Measurement in Visual C++

    I have Driver Ni-Daq 6.9 and Using a Counter to Perform Quadrature Encoder Buffered Position Measurement in Visual C++ 6.0
    (I think Ni-Daq not support PC-TIO-10 because card not support pulg&play, you can hint me driver for support this card. ) and i want example program for read counter. i use Visual C++ for run,i don't use Measurement Studio.

    NI-DAQ 6.9 supports the PC-TIO-10.
    I attached an example that will show you how to do it in CVI (ANSI C).
    Attachments:
    Cviencod.zip ‏19 KB

  • Can I use the 'Export Signal Property Node' on a quadrature encoder?

    Hi,
    So I don't know which counter board I'd be using yet for this (it's used in conjunction with a PCI-6280--the PCI-6280's counter inputs are all taken and so I need another board), but assuming this is possible at all in DAQmx I wouldn't mind knowing whether, say, the PCI-6601 (or any other timer board for that matter) could do this. I'm programming this in LabVIEW 2010 by the way. 
    I want to have a counter which counts the number of pulses on one channel (I'll call this the 'clock' channel) between when another channel goes from low to high (which I'll call the trigger). It's basically a pulse width measurement, but I only care if there are more than n clock pulses between triggers. I need to have a hardware-timed digital signal which goes from low to high if there are ever more than n pulses between trigger changing state from low to high. 
    What I am planning to do is this: 
    Wire 'trigger' to the z-input of the quadrature encoder, and set the z-input value to some arbitrary large value such that, at the quadrature encoder counter task's settings, the counter reaches terminal count in n pulses.
    Configure the quadrature encoder counter using DAQmx Export Signal Property Node (tutorial I was looking at is here: http://zone.ni.com/devzone/cda/tut/p/id/5387 ) to toggle a digital channel ('counter event output') from low to high if the counter reaches terminal count (ie, if the encoder reads n pulses).
    If the encoder ever reads n pulses on 'clock' between two rising pulses on 'trigger', it sets counter event output high.
    Is this possible? Reading through the manual of M series PCI-62xx devices, the index pulse loads the counter with a particular value so it seems like you could conceivably set the counter to the terminal count if you wanted. My only real problem is whether DAQmx Export Signal Property Node works on all counter tasks or just on edge counting tasks. 
    Thanks in advance for your help. If this isn't possible, I can reply with more details on the problem this is supposed to solve so that you can help me figure out an alternate method.
    Solved!
    Go to Solution.

    There is probably a way to do it, but it it may be easier to use an X-series board for the job.   They support a new counter capability for count reset on a digital edge without needing to be configured in encoder position mode.  I am not sure exactly how that feature's been implemented however, so maybe it won't make things easier after all.
    The plan based on the hoped-for behavior: 
    1. Configure an X-series counter for pulse generation based on "ticks" of your clock channel.
    2. Set both initial delay and low time to the critical # of ticks.
    3. Configure for count reset on a digital edge (if possible in pulse generation mode)
    4. Configure the count reset value to be the critical # (or possibly 1 less, if possible in pulse generation mode)
    5. If you want the output to remain high indefinitely, configure the counter task to use its own output as a
    pause trigger, and pause while high.
    The way pulse generation works is to preload a # of "low time" ticks into the count register.  Then every source edge will decrement the count.  When the count reaches terminal count (0), the counter's output is toggled (or can be configured to pulse).  The register is then loaded with the # of "high time" ticks and the process continues.
    You would be perpetually interrupting the count-down process as long as you got your triggers in time.  The count would keep getting reset to the # of low counts, keep decrementing toward 0 without reaching it, and so on.  If ever you did reach 0, the output state would toggle high, then the high state would prevent subsequent clock signals from decrementing the count.
    You can conceivably do a similar thing with a 6601, but I'm pretty sure you'd need 2 counters working together to get it working.
    -Kevin P

  • 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

  • RPM Measurement using Quadrature Encoder and PXI 6602 counter

    Hi,
    I am on a project at work where I need to verify the speed (in RPM) of an unloaded motor which can operate up to 1400 rpm.  After doing some research, i determined that a quadrature encoder could be used to make the measurement.  I am looking at this encoder  http://sine.ni.com/nips/cds/view/p/lang/en/nid/205321.
    I have a PXI 6602 counter/timer module in which I would like to interface to the quadrature encoder.  I would like to create a VI that allows me to calculate the speed using the encoder.  Can someone provide me with details of what needs to be in the VI or an example which can do this?  At the most basic level, i want to calculate the speed on demand.  After doing this, i would like to figure out how to quickly calculate the speed so that i can determine response time of the speed changing within sub-millisecond resolution (1 ms resolution max).
    Further, i created a VI that allows me to change the pulse width of a 100 Hz pulse train at run-time which tells the motor controller the desired speed.  I would like to be able to use this VI to change the speed of the motor and the first VI (that I am seeking help about) to calculate the response time (time between the initial speed and settling at the new setpoint).
    I am familiar with the NI example finder, but have not been able to find an example that I can use.
    Thanks,
    Gary

    Hey Gary,
    I think for you setup, you should try using the Meas Dig Frequency - Low Freq 1 ctr. You can find it by searching example finder with 'low freq'. This vi tells you the frequency of a digital signal by sampling between two pulses and inverting the time between pulses. If you hook up your encoder to a counter and have that counter specified in the vi, it will be able to give you on demand readings of frequency (you can do some multiplication to get the rpm value, freq*60/pulses per revolution of encoder). A simple way to take continuous readings is to put a while loop around the daqmx read and the data output of the read. You can also replace the numeric indicator to a waveform chart to graphically display the change of frequency or rpm readings over time.
    You should be able to integrate this as two separate tasks with the pulse train vi you created earlier.
    Hope this helps
    Luke W

  • Quadrature encoder

    Hi,
    I'm trying to make an position measurment with a quadrature encoder.
    My hardware is a6031E card, and I 'm using DAQmx 7.4.0.
    I read the AN84. So I connected Channel A to Ctrl0_src (PFI8) and
    Channel B to ctrl0_up-down (Port0.6). I used the
    "quad_encoder_with_E-series_(STC)-daqmx.vi".
    It first didn't work : il was counting up and not down or the opposite whether I was couting rising or falling edge.
    Then it worked (I cannot see what I changed, I think I did not change anything but it's impossible).
    And now, it doesn't work anymore. Even when I create a global channel
    and test it in MAX, it counts up good, but when irotate the shaft the
    other sense, it stays at his level and doesn't count down.
    Can somebody telle me where I made a mistake and what I forgot.
    Thanks.

    Merci de me répondre.
    J'avais bien configuré mon compteur en "controllé de manière externe" mais ça ne marchait pas.
    J'ai trouvé la réponse ce matin : mon codeur disposait de sorties
    totem-pole, et je l'alimentait en 12Vdc. J'ai vérifié la doc ce matin,
    et le fabricant garantit un niveau bas maximum de ... 2 Volts. En fait,
    des fois, il descendait en dessous du niveau d'acceptation bas TTL et
    souvent non ! Du coup, avec 2 volts sur mon entrée count up-down, je me
    trouvais souvent dans une sorte d'idle state, puisque mon signal sur
    cette broche était plus haut que le niveau d'acceptation bas TTL et
    plus bas que le niveau d'acceptation haut TTL.
    J'ai changé de compteur pour un avec des sorties TTL directes, et tout marche parfaitemement bien.
    Merci encore de vous être intéressée à mon problème,
    Bonne fin de journée,
    Olivier Quillard

  • Read RPM from Quadrature Encoder

    Hi Everyone,
    I wish to measure the RPM of a shaft using a quadrature encoder and a PCI-6259 card. I've seen a few examples on reading position, which i have managed to get working, but Im not sure on how to get RPM. Any tips or code examples would be greatly appreciated.
    Thanks,
    David

    Hi All-
    Thanks for the suggestion DJ, but your VI will not work as it is written using the Traditional (Legacy) NI-DAQ driver and David's M Series card is only compatible with the NI-DAQmx driver.
    To answer David's question, it is not possible to directly measure position and count edges at the same time.  What you can do is count edges with external Up/Down control (basically the same as a X1 encoder) and then use the edge counting to calculate both frequency and displacement in ticks/degrees/RPM/etc.  I have attached an example I did recently that shows how to use an edge count with external Up/Down control (i.e. PFI10 or PFI11 for M Series ctr0 or ctr1, respectively) provided by the 'B' phase signal and the 'A' phase provided to the counter source.
    Hopefully this helps-
    Tom W
    National Instruments
    Attachments:
    32bit_Cnt_Edges_to_Quad.vi ‏73 KB

  • Measuring distance using quadrature encoder

    I am currently doing a project that requires the positioning and characterization of TV signals. As such, the position of the TV receiver is one  important variable that i have to measure. I am required to automate the measurements and data logging using a PC/notebook. I have purchased a 2-channel HEDS-9000 quadrature encoder with 2000 CPR & the HEDS6120 codewheel - both from Avago Tech, to be interfaced with the notebook/PC. My idea is to get a TTL-to-RS232-to-USB converter to interface with the PC, so that i can feed the output from the encoder to the PC. However, i dun have much idea on how I can use LabView to interface the encoder and the PC. Can anyone offer some valuable advice?
    Btw, the encoder module consists of 5 pins - Vcc, GND, CH.A, CH.B, with one pin not used.
    Thanks !!

    Hi,
    I think one of the best and reliable options that should meet your needs is a bus-powered USB-M-Series device like the USB-6210.
    The USB-6210 is a multifunction data acquisition device with 16 analog inputs, 4 digital inputs, 4 digital outputs and 2 counters. Each of the counters can interface directly to the quadrature encoder signals of your HEDS-9000.
    It's very easy to use this device with the NI-DAQmx API for position measurements in LabVIEW. In fact there are some shipping examples that you can use for getting started.
    I hope this helps,
    Jochen Klier
    National Instruments Germany
    Message Edited by Jochen on 02-09-2007 09:18 AM

  • Quadrature encoder interface to PCI-6229

    Using PCI-6229 with LV7.1.
    I need to connect an incremental quadrature encoder ( A,B and Z )
    signals directly to the card and use the CTR0 to give me the angular
    position information. Encoder is a 2500ppr type.
    As per the specification summary of the PCI-6229 card, this is
    possible. If so which terminals to use ? ( I have also posted  a
    similiar query in the other hardware forum )
    can someone help me out in this ?
    Thanks
    Raghunathan
    Raghunathan
    LV2012 to Automate Hydraulic Test rigs.

    Dear David,
    the search terms that you gave helped a lot also. I could get sample code for checkout of an encoder with LV7.1. Good.
    I am not sur eif you have actually worked with the encoder + LV
    combination. Normally any optical encoder  will produce  high
    frequency jitter if it happens to stop just at the point of transition
    of either the A or B channel . I do suppose that the DAQmx  VI
    will handle this and not produce spurious counts - or do I need to
    configure a filter for the relevant PFI lines ?
    Thanks
    Raghunathan
    Raghunathan
    LV2012 to Automate Hydraulic Test rigs.

  • Speeding up quadrature encoder read out

    Hi,
    I`m using a quadrature encoder together with a 6259 DAQ Card and BNC2110 Terminal Block.
    I managed to have it working with the DAQ-Assistent at 80Mhz using the Counters and reading one value at a time. Before the DAQ-Assistent I used a DAQmx command to connect PFI10 and PFI9 as the BNC2110 Terminal only outputs PFI0-9. This works but it is really slow, the distance between each measurement point is around 6 us. The VI is in the attachement (AquadB_one_value.vi)
    So I thought I might use the n-values version with the DAQ-Assistent but this does not work and I dont see any reason why, it is complaining about that connection between PFI10 and PFI9 which it didnt do before in the one-value-version. The VI is also in the attachement (AquadB_n_values.vi)
    I also tried another method using a VI I was given some time ago and modified it but here the distance between each measurement point is also around 6us. This VI is also in the attachement (Counter - Read Encoder.vi)
    Or am I missunderstanding something? The minimum achievable time distance between measurement points should be 1/80.000.000 s where of course the value can only differ 1/0/-1 because it has only calculated one new change in the A and B Signals right? I thought with using the n-values it is storing all the calculated values in the memory and I am transferring them afterwards for doing all the "post-processing"?
    If I am wrong, how can I spped up the read-out of the calculated values any other way?
    Best regards
    Attachments:
    AquadB_n_values.vi ‏56 KB
    AquadB_one_value.vi ‏49 KB
    Counter - Read Encoder.vi ‏98 KB

    Hi Dani_munich,
    I just realized that you asked the same question in our Service request. In the service request, I was missing out more information which I found them here by chance . I will further assist you in the SRQ you have created. I also sent you an email.
    Regard
    Anoj
    Anoj Mubarak
    National Instruments

  • Programming quadrature encoder

    I'm trying to program a incremental optical encoder with nidaqmx 7.4, with C#, using the PCI-6071e card. I want to measure position, velocity, and acceleration.
    As per the "How Do I Use a Quadrature Encoder with My Data Acquisition Board?" document, channel A of the encoder is connected to ctr0_source, channel B is connected to DIO6, and index is connected to ctr1_source.
    I'm trying to run the the MeasAngularPositionBuffered_Cont_ExtClk example. However, an exception is thrown when calling myTask.CIChannels.CreateAngularEncoderChannel.
    The messagebox says "Selected physical channel does not support the measurement type required by the virtual channel you are creating. Create a channel of measurement type that is supported by the physical channel, or select a physical channel that supports the measurement type"
    Also, there is an option in the example program to enable the Z index. How does that program know which channel to read the index pulse?
    I'm new at data acqusition, so any other hints regarding optical encoders are appreciated.
    Thanks,
    Gerry

    You also may be able to measure position using the "Count Edges" measurement with an external direction control. This may be enough for your purposes. Just bear in mind that quadrature encoders typically give off noisy signals, so you might have to build an external circuit to clean up the input signals. Let me know if you need more information on doing this with your E Series device.
    gus....

  • Troulbe in measuremen​t quadrature encoder with 6601

    Hi,
    Thanks for Ross's help.But I cannot differ 6601's x4 mode from other counter/timer counting mode. In measurement position, what difference between them. And I just want to know whether my application viable.
    We are trying to measure position with 6601. The frequency of quadrature encoder is from 100Hz to 8MHz. Now, we connet the A,B and Z channel directly to counter . Using the example in CVI, we change the filter to 100ns and use x4 mode. It works perfect at low frequency.
    The problem is when the frequency of encoder is higher than 2MHz, the accuracy decreases greatly. I'd like to know about following:
    1.Can 6601 do the previous task enough? Or I must change to use 6602.
    2.If
    6601 is available, is there any way to increase measurement accuracy ?(in software or wire connection )

    >jimmyjimmy2000
    "Hi,
    Thanks for Ross's help.But I cannot differ 6601's x4 mode from other counter/timer counting mode. In measurement position, what difference between them. And I just want to know whether my application viable.
    >>mross>The application is viable. However, the use may be difficult.
    >jimmyjimmy2000
    We are trying to measure position with 6601. The frequency of quadrature encoder is from 100Hz to 8MHz. Now, we connet the A,B and Z channel directly to counter . Using the example in CVI, we change the filter to 100ns and use x4 mode. It works perfect at low frequency.
    The problem is when the frequency of encoder is higher than 2MHz, the accuracy decreases greatly. I'd like to know about following:
    1.Can 6601 do the previous task enough? Or I must change to use 6602.
    >>mross>The 6601 is just as good as the 6602 at 2MHz. Therefore, a 6602 will have the same problem of inaccuracy.
    >jimmyjimmy2000
    2.If 6601 is available, is there any way to increase measurement accuracy ?(in software or wire connection )"
    >>mross>Yes, in the wire connection you can make improvements.
    6601 can count as fast as 20MHz (60MHz with prescaling). The signal is noisy (containing addtional, incorrect information).
    You must use an oscillosope to look at the signal. Look at it when 6601 is counting correctly, and look at it when 6601 is "malfunctioning".
    The counter will increment whenever the signal is high for more than 5 nanoseconds. The conditions for "High" and "Low" signals must be strictly met. If the signal is greater than 0.8V, the counter may increment. The signal must then drop below 2 Volts for a "Low" to be seen.
    This sounds wrong, but is true. The counter is expecting TTL signal conditions (Transistor -Transistor Logic). This specification is very broad.
    A "High" will absolutely be recognised if the signal is greater than 2.0V.
    A "Low" will absolutely be recognised if the signal is less than 0.8 V.
    However, the range from 0.8V to 2.0V is "undefined." This means the counter could increment at 0.8V. It has been my experience that National Instruments TTL will always see 0.8V as a "High." If your noise exceeds 0.8V you will never be able to count accurately.
    The problem will be solved when your encoder signal is read cleanly by the 6601. This is why I gave you the URL for US Digital in the previous answer. The circuits they sell can help to clean up the counter signals. You will have to see what works best, since I don't exactly understnad you application. If the noise is very bad, you may wish to use the Encoder to Binary Number circuit. There will be no noise in the reading of a binary number. Since your encoder may run as fast as 8MHz, you must be sure the circuit you choose is also this fast.
    The other solution is to eliminate the noise which is causing the counter to trigger falsely. THis can be a very interesting problem to solve. Please look a this NI link:
    Field Wiring and Noise Considerations for Analog Signalsv
    http://zone.ni.com/devzone/conceptd.nsf/webmain/01​F147E156A1BE15862568650057DF15?opendocument
    Follow these instructions very carefully.
    Also, this book is helpful to explain noise and how one may reduce it.
    From Amazon.com you can get Grounding and Shielding Techniques, by Ralph Morrison.
    http://www.amazon.com/exec/obidos/ASIN/ 0471245186/104-3492923-2811911
    Be very careful how you wire the circuits. Try to use only one ground point.
    The worst source of noise can be the motor and drive that spins the encoder. Be particularly careful in wiring this apparatus. A simple solution can be to use an air powered motor insted of an electric motor.
    Good luck,
    Mike Ross

  • 6602 quadrature encoder with c code

    I need to implement a quadrature encoder on the 6602 board usinng c language.
    I found some good function, for example  DAQmxBaseCreateCIAngEncoderChan, but i think this function is only for DaqmxBase,
    is there some similar function for Daqmx, or have i to do it myself?
    From where can i start?
    Thank you in andvance
    There are 10 kinds of people. Those who understand binary notation, and those who do not.

    Solved my problem.
    I installed the daqmx version on CD and it was old.
    Now i installed the new version daqmx 9.0 , that i toke from the site.
    This version has the function i need  DAQmxCreateCIAngEncoderChan,
    it compiles , now i have only to attach my encoder.
    Thank you lo stesso
    Message Edited by blacksocket on 02-08-2010 05:32 AM
    There are 10 kinds of people. Those who understand binary notation, and those who do not.

  • Troulbe in measurement quadrature encoder with 6601.

    Hi,
    We are trying to measure position with 6601. The frequency of quadrature encoder is from 100Hz to 8MHz. Now, we connet the A,B and Z channel directly to counter . Using the example in CVI, we change the filter to 100ns and use x4 mode. It works perfect at low frequency.
    The problem is when the frequency of encoder is higher than 2MHz, the accuracy decreases greatly. I'd like to know about following:
    1.Can 6601 do the previous task enough? Or I must change to use 6602.
    2.If 6601 is available, is there any way to increase measurement accuracy ?(in software or wire connection )

    Jimmy,
    You would need to specify what type of accuracy you are looking for, which is pretty much dependant on the type of operation you are performing. You could be looking to timestamp your encoder positions or you could also be looking to perform position/angle tracking over time. You could also be performing single point vs. multiple point (buffered) operations. You could mention which one of the CVI examples you are using and that could give an idea of the type of operation you are performing.
    The NI-6601 is able to perform quadrature encoder measurements and the only limitations you can have in regards of frequency are the filtering parameters (if you use filtering) and the actual maximum timebase of the board (20 MHz).
    Please keep in mind that by ena
    bling filtering at 100 ns you are only guaranteeing that pulses with widths of 100 ns or longer are not being filtered out. This limits your encoder phase frequency to around 5 MHz. (Each encoder period has a 50% duty cycle, therefore the pulse duration is half the encoder period). You can refer to the board�s manual for more information on filtering.
    We would have to know the following in order to provide further help:
    a) Type of operation being performed
    b) Specific example you were using
    c) Type of accuracy you were looking for
    d) Range of accuracy you needed on your measurement
    Regards
    Alejandro Asenjo
    Applications Engineer
    National Instruments

  • Quadrature encoder, velocity

    Hi,
    I am using DAQ 6062E, with BNC 2120. I have a quadrature encoder, and I need to get the position, and velocity. I have modified BNC2120_Quadrature_Encoder vi from NI. I can compute the velocity (delta position/time loop) easily, however this is not very accurate. I need to have a high accuracy velocity, and I think I have to use the second counter to measure the frequency of channel. However, I am not able to calculate the velocity with this method. I have attached my vi. I appreciate if somebody can help.
    My encoder is connected to CTR Source 0 (PFI8), and UP_DOWN (P0.6)
    I have connected CTR Source 0 (PFI8) to CTR 1 Gate (PFI4)
    Thanks!
    Attachments:
    try encoder_with frequency.vi ‏58 KB

    I get reasonably accurate velocity from quad encoders by connecting the source of my counter to the internal 20MHz clock then gating said
    counter with my index pulse(Z) or either A or B, depending on the speed at which I am running. This will give you a count of time between
    revolutions if gating with Z, or it will yield time between X degrees if gating with A or B.

Maybe you are looking for