Linear fit between two cursors from a signal from a NI-instruments via DAQ-Assistant

Hi ! 
I'm currently having som problem with my labview code. I'm trying to make regression on a specific part of my graph. The graph consist of a signal gathered from a NI cDAQ-9178. Currently I can get the live data in a graph (Raw Signal) and then  "zoom in" to the part of the graph that im intrested in by two cursors and then display the results in a new graph (Adjusted Signal). Now a want to make regresion in the new graph. How can i do this the best way ? 
To be noted I'm a beginner of labview so my code maybe a bit off.
Best regards Maurlind
Solved!
Go to Solution.
Attachments:
Rawsignal test.vi ‏245 KB
rawsignal test.png ‏64 KB

Hi maurlind,
I got it, the function that derived the linear fit couldn't handle that large numbers on the x-axis. I edited the VI so that the large number is suctracted for the fit, i.e. the array will now begin at zero time for the fit. It will not affect your plots though, only the algorithm .
Try it now with the files I provided. The file "pm_mod2_Rawsignal test.vi" should be used with "test3.lvm" (your data). The file "pm_mod3_Rawsignal test.vi" is the same as "pm_mod2_Rawsignal test.vi", but it is arranged to work with the simulated data. The file "test3.lvm" is your data, but the file is slightly edited to work on my system.
Edit "pm_mod3_Rawsignal test.vi" to fit with your acquired signal as you did with the first file you got from me.
Attachments:
1412794.zip ‏483 KB

Similar Messages

  • Implementation of linear fit between two cursors

    Hi,
    I am trying to implement a linear fit between two cursors, as I am using total of 4 cursors. I would like to implement linear fit between cursor 2&3. Please help me how to implement it and to find a slope. I am also attaching my code.
    With Regards
    Phani kiran
    Solved!
    Go to Solution.
    Attachments:
    Linear Fit Implementaion.PNG ‏44 KB

    phanikiran wrote:
    Hi koen,
    Now I would like to merge both graphs i.e., Bestfit and XY Graph (in the block diagram). Can you suggest me, I have tried with build array and concenate Inputs function, but no use. Dont mine as I  am new to Labview. Thanks in advance.
    First, get rid of the Express XYGraph subVIs and use the "real" XY graph VIs. The Express ones get you going faster for simple things, but your options are limited.
    Take your X and Y arrays for both your original points and the best fit points (just two points, right?) and combine them into clusters of arrays (instead of feeding them into the XY graph). Then combine these into an array and feed it into your graph. It's all outlined in the XY Graph section of the LabVIEW help file.
    The LV Help File is your friend, learn to use it. It gets lonely if you don't look in on it once in a while.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ

  • How can I get extract the data between two cursors on an XY graph

    How can I get extract the data between two cursors on an XY graph

    Well, you say xy graph, so this might be a more complicated problem.
    For a waveform graph it's trivial. Simply get the two cursor indices (property: cursor index) and apply them to array subset of the data. Is that all you need?
    Here's how the above code would look like. using cursor.index instead of cursor.x elimnates the need to include scaling information.
    For an xy graph, there could be multiple segments (e.g. imagine a spiral that passes the desired x range multiple times from both sides). This would neeed significantly more code for a general solution.
    Message Edited by altenbach on 11-24-2009 07:53 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    cursorsubset.png ‏17 KB

  • Fading between two pages & controlling one MC from another.

    Let me see if I can explain this properly. I usually use a motion tween and the alpha channel to fade movie clips in or out. What I am currently trying to do is fade one page out and another in, but it could be one of several MCs. I basically have four "pages" for a website including services, portfolio, about, and contact. I have icons on my navigation bar (which is going to be imported into my XHTML seperately so it can float them according to the users window size). The icons need to navigate between the pages and the pages need to fade in and out (eg. fade in the Services MC when the user clicks on the services icon, and fade out of it and into the Portfolio MC when the user clicks on the portfolio icon). Please keep in mind that the icons and pages are in completely different .fla/.swf files because I couldn't figure out how to float them in Flash after several hours of looking around online, but know I can easily do it using div tags + CSS in XHTML.
    If someone could quickly explain how to "gotoandplay" a label in a different .swf file (communicate between the .swf NavBar and my main .swf) as well as fade out of the current MC (whichever page the user is currently on) before fading into new page (according to the icon the user clicks on), I'm sure I could 'fill in the blanks' from the rest of the AS3 and Flash I already know. The page also needs to fade out of whatever page it's currently on when the user clicks on the hide button (located on the page in the main .swf file). There is also several subpages on each page (which shouldn't be a big deal if I can figure the rest of this out).
    I'm going to be using this same concept for nearly all of the websites I design & develop in the future and really need to know how to do this for the current site I'm working on. I would greatly appreciate any suggestions on how to accomplish these two things.
    P.S. Please keep in mind I'm not an advanced user in AS3, but am very computer savy, and have done my share of programming in the past. I looked around for hours online to try and complete this without using the forum, but have come up with links to dead tutorials and short answers left and right. I'm hoping I won't come across the same here.
    From what I've read so far I believe I can use tweening in ActionScript instead of a motion tween on the timeline to fade in and out of clips and believe that's the method to use to accomplish what I'm trying to do. Correct me if I'm wrong though.

    I'm not looking for a "tutorial created especially for me".... Just perhaps someone that can copy and paste some code from a similar project that they have done so I understand how to do it.
    You could have simply put here's a tutorial for how to use TweenLite to crossfade between four pages, and here's one that will let you pass information between two .swf files. If you recently watched the tutorials then it wouldn't take long to find them (maybe you have them bookmarked) and post a couple links.
    Anyways, I just found an excellent tutorial on how to crossfade using TweenLite (found here) and an article that explains how to pass information from one .swf to another (here). It took some searching and knowing exactly what I was looking for to find them, but that's a much better answer for someone looking to do those two things than I've found here (or elsewhere for that matter).

  • In Labview 8.5, what happens if the signal input exceeds the signal input range set by the DAQ Assistant?

    Hello all,
    This should be a pretty simple question, but I can't seem to find the answer on-line and don't currently have the capabilities to test this:
    I'm using LabVIEW 8.5 and have a VI that imports sensor data through the DAQ Assistant. In the configuration tab there is a signal input range. What happens if my sensor exceeds this range? Will I get a warning? Will the value default to the maximum (or minimum)? I was interested in writing in some code to display an error as I approach the limits of this range, but was unsure if I also needed to include some code to display an error if the range is exceeded as well.
    Thanks for the help,
    Tristan
    Solved!
    Go to Solution.

    Hello Tristan,
    The behavior depends on the range you choose and the device you are using.
    If you are using a device with only one valid input range, we will use this range even if you set a smaller minimum and maximum in the DAQ Assistant.  Thus, if your device only supports ±10V and you set the range to ±8V, you will still continue to get valid data after your sensor exceeds 8V until you approach 10V.  Once you reach the limit of the range of your device, the output will "rail" and just return the maximum value until the signal drops below the maximum again.
    Note: A device that is nominally ±10V usually has some overshoot (like ±10.2V) that is typically specced in the manual.
    However, if you are using a device with multiple input ranges then things get more complex.
    The NI-DAQmx drive will pick the smallest range that fully encompasses the range you choose.  So, suppose your device supports the following input ranges: ±0.2V, ±1, ±5V, and ±10V and you choose 0V - 3V as the range in the DAQ assistant.  The NI-DAQmx driver is going to look at your input range and the list of input ranges that your hardware supports and choose the smallest that encompasses the full range you set.  This would the ±5V, because that's the only range that contains up to 3V.  As a result, any input signal between ±5V will be returned and any outside this range will "rail" to either the maximum or minimum value.
    We do this because using smaller ranges make more effective use of the resolution of the ADC.  Thus we try to use the most efficient range based on what you request without picking a range that will cause you to miss data.
    Let me know if I can clarify this further. 
    Seth B.
    Staff Test Engineer | National Instruments
    Certified LabVIEW Developer
    Certified TestStand Developer
    “Engineers like to solve problems. If there are no problems handily available, they will create their own problems.”- Scott Adams

  • Error message from labview when trying to set up the DAQ assistant

    I recieve a message from labview when I try to set up the DAQ assistant and select a channel to use. The error I get states "An exception occured within the external code called by a Call Library Node. This might have corrupted LabView's memory. Save any work to a new location and restart labview". Labview then freezes. I have reset the DAQ device in trying to slove this but I still get the same message. How do I solve this?? thanks - mars2006

    Hi Mars-
    It sounds like your NI-DAQ installation may have become corrupted. I would suggest uninstalling and reinstalling the DAQmx 7.4 driver to correct this problem and ensure that you're up to date. This download is available here: NI-DAQ 7.4
    If the problem persists you may want to uninstall and reinstall LabVIEW and then NI-DAQ in that order. The error message will usually give an indication as to which VI the error occurred in. Please let us know which VI is failing if you're unable to avoid the error with these suggestions.
    Have a good day-
    Tom W
    National Instruments

  • Signal express tc calibratio​n to daq assistant calibratio​n

    I ran some calibrations in Signal Express for K-type thermocouples. I didn't realize that those calibrations don't carry over to other NI programs. I would like those same calibration values to be used in the DAQ Assistant, rather than completing all my calibrations over again. Is there a way that LabVIEW can grab the Signal Express calibrations and use them?

    Hi Jdezman,
    I will try and help you with this aspect of hardware calibration.
    NI-DAQmx will allow you to do a system calibration. Once creating your task in signal express, there will be a 'Calibration' tab under the 'Thermocouple Setup'. This will direct you to the 'Calibration Wizard'. This Wizard is the same in both Signal Express and the 'Measurement and Automation Explorer' (MAX).
    There is a KnowledgeBased article which will guide you through this process:
    http://zone.ni.com/devzone/cda/tut/p/id/4224
    Hope this helps with your system calibration. Please let me know how you get on,
    Regards,
    Aaron. E
    Applications Engineer Team Lead
    National Instruments
    ni.com/support

  • Linear search between two arrays

    I'm having trouble with the comparison of an array of football teams and an array of team names that may or may not be in the football team array. I have read both .txt files into their own arrays and parsed the team array with substring in order to isolate the team name. I know I can read both the search array and the team names individually because I tested it with a println. I think my problem is in the comparison "if" statement.
        public void seqSearch()//Sequential(linear) search
        int j=0, s;
        //int m = j+1;
            for(s=0; s<searchSize; s++)//increments through the search array
              for(j=0; j<teamArray.length; j++)//increments through the team array
               if(teamArray[j].getName().equals(search[s]))//I think this is where the problem is
                   System.out.println("Found " + teamArray[j].getName() + "after" + j + "searches.");
                   break;                 
               else
                   System.out.println(teamArray[j].getName());//prints through all of the names during each search for testing
                   if(j == teamArray.length-1)
                       System.out.println("Can't find " + search[s] + " after " + j + " searches");
            }//end for
        }//end seqSearch()My output prints the names of each team on their own line and at the end it always says that it can't find each search term.
    Ex.
    Bears
    Bengals
    Bills
    Vikings
    Can't find Bills after 32 searches
    Bears
    Bengals
    Bills
    Vikings
    Can't find Eagles after 32 searches
    etc
    I though that .equals was the way to compare in this situation. Any idea what I'm doing wrong?

    Dave,
    teamArray[j].getName().equals(search[s]))what is the implementation class which is returned from "search[s]" and from "eamArray[j].getName()"
    if both of them are java.lang.String then us "equalsIgnoreCase" instead of "equals"
    if the implementation class is different, then you have to override the equal method and implement your own.
    Regards,
    Alan Mehio
    London, UK

  • Trial Balance between two effective_date

    HI,
    i am new to OBIEE. i have to create Trial Balance between two effective_date.
    filter should be: from effective_date: date1, to effective_date: date2.
    report should show following columns:
    company (group by this column), sum(accounted_cr) between date1 and date2, sum(accounted_cr) to date1 (like opening balance).
    i made repository file. but i can't filter as i need. could anyone help me?
    Thanks
    Sebuhi

    na

  • DAQ Assistant: Clock Settings (Samples To Read, Rate) can affect signal readings?

    Dear all,
    I'm totally new to Labview, and recently I get confused with the equipment I'm dealing with.
    Technical details:
    The Labview version is 7.1; computer operate system is Windows XP;
    The equipment has a NI PCI-6220 and a 68 Pin Connector Block to read signals from the equipment;
    There are 4 channels in DAQ Assistant (2 pressure reading, 2 temperature reading);
    For the first pressure reading, Signal Input Range from 4m to 20m Amps;
    Clock Settings are Samples To Read = 5, Rate (Hz) = 20.
    Description of the problem:
    I use Labvew to monitor and record pressure readings and temperature readings. The Labview configuration was set up by my advisor several years ago. Recently, I found the pressure reading vibrated a lot; for example, 5.01 to 5.05 bar within a second. In order to get a stable pressure reading, my advisor suggested me to change "Clock Settings" in DAQ Assistant from Samples To Read = 5, Rate (Hz) = 20, to Samples To Read = 250, Rate (Hz) = 1000. In this case, she believed that since we increase sample numbers and sampling rate, we could have more data, and thus have stable pressure readings.
    At first I could have very stable pressure reading. The last digit (0.01) did not change within 20 seconds. However, somehow after a day the pressure reading became unstable and even worse than previous. (pressure reading vibrates from 5.01 to 5.30 within a second)
    This is not the worst case. We found that when we set Clock Settings: Samples To Read = 5, Rate (Hz) = 20, the pressure reading is about 8 bar. However, when we set Clock Settings: Samples To Read = 250, Rate (Hz) = 1000, the pressure reading is about 5 bar. In this case, we even don't know which pressure reading is correct.
    Labview records current, and transforms it into pressure reading. Thus my advisor tried to monitor the current reading by Labview, and she found the current reading changed when she changed the Clock Settings. (0.004 Amps (5 bar) when Samples To Read = 5, Rate (Hz) = 20; 0.005 Amps (8 bar) when Samples To Read = 250, Rate (Hz) = 1000)
    Since we only change the sample numbers and sampling rate, the average readings should still be similar. However, the reading are not similar. That is what confuses me.
    My questions are, if Clock Settings in DAQ Assistant could affect signal readings? If so, how it could affect the signal readings? What is the effect of "Samples To Read" and "Rate (Hz)"? How to determine these parameters to get the true pressure readings?
    Thank you very much for your help. Hope to have some feedbacks from you.
    Best regards,
    Cheng-Yu
    Energy and Mineral Engineering
    the Pennsylvania State University

    A 6220 cannot read a current, it can only read a Voltage, so you'll probably have some (or should have) a resistor accros the voltage input. (normally 50 Ohm for a 0-20 mA signal).
    My first step would be to measure this voltage with a multi-meter so you know what the actual voltage should be.
    Then I would read that same voltage with MAX (measurement and automation explorer) to make sure you have the right value
    Now about the changing of the voltage/current/pressure, how have you terminated the other signals? Have you provided a good earthing?
    If you sample with a high frequency (1 kHz), perform an FFT on the acquired data, I can imagine a dominant 50 or 60 Hz (depends on where you live) in the signal that might cause your problem.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Where can i find labview signal express DAQ assistant at?

    Hi, i need help
    Q1) where can i locate Labview signal express DAQ assistant at?
    Q2) Is Labview signal express functions same as Labview 8.6 ?

    LabVIEW Signal Express and LabVIEW are two different products.
    If you are talking about the DAQ Assistant, then you need to have the latest DAQmx driver installed and you should be able to find in the Measurement I/O palette on the LabVIEW Block Diagram.
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • Better estimation of phase difference between two signals with variable frequency!

    Hello LabView Gurus, 
    Being a power engineer and having just a little knowledge of signal processing and labview, I have been pulling my hair out for the last couple of days to get a better estimation of phase difference between two signals.
    We have two analog voltage signals; 1. sine wave (50Hz ± 1Hz) and 2. a square wave with exactly half of sine wave frequency at any time.
    At the starting point of operation (and simulation/acquisition) both signals will have no phase difference. However, the square wave's frequency changes unpredictably for a just a few millisecond but then it gets synchronized with sine wave's frequency again. This means that the square wave will be phased out from its original position. The task of the labview is to find the phase difference between the two signals continuously.
    My approach to determine the phase difference is to measure the time when sine wave crosses zero amplitude and the time when the very next square wave changes amplitude from zero volts to +ve voltage (I have a 0.5volts threshold just to avoid any dramas from small line noise). The difference between these times is then divided by the time period and multiplied by 360 to get this phase difference in angles. 
    As this part is just a small block of a big project, I can only allow 5000Hz sampling rate each for both signals. I read 500 samples (which means I read data from 5 cycles of sine wave and 2.5 cycles of square wave).
    Now the problem is, as long as the frequency of sine wave stays constant at exactly 50Hz, I get a good estimation of the phase difference but when the frequency changes even a little (and it will happen in the real scenario i.e 50Hz ± 1Hz  and the square wave's frequency is dependent of sine wave's frequency), the estimation error increases.
    I have attached my labview program. From front panel, you can set the phase of square wave (between -180 and 0) and you should see the labview's calculated phase in the indicator box named 'Phase'. Then you can press 'Real Frequency' switch that would cause the frequency to change like it would in real operation.
    You can observe that the estimation error increases after you push the button. 
    All I need to do is to reduce this estimation error and make it as close to the actual phase difference as possible. Any help would be greatly appreciated.
    I am using LabView 2009 for this task.
    The application is for electric machines and the stability/performance of machines under different faults.
    Thank you for reading this far!
    Regards,
    Awais
    Attachments:
    v603.png ‏320 KB
    v603.vi ‏186 KB

    Jeff Bohrer wrote:
    Basic math gives me a bit of pause on this approach.  You are sampling at 50 times the frequency of interest so you get 50 samples per cycle.  your phase resolution is 1/50th cycle or 7.2 degrees +/- noise.  You will need to samlpe faster to reduce phase resolution or average multiple readings (at a time cost that is signifigant)
    Jeff- (Hardly Working)
    I am sampling at 100 times the sine wave's frequency and 200 times the square wave's frequency.  Increasing the sampling rate completely solves my problem. But since I am acquiring several other inputs, I cannot afford a sampling rate higher than 5kHz.
    F. Schubert wrote:
    I'm not a signal processing expert, but here my basic understanding.
    If you simulate sampling with 5kHz and a frequency of 50 Hz (and both are 'sync' by design), you always get an exact 5 periods. Any variation of your signals frequency gives you a propability to get 4 or 6 'trigger' events. That's an up or down of 20%!
    The one measure to reduce such problems is using 'window functions'. They don't fit your current approach (counting instead of a DSP algorithm), so this needs to be reworked as well.
    My approach would be to use the concept of a Locki-In amplifier. You need to phaseshift your ref-signal by 90°. Then multiply your measurement signal with the ref signal and the phase shifted ref signal. The obtained values for x/y coordinates of a complex number. Calculate the theta of the complex number (with the LV prim). Feed this in a low pass filter.
    The trick on this is, that the square wave has harmonics in it, in this you are interested in the second harmonic which is the sine wave.
    To get rid of the effect that the sync between sampling rate and ref signal frequency gives an error, you then can use the window I mentioned above (place it before the lock-in).
    For a design that really plays well, use a producer-consumer design pattern to get the calculations done in parallel with the DAQ.
    I suggest you to check on wikipedia for some of the keywords I mentioned. Go also for the external links which lead to great tutorials and AppNotes on the signal processing basics.
    Sorry, it's not a simple solution I offer and we will have quite some conversation on this forum if you follow this path. Maybe someone else knows a simpler way.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml
    An interesting view. the sine wave can indeed be looked as a second harmonic of the square wave. I will implement your idea and get back to you as soon as I get some results. But since I have very limited knowledge of signal processing, it might take me a while to get my hear around the solution you mentioned.

  • How should I set up my VI so that I can use the linear fit coefficient data analysis program, when my values are coming from while loops within a sequence structure?

    I'm attempting to create a calibration program, using the printer port, and a Vernier Serial Box by modifying a calibration program designed for the serial box.
    There are six calibration points, and to collect them, I have it controlled by while loops so that the numbers are taken when a button is pushed, and this is inside a sequence structure so that I can get the six different points. I feed these numbers into two different arrays (for x and y values) and then try to use the linear coefficient analysis on these points, but the values for the slope and intercepts it returns are not correc
    t.
    If I cut out the array and coefficient analysis, and feed the same numbers in directly without the while loop and sequence structures, it produces the proper values... I don't know why the numbers it is producing are different, and I'd really like to know.
    Thanks,
    Karinne.

    I would use a data manager sub-vi that would be called by each from of the sequence structure that produced a data point. The data manager sub-vi could auto append new items or could place items in a specific entry of an array. Later on when you want to calculate the linear fit, call the sub-vi to return the array of values.
    Stu

  • If I have an airport extreme and a time capsule is it possible for seamless switching between the 2 when a signal is weak or drops Main reason is as I move from my first floor to my attic office and would like to place one (airport extreme)downstairs and

    If I have an airport extreme and a time capsule is it possible for seamless switching between the 2 when a signal is weak or drops
    Main reason is as I move from my first floor to my attic office and would like to place one (airport extreme)downstairs and time capsule upstairs to get complete coverage

    In theory, yes. If you configure the two base station into either an extended or roaming network configuration, you should be able to walk a laptop between routers and the laptop should attempt to connect/reconnect to the base station providing the stronger signal ... but, in reality, this is not always 100% true.

  • How can i compute the time elapsed between two pulses or the period of an encoder signal if I dont have a constant rpm?

    I need to compute the rpm of an engine using information from an optical encoder attached to it. the engine is running in transient mode so the encoder pulse doesnt have a constant frequency. I need to get the period betwwen two rising or falling edges using DAQmx.
    Any ideas?

    Using an M Series or TIO device you can measure the period between two edges (on two different signals) using the two edge separation measurement.  I'm assuming that you don't want to use position measurement because the frequency is varying so much?  If not, you may be able to set the sample clock period short enough that you get a decent average RPM measurement.
    gus....

Maybe you are looking for

  • G5 Mac Tiger 10.4.11 w/Itunes 8.2.1(6) can't access store; wants me to download itunes 10.3 which isn't for Tiger

    Itunes 8.2.1 (6) won't let me into the store - it keeps offering me an upgrade to itunes 10.3 which isn't for my G5 Tiger 10.4.11 system.  Anyone know why?  I've already turned off "Check for Software Updates".  Sure appreciate your time with my prob

  • Where all downloaded messages are gone?

    I am new user of iPhone 3G. I managed to download all email messages. But yesterday I switched my phone off and when I switched it back no message was in the in-box. Do I need to re-download all messages again? What has happened? Is it normal functio

  • Coping originating document no.in VF01

    Hi, While creating invoice (i.e VF01)  when u scroll to right at item level u will find three columns in the end which are as follows: originating doc  (It is taking Sales document no.) Sales doc        (it will take sales document no.) Reference doc

  • Using Output in CS5 reducing quality?

    I have 2 pdfs that I'm trying to combine with Bridge Output to become a 2 page PDF. The 2 pdfs are 3.8 and 3.3 MB, and even though I set quality to "full" the resulting PDF is around 300 KB. How can I combine them without compressing them? EDIT: I do

  • HT201302 How to move photos from a folder onto the Camera Roll for printing?

    I have a folder of photos that I imported to my iphone4, I want them in my Camera roll instead of in the folder so that I can get them printed. How can I do this? All the digital printing places here will only link to the camera roll, not to the fold