11-13-2008 02:15 PM
I am using the USB-6251 data acqusition unit and the SC-2345 module for signal conditioning. I am using 2 encoders; one interfaced to counter 0 and the other interfaced to counter 1 input of the SC-2345 using PFI-12 as the clock source to provide the sampling rate. This rate is 9600Hz. I am also measuring a load cell output into one of the analog channels.
I acquire measurement data and pass the arrayed data to a For Loop to process the values to derive motor velocity from each counter task and a torque value from the analog input task. The measurement/process loops execute for 30 loop cycles before the motor starts motion controlled via a case statement being true then stops when 60 loops is reached. I am trying to measure startup characteristics of a motor.
The problem I am experiencing is that after the initial 30 loops the analog read task has measured data points for processing as the motor starts motion while the counter read tasks measured data = 0 for a short time and then starts outputting measured data.The counter measurements do not start until approx. 140mS after the analog measurement.
How are these read tasks synchronized? I have being looking at Labview examples and reading tutorials but I am not finding a solution. Any help would be appreciated. The code is attached; the read and counter tasks in question are on frame 3.
11-14-2008 06:24 AM
You have to route the clock from the analog task to the countertasks to have them started at the same time. For the counter tasks use the DAXmx timing (sample clock).vi and wire the ai/sampleclok with the correct device name to the source input. Then first call the DAQmx Start.vis for the counters and afterwards for the analog task.
This way the task will start sampling with the same clock and at the same rate.
11-18-2008 07:21 AM
I tried your suggestions and I do not see the position counter tasks synchronized with the analog task. However, I do consistantly receive "error -200019; ADC conversion attempted before prior conversion was complete. Increase period between ADC..." which may prevent the tasks from being synchronized. I am tracking down a problem which I believe exists with the external clock source of 9600Hz connected to PFI12 that works well for the position counter tasks but it does not work well for the analog read task. I proved this by creating a seperate VI with just the position counter tasks and another VI with just the analog read task. The analog read task consistantly errors with -200019; the position counter tasks work OK.
You don't know of any special considerations needed for analog read tasks when using an external clock source? If I run the analog read task with an internal timebase it works OK.
hhsatBeck
11-19-2008 11:26 PM
Hi hhsatBeck,
I created and attatched an example program that synchronizes the acquisition of two counter tasks and an analog intput task. I also tested this on a PCI-6251 and it behaved as expected. The counter tasks are buffered period measurements but could be changed to be another type of buffered measurement. When I say that these are synchronized, I mean that the acquisitions start at the same time using the same trigger, and that the sample clock used for each of these is the same. That means for the counter tasks that the buffered count value is updated at the same time that the analog input takes a measurement. The sample clock that I used was an external signal, tested with frequency values between 1kHz and 10kHz.
Just to be clear, we have to use a buffered measurement in order to actually synchronize a counter reading with an analog input task if we want the term "synchronized" to mean anything. If you are just trying to count ticks then the values that you read from the count register will only be software timed and the frequency of the actual count will only be dependent on the counter hardware being updated by the encoders.
For this VI to work properly I used the following hardware configuration.
Maybe give this a try with your input timing signal and see how it works out. This shouldn't be too hard to incorporate into your code. I hope this helps out.
Chris W
High Speed Products Group
12-03-2008 08:44 AM
Hi Chris W.,
Thanks for your suggestions on this synchronization issue. Your code example was written with Labview 8.6; I am using Labview 8.5.
I didn't use much of the hardware change suggestions you made because I want to maintain the Position Measurement capability of the counter task. The M-series documentation indicates that the encoder phases(inputs) use PFI8(A) - PFI10(B) for one encoder and PFI3(A) - PFI11(B) for the other encoder, so therefore I couldn't use ctr0 source(PFI8) and ctr1 source(PFI3) as the timing source since these are required for the position measurement counter task.
I used your DAQmx Trigger suggestion and placed the analog read task in a seperate while loop from the counter read tasks. I also added a start trigger for the analog read task. These changes greatly improved the synchronization of the counter tasks to the analog task; the read task lags the counter tasks by approximately 32mSec.
I have attached the latest code. Please reply if you have any further suggestions to make this work.
12-03-2008 09:24 AM
Hi hhsatBeck,
I'm sorry about posting 8.6 code. I have re-attatched the code in version 8.0 so you can see it and in case other people are interested. I didn't realize that you were using a position encoder when I wrote that VI, however, looking back at your original post that is apparent...oops. I have modified the VI so that it uses Linear position encoder tasks and an AI task. The encoder tasks are stil buffered so that the count values that are recieved from those are count registers are synchronized with the AI readings. I am using the model of "Buffered (Sample Clock) Position Measurement" shown in page 123/424 of the M Series User Manual.
http://digital.ni.com/manuals.nsf/websearch/2025C99AB0614F9E8625748000577B9A
With this revision I've changed it so that all of the tasks run off the aiSampleClock for timing instead of relying on an external signal. You can of course specify some other source if you'd like. This should take care of the AI lag.
Chris W
12-09-2008 08:57 AM
Hi Chris,
I still had an issue of the acquired data not being aligned(synchronized) per your suggestion. The acquired data became aligned once I placed the Start Tasks in a flat sequence and added in the Start Trigger for the analog task.
I have attached my code; the task setup is in sequence 3 of debugTorq_TwoEncoderVel with sync with data storage.vi
Thanks for all of your help.