06-28-2023 10:55 AM
Greetings everyone! I'm currently facing an issue regarding the precise timing of sinusoidal signal generation. In my program, I aim to generate a sinusoidal signal with an amplitude of 0.5 and an offset of 1. However, I'm encountering a delay between the output generation of the sinusoid and the input signal I'm reading, which is set at 500 Hz. In addition to my previous query, I would like to mention that my ultimate goal is to analyze the frequency response of a motor. To achieve this, I plan to utilize sinusoidal generation at various frequencies.
I have included a graph for reference, where the green line represents the signal I generate, and the red line represents the signal I am reading. It is evident that there is a noticeable delay between the two signals.
I'm having trouble understanding the relationship between the timing of the sinusoidal generation and the input signal reading. Could someone provide some guidance on this matter? Your assistance would be greatly appreciated.
06-28-2023 11:02 AM
Sorry, I cannot look at your code (unless you save for previous and reattach), but your two signals have different frequencies, so how do you define "delay"?
06-28-2023 11:07 AM
this is the file with labview code
06-28-2023 11:20 AM
Well, all you have is a free-running toplevel loop using no obvious timing whatsoever (where you output a single scalar and read an array of two data points (all in no particular order!) with each iteration). Where is the queue used?
You need to use hardware timing.
(You really should get rid of the dynamic data and all the to/from dynamic data, etc. Way too opaque)
06-28-2023 11:26 AM
I suggest that you write a "small" program first, one that acquires N-channels of sampled data at 500 Hz, but sampling 500 (or 1000) samples at a time.
If you want accurate and precise timing, you cannot use the PC's clock to take multiple samples -- it just is not precise enough to do this. Fortunately, DAQmx hardware has more reliable clocks that only time the DAQ hardware, so if you take 500 points at 500 Hz, it will reliably take 1 second per sampling.
One second should give you enough time to send the data to a Graph. So write a simple program to do this and plot the results. Note you will get a 2D Array from the NChan NSamp DAQmx Read, which can (and should) be directly wired into your Load Cell and Input Motor graphs (please don't use the Dynamic Data Wire. You should also be able to generate the appropriate 1D Array of a Sine Wave within the 1s you are waiting for the data. Much better to process your data in "chunks" (using "hardware" timing) than one-at-a-time, using Windows timing and much messier "point-by-point" processing.
Bob Schor
06-28-2023 12:10 PM
Thank you for your answer, but if I put the hardware timing in the DAQmx the labview give me an error:
"Possible reason(s):
Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: SampQuant.SampMode
Requested Value: Hardware Timed Single Point
Possible Values: Finite Samples, Continuous Samples
Task Name: _unnamedTask<1CA9E>"
06-28-2023 01:38 PM
ccarra25@uic.edu wrote:
Thank you for your answer, but if I put the hardware timing in the DAQmx the labview give me an error:
"Possible reason(s):
Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: SampQuant.SampMode
Requested Value: Hardware Timed Single Point
Possible Values: Finite Samples, Continuous SamplesTask Name: _unnamedTask<1CA9E>"
We cannot tell what you did from this description.
06-28-2023 02:16 PM - edited 06-28-2023 02:40 PM
I did a simple program but I still have problem with the input signal. Can you suggest any improvement?
It seems that I generate a sinusoidal signal but the analog output didn't get this, so i acquire noise data.
06-28-2023 04:11 PM
Stop using that code you keep showing -- it is fatally "broken" (because you are asking it to do something that makes little sense, and the way to find out about that is to "see for yourself", which is precisely what I'm trying to get you to do without my "doing it for you", which is not my style of teaching).
Run this VI. If you have a waveform generator, use it as an input to one of the A/D channels. If not, simply touch one of the A/D channels to inject 50 or 60 Hz "noise" into the system.
So what about generating an analog signal to "drive" the system? It depends -- do you want the "driving signal" to depend on the analog response you are measuring (above)? And if so, how quickly do you want it to respond? If you are trying to build a closed-loop control system, this is a much trickier problem that requires specialized (and fast) hardware, such as an FPGA that can respond almost instantaneously, which leaves DAQmx out. Otherwise, take a separate While Loop and build your Analog Output code following the same principles as outlined above. Note that, again, you can pre-compute 1000 points of your Waveform, start it going, and while it is outputting the first set of points, you are generating (and doing a DAQ Write for) the next bunch of points, making the output continuous and uninterrupted.
Do these one at a time. Keep your VIs compact and neat. Don't add Bells and Whistles at the beginning of your code development -- wait until "something works".
Bob Schor
06-29-2023 04:19 AM
If you have your generation and measurement tasks running:
If you want to find a fequency response by applying sine exitations , you migth need to add a delay after changing the exitation to measure the steady state 😉
Or you apply a whatever (broad bandwidth ?) signal and go the frequency domain / correlation way ...