LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate staircase-shape SIN waveform

 

Ok, I will try it with loop.

At my side I've also find a solution.

Here it is:

staitcase_SIN_generation_step_duration_issue (2).JPG

 

staircase_sin_steplength_issue_simplest_setup (2).png

0 Kudos
Message 11 of 26
(2,293 Views)

That logic should work also.  You are basically generating a wave for with N number of points (where N is the desired final number of points) and flattening the slopes to whatever was the last recorded value when the remainder of Mod 100 was zero.

 

Mine was generating a wave of N/100, and repeating each step of that wave for 100 times before moving onto the next wave.

 

The results should pretty much be the same, just getting to them from opposite directions.

0 Kudos
Message 12 of 26
(2,287 Views)

@johnsold wrote:

Pavel_47,

 

You have multiple threads going with very similar questions.  Each time you make a little progress and then come up against a new obstacle, you start a new thread.  While there is some merit in keeping each thread short and to a single topic, I think that you may be making things more difficult here because no one is sure just what has neen answered and what has not.

 

Please pick one thread, possibly this one, and specify your overall goal. Tell us what you are really trying to generate or measure, not so much what you have tried that did not work. For example give details about what the staircase sine wave should look like. What is the range of amplitudes? What is the range of step amplitudes? Does every step have the same amplitude or does it depend on sin(t)? What is the range of frequencies? How is the duration of each step related to the frequency? Do all steps have the same duration? Which parameters of this waveform are fixed and which can vary? How often can they change? If a parameter changes while generation is in process, does the waveform change immediately or at the end of the next complete cycle? What sampling rate or rates will be used? In one thread you had noise or a higher frequency sine wave superimposed on the stepped waveform. Is that a requirement or simuation of interference? If a requirement, then also specify all the parameters of the higher frequency signals.

 

What will you do with this signal after you get it generated?

 

After we have answers to these questions, we will have a much better idea of what you are trying to do and can then more likely give you useful advice on how to achieve it.  Help us to help you by not making us pry information out bit by bit.

 

Lynn


 

Well, I thought that my posts aren't so similar and touch different aspects of design, that could be useful for other users.

This post concerns waveform generation, whereas previous one was on spectrum.

But, Ok, I agree, all of them concern the same setup.

 

Overall goal - is to debug calibration algorithm on PC before going to the lab and connect to devices.

Calibration algoritm must compensate residual magnetic field in 3 directions on our testbend (research experiment in magnetoptics)

3 compensation coils are controlled by NI DAQ.

The feedback (output from DUT ... or "input in LabVIEW")  is provided by a signal from camera or photodiod.

The generic behavior of DUT is known, so I can model it in LabVIEW, but there is noise and spurious (e.g. 50Hz) that should be taken into account by calibration algorithm.

The noise and spurious behavior are unknown, that's why I have to develop some LabVIEW staff to remove them (without detriment to useful signal) for different scenarios.

 

Concerning all the parameters you enumerated, actually some of them aren't defined yet.

Is it so important to know them ?

 

Thanks

 

Pavel

0 Kudos
Message 13 of 26
(2,284 Views)

Maybe it's just me, but what use is any waveform plot that plots the same datapoint 100 times in a row NO MATTER how much it might change. If I needed a staircase shaped waveform, I instantly think of an ATD (Analog to Digital) converter that switches to another 'staircase' level when the signal gets close to it. Then route it back through another DTA (Digital to Analog) converter to restore the signal. Because there's always a loss of precision in these circuits, you will get a staircase waveform back.

 

StaircaseWaveform.png

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 14 of 26
(2,272 Views)

One-shot run Ok, but once in while loop, waveform is quickly saturated. So, some array management is necessary

0 Kudos
Message 15 of 26
(2,254 Views)

@RavensFan wrote:

That logic should work also.  You are basically generating a wave for with N number of points (where N is the desired final number of points) and flattening the slopes to whatever was the last recorded value when the remainder of Mod 100 was zero.

 

Mine was generating a wave of N/100, and repeating each step of that wave for 100 times before moving onto the next wave.

 

The results should pretty much be the same, just getting to them from opposite directions.


It seems that in your solution the step length depends on frequency and cannot be defined independently.  Am I right?

0 Kudos
Message 16 of 26
(2,246 Views)

Of course.  Everything is inter-related.

 

You had never defined why you thought your step should be 100 units long.  You were just wondering why it wasn't.  The lengths of the steps were all dependent on your software speed, which is pretty meaningless since the length of your step is going to depend on the hardware you will be using when you finally start collecting data.  And only then it's a function between the update rate of the hardware that creates the signal versus the acquisition rate of the DAQ system you are using to acquire the signal.

 

You are saying you are trying to simulate something you are going to do in hardware, but you really haven't defined what that system is or what how the real world hardware is supposed to behave.  Anything discussion up to now is pretty much an academic exercise.

 

Your step length can never be defined independently because it is all dependent on factors in your system you haven't defined.

0 Kudos
Message 17 of 26
(2,239 Views)

I've explored your version attaching it to hardware (I've also slightly modified your code and included some benchmark measurement).

The generated staircase SIN were applied to AO0 of USB-6521, then using T cabled to AI0 of USB-6521 and to oscilloscope Tektronix TDS 2004C.

Here are 2 observations:

  1. 100ms of step duration (set in VI) wasn't retained:
    • on oscilloscope step duration values are slightly greater than 100ms
    • values processed in BOTTOM loop are slightly less than 100ms
  2. The step duration demonstrattes ripples

The 2nd point is more important than 1st: the exact value of step duration is not so important, whereas ripples could be a source of additional noise.

I've added some measurement staff - mean value, standard deviation and can see that they are far to be constant.

 

Additional remark concerning step duration measurement in the bottom while loop ... surprisingly it measures a value about 2 times greater than value that is observed in INP Waveform Chart (so before connect to indicator,  I didvide it by 2) 

So there are 4 different values of step duration, observed in this setup:

  1. Generated in TOP while loop, then observed in OUT Waveform chart: seems to be exactly 100ms
  2. Observed on oscilloscope: difficult to measure exact value, but seems to be greater than 100ms
  3. Captured in BOTTOM while loop and observed on INP Waveform chart: less than 100ms
  4. Calculated in BOTTOM while loop: less than 100ms and even less than (3)

Regards

 

Pavel

 

P.S. STOP button stops only BOTTOM loop, not VI ... it's due to DAQ that still running. Correct ?

 

staitcase_SIN_generation [RavensFan] USB-6521.JPG

 

 

 

 

staircase_SIN_generation [RavensFan] USB-6521 (1).png

 

 

0 Kudos
Message 18 of 26
(2,202 Views)

The steps are just fine in the top loop.  The only possibility of a problem would be related to the regeneration mode of the analog output as to whether a packet of data falls at the correct timing interval after the previous packet of data was written.  In other words, the time it takes to generate the next packet of waveform may be adding timing between the end of the last one going out and the start of the first sample of the newly generated waveform going out.

 

The problem with your bottom loop is your are just acquiring 1 sample at a time, so it you now back to just software timing of your acquired data.

 

I suggest looking through the DAQmx examples to find the most appropriate setup for both the input and output sides.

0 Kudos
Message 19 of 26
(2,188 Views)

@RavensFan wrote:

The steps are just fine in the top loop.  The only possibility of a problem would be related to the regeneration mode of the analog output as to whether a packet of data falls at the correct timing interval after the previous packet of data was written.  In other words, the time it takes to generate the next packet of waveform may be adding timing between the end of the last one going out and the start of the first sample of the newly generated waveform going out.

 

The problem with your bottom loop is your are just acquiring 1 sample at a time, so it you now back to just software timing of your acquired data.

 

I suggest looking through the DAQmx examples to find the most appropriate setup for both the input and output sides.


  1. ... In other words, the time it takes to generate the next packet of waveform may be adding timing between the end of the last one going out and the start of the first sample of the newly generated waveform going out. Anyway the neighborrow steps (within the packet of 1000 samples) aren't affected by this case. My measures in BOTTOM loop show that even neighborrow steps aren't equal. Ok, I will change acquiring mode to see the difference. Unfortunately with my oscilloscope it's quite difficult to do such measurement on hardware.
  2. ... The problem with your bottom loop is your are just acquiring 1 sample at a time, so it you now back to just software timing of your acquired data. Have you an explaination why meausrements with INP Waveform chart differ from mesurements obtained with the staff located in the top part of the BOTTOM loop ... after all, the "input" for both is the same. Moreover, the measurement staff requires division by 2 (or my measurement staff isn't correct ?)

What about issue with STOP button. Is my supposition correct ?

 

Thanks

0 Kudos
Message 20 of 26
(2,172 Views)