Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

menomena

Member

08-31-2013 09:04 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

Hello, i am getting data from excel file into array, then i am using 'sim arbitrary signal' block to set a dt which i need and to plot signal(it is voltage signal). Then i need to get a 1st derivative of this signal. and there i am getting problems cause after using derivative from (time domain sig pallete) my derivative doesnt look proper. Is there anyone who could help me? U can see in attachments some piece of my VI, Graph of Voltage Signal and Graph of Derivative of Voltage Signal

Solved! Go to Solution.

Download All

Virus scan in progress. Please wait to download attachments.

johnsold

Knight of NI

08-31-2013 10:16 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

Are you sure your dt is correct? Looking at the image vol.png I would guess that the dt is closer to 100 us than 4 us. That will make a big difference in the derivative.

Please post your VI (rather than an image of part of the block diagram) and the data file.

Lynn

08-31-2013 10:52 AM - edited 08-31-2013 10:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

I am 100% sure that my dt is 0,000004s

I ve attached my project, excelorto867 is main file, inside is also a setting file (settings.png)

johnsold

Knight of NI

08-31-2013 12:09 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

The problem is that your data is rather noisy and the standard differentiation techniques accentuate the noise. Another factor is the decreasing dt at the beginning. This creates overlapping plots.

I tried the Savitsky-Golay smoothing and differentiation method and can definitely see the derivative.

This is for the portion after the time column reaches zero and starts increasing. The setting was for 240 side points and 3rd order polynomial for the Savitsky-Golay differentiatior. The blank spaces at the ends are due to the smoothing process which cannot cleanly handle the ends of the data array. The image below shows the same calculation with 50 sidepoints of smoothing.

You can see the sinusoidal signal in there, just barely, but the extra smoothing above helps. Note that ti takes much longer to run with more sidepoints.

I do not have the Excel VIs so I converted your file to a tab-delimited text file then read it once with Read from Spreadsheet File.vi. Then I created a constant from the all rows indicator and used that as my data source.

Lynn

08-31-2013 12:38 PM - edited 08-31-2013 01:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

johnsold

Knight of NI

08-31-2013 01:47 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

Error -5111 is one I defined for the Differentiator and Smoother VI. The second line of the error message is the clue to the problem. L <= 2k + 1. L repesents the length of the input array. K is the number of side points. It appears that the input array is too small for the number of side points you have selected.

Note the constant 1709 connected to the Array Subset functions. That is based on the location of the minimum in the first column. If you are using different data, you will need to change that or remove it for data with monotonic time values.

There are some things about your code I do not understand. You have a 2D array coming from the spreadsheet. You connect it to Index Array with a control wired to both Column inputs and nothing wired to the row inputs. This gives you two copies of the selected column which you then combine into a 2D array.

In my code the 2D array contains the three columns of data from the spreadsheet file which appear to be time, voltage, and current. What you have appears to generate two columns of voltage data. You should still be able to get the derivative although the graphs will not make any sense because the time data is missing.

Lynn

09-01-2013 06:59 AM - edited 09-01-2013 07:02 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

I wish to thank you again for your invaluable support. 1st thing, u are right that this thing to control before building an array has no sence(i am a beginner). What does excactly mean constant 1709? Ive noticed that it looks rather more like 'how many samples do u want to plot on your graph'. If i am setting 10 i see 10 samples at my plot, if i choose 1000 i see 1000 samples.

Is it possible that u could help me to consider why not the full signal is plotting, u said that something is cutting end of the plot(array). In my opinion it is rather like, the start is cutted off and the plot is moved to the left side. Cant figure it out

09-02-2013 05:39 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

johnsold

Knight of NI

09-02-2013 01:02 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

menomena,

It is better to keep the discussion here rather than in PMs. That way others who are following the thread or may find it in the future can benefit.

In the PM you asked: "U suggested and sent me a VI with Savitzky-Golay filter. I have a question to u. Why, when i am setting "side points"(24 are default, but i am setting 240 for better calculation) (to obtain derivative), the algorithm cuts on the plot first and last 24 samples(from array), or 240 samples(it obviousely depends on how many 'side points' i set. Is it possible to get a plot without any cuts?"

Please look at the detailed help for the Savitsky-Golay Filter Coefficients VI. It describes how the process works and how to adapt it to work on th epoints near the ends of the data set. The application I had when I developed the VI I posted did not need the end points so I created this simplified version.

The NaN (Not a Number) values in the Differentiator VI output are causing the problem with the Integral x(t).vi. Many VI will return NaN for the entire output if any input value is NaN because there is no way for the VI to determine an "appropriate" output for that input. The NaN values occur at the begining and ending "side points" of the output array. You can use Array Subset to extract the portion with valid data to integrate. The Waveform graph on the right is the integral produced by the code shown.

Lynn

09-02-2013 03:58 PM - edited 09-02-2013 04:02 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator