LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generation of inclined Sine wave

Hello Community,

 

I am a graduate student. I need to write a program in LabView for my project. We have a servo drive which is attached to rack and pinion. The aim is to move the sample attached to the rack and pinion.

 

It is required to move the sample with a specific sine wave. The movement is unique and combined with 2 types of motion. First one is the sample will oscillate with a fixed frequency with a perfect sine wave. Second one is the sample will move downward with a fixed velocity. I am trying to write a code so that the sample moves with superimposed motion of 45 deg sine wave. I have attached the required sine wave named as "superimposed sine wave".

 

I am using DAQ Express software from NI. I am using USB 6003 DAQ device for analog voltage input. The device has analog voltage restriction of 10volt peak to peak. My experiment will last only for 5 seconds. The draw wire sensor that will be attached to the sample to get the output has a sensitivity of 1.906mV/mm. The frequency of the size wave is 5 Hz. Amplitude is 6mm (3mm+- for up and down). Therefore, the amplitude signal should be (considering the draw wire sensor sensitivity factor) (3mm * 1.906mV = 5.718 mV or 0.005718 V). The second motion, velocity of the sample to the downward for 100mm per second. If I convert it to draw wire sensor sensitivity factor, it would be (100mm * 1.906mV = 190.6 mV or 0.1906V). After writing the code and test the code with an oscilloscope, I am having several problems as follows:

 

1. There is a time delay, after which the sine wave generates in the oscilloscope. How to make to zero time delay?

2. I tried to use "Ramp pattern by increment" function from signal processing and pattern generator menu. In order to make it consistent with the velocity, the appropriate voltage should be 0.1906V. However, I can not make it fraction. I have attached the error as the screen shot of pattern generator.

 

Is there any alternative way to write the code? I have attached the project code for your convenience. I would greatly appreciate if someone help me in this regard. 

 

Best Regards,

Muhammad

0 Kudos
Message 1 of 24
(1,372 Views)

Thank you for trying to send us your entire LabVIEW Project so we can examine your code.  However, your .zip file contained a single file, with the extension .lvproject, which is a file type that I didn't immediately recognize (I'm very familiar with .lvproj files, which are the "Project Files" that LabVIEW configures when you create a new Project and holds links to the VIs that comprise the Project).  There were no VIs or TypeDefs in the .zip file, just the single .lvproject file.

 

Do you have the LabVIEW code (VIs, TypeDefs, etc.) and a .lvproj file that you open when you want to create and modify and test VIs that are part of this Project?  If they all lie in a single "Project Folder", it is the compressed form of this "Project Folder" that would be useful for us to see in order to make intelligent suggestions.  

 

What version of LabVIEW are you using?  Not everyone is using the most recent versions ...

 

Bob Schor

Message 2 of 24
(1,353 Views)

Thanks a lot, .

 

I am actually using DAQ Express software, which runs in LabVIEW environment. 

Link: https://www.ni.com/en-us/shop/data-acquisition-and-control/application-software-for-data-acquisition-and-control-category/what-is-daqexpress.html 

 

When I write a code in the DAQ Express software, I can only save it in .gvi format. I have attached it. Can you open that? I have also attached screenshots of diagram and panel window of the code. 

 

Thanks.

 

Muhammad

 

 

Download All
0 Kudos
Message 3 of 24
(1,338 Views)

Oh, no, are you using LabVIEW NXG?  The "pictures" you attached certainly are not "classic" LabVIEW, which is still being supported by NI.  I did download and install a version of NXG a few years ago, but it was too "different" and "lacking in the things I needed and was using in LabVIEW" for me to continue trying to learn an "incompatible" programming-paradigm-in-development.

 

Sorry, I don't know how to help you -- it's almost like you sent me code in "Visual Python" ... (a made-up Graphic Language).

 

Bob Schor

Message 4 of 24
(1,335 Views)

Could you suggest me how to write a program for the desired operation in normal LABVIEW environment? Then I will certainly try that.

0 Kudos
Message 5 of 24
(1,332 Views)

Hi Muhammed,

 


@Muhammad_mst wrote:

Could you suggest me how to write a program for the desired operation in normal LABVIEW environment? Then I will certainly try that.


After installing "classic" LabVIEW you will find an ExampleFinder in the help menu.

Using that ExampleFinder you get access to a ton of example VIs and projects...

 

You probably could use examples on signal generation in combination with examples on signal output for your hardware!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 24
(1,301 Views)

Hello GerdW,

 

Thanks for your reply.

 

There are some reasons because of them, I can't use the classical labview. I have to somehow stick to this version.

 

However, I am facing following 2 problems:

 

1. Every time I run the code, there is always some delay. I have made delay time zero, but still I am having a delay as shown in a attached picture of output in oscilloscope.

2. I need to ramp the sine wave using the ramp pattern by increment function. My sine wave's ramping should be 0.19V as per my requirement. But it shows error every time I set it as a fraction as if it only takes 1 as an end value (indicated in blue underline).

 

Do you have any thoughts about these issues? Could these problems be solved using functions in classical LabVIEW?

 

Regards,

Muhammad

Download All
0 Kudos
Message 7 of 24
(1,217 Views)

You didn't attach code that we can "see" and understand (presumably because you are using LabVIEW NXG, which is a discontinued product, while most of us are running LabVIEW, which existed for maybe 20-25 years before NXG and is still being used after NXG).  You also did not clearly describe what you want to do.

 

I know that it involves a sine wave, and possibly a second signal (a ramp?).  But if I knew what you wanted to do, I could write a simple program in LabVIEW to produced a sinusoid and a ramp and plot them, thereby demonstrating many of the functions you are trying to create.  With luck, you'll be able to recognize LabVIEW functions such as "Add", or "While Loop", or "Case Structure", or "Chart", or "wires", or "Controls", or "Indicators", and translate my code (pictorial, since you appear not to have LabVIEW software to "see" and "execute" and "edit" the VI).

 

So what are the parameters of the sinusoid?  What frequency (or frequencies) do you want?  Is the amplitude fixed, or changing (and if changing, how?).  Similarly, is frequency fixed or changing?  What are the parameters of the ramp?  How are the ramp and sinusoid related?  [Presumably they share some temporal relationship, but are they used as separate signals, i.e. one drives an oscillator and the other drives a positioner, or are they combined somehow (you are using the Ramp to control the frequency, or the amplitude, or the bias of the sinusoid).]

 

Tell us more, and more clearly, and we'll try to help.

 

Bob Schor

Message 8 of 24
(1,182 Views)

Hello Bob,

 

Thanks for your reply.

 

First of all, the sine wave has a fixed amplitude 0.005718 V and frequency of 5 Hz. I need to ramp up this sine wave with respect to time. In that case, the ramp-up for each second would be 0.19 V.  The experiment should be for a total duration of 5 seconds and ramp-up will continue throughout the 5 seconds. 

 

Now I am checking classical LabVIEW 2023 and I am looking for the required function of ramp-up in classical LabVIEW 2023. Since I am new in LabVIEW, Could you help me by saying what functions should I use to generate the program in classical LabVIEW and how?

 

Thanks.

 

Regards,

Muhammad

0 Kudos
Message 9 of 24
(1,071 Views)

Hello, Muhammed.  

 

     Do you have experience with the LabVIEW "Waveform" data type?  This is a way of representing "sampled" (or "equal-time-interval") data for input or output.  For example, you could create a Waveform that represents a sinusoid sampled at 1 kHz for 1 second (or even for 5 seconds) that has an amplitude of 0.005718 V and a frequency of 5 Hz.  You could also create a second sampled signal that is your "Ramp".

 

A question -- when I think of a Ramp of 5 seconds, I think of a signal that "only goes up" for 5 seconds.  But I wonder if you want to use a signal that goes up, then returns to 0 every second (sort of like the beam of an oscilloscope that sweeps left to right, then snaps back at the end of a 1 second sweep).  It is easy enough to generate either form of ramp.

 

If you open LabVIEW, you can find (on the Block Diagram) a Waveform Palette.  Click on Analog Waveform, then click on Generation.  The Basic Function Generator can generate both Sine Waves and Triangle Waves (I think this means the kind that goes up and "snaps" down to start the next cycle).  Try configuring a Sine Wave Generator with a frequency of 5 Hz and an amplitude of 1.  Leave "Sampling Info" at the default, 1 kHz and 1000 points.  

 

Now go to the Front Panel and drop a Waveform Chart.  Back on the Block Diagram, wire Signal Out to the input of the Waveform Chart.  Note that the Chart Icon changes color, becoming dark Brown to match the "Wire", which is now of type "Waveform (Dbl)".  (You can tell by right-clicking the Wire and looking at the Help).

 

Aha!  I just tried this, and I got a 10 Hz sinusoid, all squished up on the left side of the chart.  This we'll fix now.

 

To fix the Chart, go to the Front Panel, right click the Chart, and choose "Properties".  You want "Time" (not Date and Time") on the bottom.  On the Display Format tab, choose "Relative Time", and also HH:MM:SS (since you want seconds).  Now click the "Scales" tab.  You can either "Autoscale" or set the X Scale to 1.

 

So why did I get a 10 Hz sinusoid?  I expected that I could fill in the Front Panel of the Basic Function Generator and it would "remember" what I told it.  I guess it doesn't.  So I wired 5) into the Frequency input and 1 into Amplitude.  Ah, much better.

 

I get it, now.  The values I saw when I double-clicked the Waveform Generator were the default values, which would be used if I didn't wire something.  But when I clicked "Run", inputs that were not wired went back to their "default" values.  Oops, I knew that, but even Experts sometimes make a Beginner mistake.

 

So now look at the inputs on the top of this function.  Right click "Signal Type" and choose "Create Constant".  You should see "Sine Wave".  This is an "enum", an "Enumerated Type" that takes on specific values.  Click the arrows and select "Triangle Wave".  Is this what you want?  [I was a little surprised by this -- maybe you do want "Sawtooth" -- try it and see].

 

Well, "Sawtooth" is what I was thinking you'd want (from my "oscilloscope" analogy, above).  But you'd want it to rise for 1 second and then snap back.  Try adjusting the Phase and Offset inputs and see if you can get what you want.

 

So you can have two of these generators going, and all you need to do is add their signals.  If the Waveforms are generated at the same time and with the same "timing" parameters, I think you can simply add them (try it and find out).

 

See how easy it is to "experiment" with LabVIEW and "teach yourself" how these functions work?

 

Have fun.  Send me a message if something doesn't quite work.

 

Bob Schor 

 

 

Message 10 of 24
(1,059 Views)