LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the generated wave frenquency diffrerent from the set frequency in the program?

Solved!
Go to solution

I cannot debug a picture.  I can debug a VI.  Attach (all of) your code.  If you have more than 3 VIs, compress the folder containing them and attach the resulting .zip file.

 

When I run my code, and set # Samples to 500 (to get 5 seconds of data), I get this:

Simple XY Scan Demo, 5 secsSimple XY Scan Demo, 5 secs

As you can see, the steps and ramps occur with a period of 1 second (or frequency of 1 Hz).  I can say that "you are doing something wrong".  I can "guess" at what it is, but that would probably waste your (and my) time.  With your code (*.vi), I can find (and explain) it for you.

 

Bob Schor

0 Kudos
Message 11 of 38
(304 Views)
Solution
Accepted by topic author M.Mei

OK, you've provided (in your most recent posts) sufficient "hints" at where you've made your mistakes, and also attached in your very first post your "failing" VI, that I'm willing to "make a guess" at what you are still doing wrong.  In doing so, I'm also guessing I've put far more effort into helping you than you have into helping me to help you (by not attaching your VI so I could see what you've done).

 

I'm guessing you've made minimal changes to your original code.  Many LabVIEW beginners don't get to see the slide I made in my "Introduction to LabVIEW" talk titled "Concept of Time", which states "Time is an intrinsic element of LabVIEW".  This is especially true when acquiring data, and is the reason that LabVIEW has a data type called a Waveform, and has plotting Indicators called Waveform Chart and Waveform Graph.  If you look at my code, I create a Waveform and wire it to the Waveform Chart, and "magically" get the correct axis labels on the Time Axis.  In your original TEST code, you also had a Waveform, but blithely stripped the Time information off it before plotting it and before sending it to the DAQmx Write (so it's a minor miracle that it runs at the proper speed).

 

What you should do is to create a 1D Array of Waveforms (as I did), send it to a single Waveform (quick quiz -- Chart or Graph?), and configure the DAQmx Write to take a 1D Array of Waveforms.

 

If I "guessed right", please feel free to mark this Post as the Solution.

 

Bob Schor

Message 12 of 38
(298 Views)

Hi Bob,

 

Yes!!! Your guess is right! I just find why I get  different results when I only copied your code and added them into another program.

 

When I copied your code, I really fully copied them and understanded, then I tried to added them in the acqusition one. But in the whole program, I used a DBL mode without the 'time' rather than  a waveform same as in your code. I do this because I think the program will go with time as what I imaged, however it is not. I am sorry I did not mention about this before, because I really do not realise this thing, so I ignored it all the time.

 

I put the wrong code to show everyone where I am wrong.

 

Thanks,

Mei

0 Kudos
Message 13 of 38
(296 Views)

Hi,

 

In the original code, I used 100 samples per wave.  I just find the reason! Please see my replies.  Thanks for your help!!!

 

Thanks,

Mei

0 Kudos
Message 14 of 38
(295 Views)

 

Hi Bob,

 

With your patient help, the time showing on the waveform graph is right. But I used time count funtion to get the time, this time is different from the one showing in the graph.  I also used an oscilloscope to check, the output wave frequncey is also 5 HZ, when the setting is 1 HZ (Please see the picture below).  Can you help me about this?

Capture1.PNG

The VI is attached.

 

Thanks,

Mei

0 Kudos
Message 15 of 38
(267 Views)

The vi that you posted appears to be different than the one that you ran. I had to make some changes (you were starting the vi twice and were waiting for the acquisition to end on a continuous acquire, e.g) to make it run, but when I did run it the time was 5 seconds.

0 Kudos
Message 16 of 38
(261 Views)

Hi johntrich,

 

Thanks. As I mentioned before, the current Data acqusition card is from measurment computing not NI,so, I changed the VI to DAQmx vi in case you cannot debug the vi, but I only changed ULxI vi to DAQmx vi, other parts keep the same. The picture result is from the program with ULxl vi. It is strange if the result is different running with DAQmx.

 

Can you explain your changes more detailed or can you show me your code? I cannot make the correction according to your relpy.

 

Thanks,

Mei

0 Kudos
Message 17 of 38
(253 Views)

The only changes that I made were to DAQmx so they probably don't apply to your vi. The problem must be with the call to the Measurement Computing driver. 

0 Kudos
Message 18 of 38
(250 Views)

Hi johntrich,

 

Can you please let me know the changes? I can try to check whether it is because of the driver or my code? 

 

Thanks,

Mei

0 Kudos
Message 19 of 38
(244 Views)

I apologize but I did not save the changes. I can assure you that they were only to the DAQmx. Can you upload a copy of your code with the Measurement Computing driver? Perhaps someone can spot the issue. It's hard to troubleshoot your code when we don't have the code that you're running.

0 Kudos
Message 20 of 38
(237 Views)