11-11-2013 10:03 AM
Hi,
I need to generate pulses that simulate a quadrature encoder with acceleration. I have digital output and counter output NI devices available. I have done vi's that start with the quadrature pattern as a 1-D array of Integers and clock those out to a digital port. This is fine for fixed speed output. It allows me to output a fixed number of pulses at a fixed speed, but it doesn't easily allow acceleration.
I need to be able to do accelerating pulse trains. This would simulate, for instance, a real encoder attached to a motor that is accelerated from one speed to another. It would be most ideal if I could accelerate from a fixed speed to another fixed speed using a fixed number of pulses for the whole pattern. This would simulate a device that has distance, speed and acceleration control simultaneouly, and that is exactly the type of device I am simulating.
Max pulse frequency will be a bit under 130kHz.
The most ideal situation would be for the width of each pulse in the train to change proportionally as the frequency changes, i.e. a smooth frequency ramp.
Thank you.
Mark Holm
11-11-2013 01:15 PM
What kind of hardware are you using? DAQ, cRIO, PXI, PCI?
11-11-2013 02:16 PM
DAQ Hardware
11-11-2013 06:28 PM
Mark,
This was a fun little challenge.
It steps through a range of periods from beginning period to ending period. Internally the quarter period is used to allow generation of the quadrature signal by dividing by the frequency by 4. All timing inside the loop is done with integers to simplify comparisons.
The acceleration increment, Tau, is used to determine when the period changes. The accelration rate, dT/dTau, determines the amount of change in period at each increment Tau.
When iteration counter i divided by the current period has a remainder of zero, the encoder value is updated. The encoder consists of two booleans on shift registers with logic to implement a two-bit grey-code counter.
The booleans are changed to integers and offset to display on both a chart and a graph. The small delay in the grey-code case structure sets the speed of the displays.
The loop will stop when the Ending period is reached or when the user presses Stop. With the default values it runs about 10-15 seconds on my computer.
The VI was developed in LV 2013 and saved back to LV 8.0.
Lynn
11-12-2013 10:08 AM
Thanks, Lynn. I need to look it over. It appears that I can use this, with minor modifications, to build an array representing the accelration, and then push that array out using DAQ routines.
Mark