Outputting sine wave to motor -- While loop placement?

I'm having trouble creating a basic Labview program to drive a motor with a sine wave. I'd like to output one sine wave at a time to my motor and look at the response to eventually get a Bode plot. I'm using the Sine waveform VI and I've got a PXI-7358 controller card.
I'm having trouble figuring out what goes in the while loop. I'd like to output, for example, a 10Hz sine wave to my motor. But when I create a VI as shown below (& attached), my output waveform frequency is nowhere near my input frequency. When I type 10Hz I get no movement out. At 10.01 Hz input the motor oscillates at a few Hz, and at 10.1Hz input the motor oscillates wildly. I don't think it's a problem with my motor or my PID settings, because even when I eliminate the motor commands altogether (second figure below), I get the same unpredictable relation between the frequency I type in and the Waveform graph.
It seems that the output waveform depends on some sort of difference between the while loop execution rate and the PXI-7358 command generation rate. It seems to me that the Sine Waveform.vi should be outside the while loop, but in that case the Load Position.flx only seems to grab one position. Is there a good way to have direct control over output frequency of the sine wave?
Attachments:
one_axis_move11.vi ‏20 KB
one_axis_move12.vi ‏12 KB

matthewg,
  Dennis is right, let’s keep this to one forum since it is the same topic of discussion, and I will address some of the issues with your code there.
Chris_G
Sr Test Engineer
Medtronic, Inc.

Similar Messages

  • How to calculate the ratio between the maximum and minimum peaks of the two waves using two while loops?

    hello everyone,
    i'm rai from indonesia
    I have a final project about pulse oximetriy, I have some problems,
    how to calculate the ratio between the maximum and minimum peaks of the two waves using two while loops to calculate SpO2 ?
    My program image can be seen below predicament ?
    Attachments:
    spo2 akusisi data with filter lpf hpf smoot nilai max min ir merah.vi ‏249 KB

    Hi Rai,
    You should post this into the LabVIEW forum rather than Real-Time since this isn't a Real-Time application. Your post will see more replies in the LabVIEW forum. 
    As far as your question is concerned, you can write the max and min from the respective loops to a local variable to send the data out of the loops to a third loop or just do the calculation in one of the loops. This would be ideal if you're trying to do this while the loop is running. 
    -Jayk
    Applications Engineering
    National Instruments

  • Unable to read the frequency from this output sine wave of amplitude VS time

    my programe reads through a labjack programe works up until the LJ stream graph process reads to "scaled data v's seconds" graph.where it outputs a sine wave (amplitude vs time)
    for some reason the "freq. amp." analyser won't read the frequency correctly. when i run the programme it outputs a frequency of zero.
    note: the amplitude is reading correctly
    see both programmes attached..................
    Attachments:
    problem.vi ‏77 KB
    LJstream_graph_processing.vi ‏46 KB

    I don't really see the utility of this VI, however, the variable "scan rate", of the "LJstream graph processing", it's an arbitrary value, why?...
    What is the idea with these VIs?, tell me more, please.
    Bye.

  • Measuring lag between input and output sine waves...

    Hi,
    I am using a Labview VI to control an array of servo motors, each receiving a sine wave input (with different phase offsets for each servo). I'm using a NI USB-6229 DAQ system to monitor their movement via a wire that I've soldered onto each servo's potentiometer. I've written another VI that recieves both the initial sent signal and the returned DAQ signal and plots both on a waveform chart. Both signals show up on the plot as expected, with an obvious phase shift between them. I'm having problems accurately measuring the phase shift, and I'd rather have an automatic method that gives accurate numerical values instead of a more qualitative visual method.
    So far I've tried to use triggers and peak to peak comparisons, but I've been having problems getting results in real time. My incoming signals are time stamped, if that helps. Is there a quick and easy method to extract phase shift data from two sine waves on a waveform chart?
    Thanks for the help...

    Since I work with lock-in amplifiers I came up with this. I guess it will work in your case. This method has some limitations. It will work up to 180 degree. It also measure absolute phase lag. You can not say if the signal is leading or lagging. But in your case it will always be lagging. I posted a VI showing the method in another discussion. Here is the link. http://forums.ni.com/ni/attachments/ni/170/409516/1/demo_v2.vi. Since your DAQ unit do not have simultaneous sampling you will get a small phase error due to inter-channel delay. This is also true if you use the FFT method. What is your signal frequency and which samplerate do you use?
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Storing multiple Sine waves in one LVM

    Hi all,
    actually i got a very short question. I can't believe that i'm unable to fix the problem by my own... But that's the way it's suppose to be I think.
    The question:
    Just a simple Sine wave in a while loop, connected to a graph. When I run it i see a lot of different Sines in the graph window, let's say 100 sine waves. How can I write this data from ALL THE 100 SINE WAVES to 1 LVM?
    When i store the data right now I only see 1 Sine Wave and not all the waves i've seen in the graph window.
    I hope somebody can help me with this. Cause this is just a simple example of a very complicated programm i'm working on.
    Thanx for spending time on this stupid problem!

    Could you post your VIs?  I am not sure what you are talking about.
    Thanks,
    Bob Young
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

  • Analogy output a 5000 Hz sine wave from DAQ 6015

    Dear Friends,
    I am back again. Today I try to use the DAQ 6015 to generate an analogy output sine wave of 5000 Hz, it shows me underflow warning. I think it is because of the limit of the on board buffer size. However, I would like to ask for some advice from your experienced expert if there is any way I can make it.
    Many Thank
    dan 

    Hi Dan
    Just a few questions before I can help you. Are you using LabVIEW, if so which version. Are you using NI-DAQmx driver, again if so which version. When you receive the underflow warning do you also encounter an error code and description of the warning? Would it be possible to post the message and code in your next post.
    You can setup buffer size and sampling rate via LabVIEW. Using the DAQmx API makes this very easy using the DAQmx Timing.vi
    Kindest Regards
    Yatin | NIUK & Ireland

  • How to obtain a sine wave polar representation?

    i need some hint

    LabVIEW has a polar plot. I do not know if the Base Version has the featur though. Goto functions >> graph >> ctls >> polar plot indicator. This places a combination VI and picture control on the diagram and front panel. The data terminal for the VI is an array of clusters of mag and phase in degrees. You can easily construct the data for a sine wave in a For Loop by bundling 1 with the i and building an array of 360 elements.

  • Does anyone here knows how a while loop works?

    The following code works...
    DECLARE
    zz NUMBER := 1;
    BEGIN
    While zz < 10
    LOOP
    zz := zz + 1;
    END LOOP;
    END;
    If I put a prompt in it like so it does not....
    DECLARE
    zz NUMBER := 1;
    BEGIN
    While zz < 10
    LOOP
    prompt Look THEO I am looping...;
    zz := zz + 1;
    END LOOP;
    END;
    I get the following error...
    prompt Look THEO I am looping...;
    ERROR at line 6:
    ORA-06550: line 6, column 14:
    PLS-00103: Encountered the symbol "LOOK" when expecting one of the following:
    := . ( @ % ;
    I get the same kind of error if I put a create, select or pretty much any other statement than an assignment in the loop.
    Am I to believe that a while loop in SQL*Plus is particular to what kind of statement is in it?
    Any help would be appreciated.

    PROMPT is a SQL*Plus command. If you would like to output text to the screen while looping in a procedure you should use DBMS_OUTPUT.PUT_LINE(). This will also require you to use the following command at the SQL*Plus promptSET SERVEROUTPUT ON;Your code will look like thisDECLARE
        zz NUMBER := 1;
    BEGIN
      While zz < 10
        LOOP
          DBMS_OUTPUT.PUT_LINE('Look THEO I am looping...');
          zz := zz + 1;
      END LOOP;
    END;This will output Look THEO I am looping... 9 times. If you would prefer that it only be displayed 1 time then you can move the DBMS_OUTPUT.PUT_LINE between the BEGIN and WHILE commands.

  • Why does Labview VI pause intermittently during motor control while loop?

    I'm performing some biomechanical testing using Labview to control stepper motor actuators. I have a PCI-7334 controller card and a MID-7604 driver. The testing is run in load control using a while loop that sends a number of steps to the stepper motor that is proportional to the difference between the actual and desired load. The VI intermittently pauses though and sits in active for several seconds (~5 sec to 20 sec). What could cause this problem?
    Thank you in advance for your assistance.

    Without the subVIs it is hard to see what is going on.
    Some general comments:
    1. Block diagrams should be limited to the size of one screen.  Yours is over 4 times as wide as my 27" screen.
    2. Sequence structures should be avoided.  LabVIEW is a datflow language and only rarely are sequence structures required. There is almost certainly a way to write your program without them.
    3. The use of local variables should be avoided.  Again, they have a place but most likely they are not needed in your program. They are prone to race conditions, make extra data copies, and force execution in the UI thread.
    4. Floating point data types are not recommended as case selectors. They will be rounded and coerced to integers.
    5. Learn about the Producer/Consumer Design Pattern and state machines.  
    One possible cause of your slowdown is having the Write to Spreadsheet File.vi inside the while loop. This VI is convenient to use but it opens, writes, and closes the file each time it is called.  I have no way to tell how much data you write on each iteration but as the file grows the OS may need to re-allocate space for the file or fragment the file. These operations can be slow.
    Do you really want to Abort the program in the False case?  This will leave any outputs in the last state they had been set. This could have your motor(s) running, clutch engaged, ...  In programs which control physical hardware an orderly shutdown procedure is usually better: set all outputs to a safe condition, close files, close DAQ tasks, and indicate the status to the user.  Calling Stop allows none of this to happen.
    Lynn

  • Analog input to modulate triggered sine wave analog output

    I'm new to Labview and having trouble getting my app to program correctly.
    I would like to use an analog input (AI) to modulate the amplitude of a
    100 kHz sine wave and output the results to an AO.  This is a real
    time application: the AI will change every few 10's of ms so during one
    "cycle" the amplitude will be modulated many times. Plus, the entire AO
    will be triggered on and off with a digital input TTL trigger. The
    waveform "cycle" will run continuously and so will the AI.
        I've used an example included with Labview to read
    the AI and a separate one to generate the sine wave and trigger it on
    and off, but cannot combine the two together. I assume what I need to
    do is implement a loop properly but when I try I can only trigger the
    AO on and off and the AI does nothing or is static. I assume that the
    vi just takes one point from the AI and uses that to determine the
    amplitude of the sine wave, but doesn't "redraw" the sine fast enough
    to respond to the AI changes.
    Thanks,
    Ethan

    Hal,
    I do not think I have Labview Realtime (unless it comes standard with the full version of Labview ). Do I need to have that? I have a 6251 DAQ board.
    I've enclosed my program- it has the name of the original included program in its file name so you can see that I didn't do much to change it. I made some changes today (to make it non regeneration) but now can't get the AI to read at all. And I have no idea how to modulate the sine amplitude using the AI.
    The sine wave works fine and triggers as needed. The one problem is that the sine wave doesn't end at the same point (phase) each trigger period so during the times between triggers the DC level on the AO is variable (which I do not want). Is there a way to end the sine wave at the same phase (at the zero crossing) while still triggering it with a digital input.
    Thanks,
    Ethan
    Attachments:
    ERB6-Cont Gen Voltage Wfm-Int Clk-Non Regeneration.vi ‏157 KB

  • I want to use the Function Generator VI to send command signals through the NI 7344 motion controller. This will be a closed loop servo valve system. I want to be able to change from say a square wave to a sine wave on the fly. Idea's?

    I am going to run tests that require an actuator to move using various types of arbitrary waveforms such as sine or square. The NI 7344 is hooked to the UMI that is going through a driver for a servo valve. The loop is analog and it is closed. I have played with some of the examples but can't get it to work. I have used the function generator VI to generate a signal but I think I am using the wrong input VI to the motion control board. When I use what I have it moves the servo and then stops. It doesn't continually generate the signal.
    I would love to use the controls on the function generator vi to control frequency and amplitude ect. Any help or pointer would be helpful. Thank you in advance.

    Hello,
    I'm not clear on exactly how you want to use the generated data but I'm assuming they will be used as your target points.
    There's a built-in example for motion called 'One-Axis Contour Move.vi'. This example demonstrates how to provide your target points as 1-D array. All you need to do is to replace the input array with the output of the function generator. In order to have it run continuously, use a while loop. You can further program your application so that it'll change the waveform on the fly by monitoring the user interface but this might be little little tricky as you will need to reset the move and load the new generated points while keeping track of your current position.
    I hope this helps. Let me know if you have further questions regarding this
    application.
    Best regards,
    Yusuf C.
    Applications Engineering
    National Instruments

  • Can we place Analog in Read(AI-RE​AD) Vi inside the while loop for high sample rate like 22ks/s?

    I am using E-series Card for data acquisition.My requirement is to sample the channel, and check the 10 samples for certain condition.both at a time.What should be done can we place the AI-READ vi inside for or while loop for this purpose?

    Hello,
    Yes, you can include the AI Read.vi inside the while loop, you would just need to specify the number of scans to read for every iteration of the loop. Then, after AI Read.vi has read the data, you can do what ever kind of manipulation of the data you would like, before the next iteration of the loop. The one thing to watch out for is what ever manipulation of the data you do, be sure that it doesn't take to long whereas the buffer holding the data starts to back up. That can be checked by looking at the scan backlog output of the AI Read.vi, which will tell you how many scans have been acquired but haven't been read into your program.
    Hope this helps!
    Regards,
    Steven B.
    Applications Engineering, NI

  • How can I output successive sine wave sequences?

    I'm using Labview 8.2.1 and I'd like to output sequences of sine voltage waves to a motor, each sequence being associated with n number of cycles at a given frequency and magnitude. For instance, three 0.5V sine cycles at 1Hz followed by three 0.2V sine cycles at 10Hz - no waiting time in-between and all data saved to a given folder. I've been using the 'Cont Gen Voltage Wfm-Ext Clk.vi' within the example library. I added to that a stacked structure thinking that I could copy-paste the first sine sequence to the next frame - changing only the frequency+magnitude values of the sine wave - but I couldn't get the second sequence to execute. I tried out other options with different timed structures but it was not successful either. My block diagram for now looks like this:
    What fundamental steps/elements am I missing?
    Thanks for your help,
    Thibault.

    Instead of using frames let’s try something a little bit simpler. First your generation is set to continuous so it will never go to the next frame until the first task is done.  
    You have two options to solve this problem:
    1.       You build the waveform the way you want it, and then you start the generation with the whole waveform load into the card. Just need to make sure this will limit the size of your waveform to as much memory you have on your card.  Advantage about this approach is there will not be time gaps between one signal and the other one
    2.       The other option is to start the generation with one waveform stop it and start it over with different specification. Basically what this is what you are trying to do, but you need to change your generation to: “N samples”. One thing to consider about this approach is that your signal will have a gap every time your task is started and stopped.
    Let me know if it helps
    Two point to remember, this is a question that can be answer more correctly in DAQmx discussion forums not, labview and next time if you can reduce the picture width to less than 500 pixels.
    Jaime Hoffiz
    National Instruments
    Product Expert
    Digital Multimeters and LCR Meters
    Attachments:
    Cont Gen Voltage Wfm-Int Clk.vi ‏54 KB

  • Simultaneous analog output 1k sine wave and data acquisition

    Although many topics of simultaneous analog output and input can be found in NI Developer Zone, I have not found a case similar to my project. I'm trying to generate a 1kHz sine wave by using the analog output of NI DAQPad-6070E, and acquire one channel input signal simultaneously. I found most of the examples can not work properly above 100Hz. Any suggestions are welcome. Thank you.
    Jian

    I have sucessfully solve the problem when I observed the increase of
    scan backlog number. Simply increase the buffer size of AI/AO and you
    can make the 1kHz sine wave output and data acquired properly.
    On Tue, 3 Feb 2004 09:03:07 -0600 (CST), jujian wrote:
    >Although many topics of simultaneous analog output and input can be
    >found in NI Developer Zone, I have not found a case similar to my
    >project. I'm trying to generate a 1kHz sine wave by using the analog
    >output of NI DAQPad-6070E, and acquire one channel input signal
    >simultaneously. I found most of the examples can not work properly
    >above 100Hz. Any suggestions are welcome. Thank you.
    >
    >Jian

  • Best fit lines for loops and sine waves

    I am trying to find a best fit line that will work for sine waves and loops (hysteresis loops). I can get the sine wave just fine, but when I switch to a hysteresis it just puts a line across the middle (I assume because of the 2 y values for every x). I am doing data acquisition that will take in both forms and graph them. I tried a polynomial fit and it doesn't work at least the way I implemented it and I tried a few others but it looks like they are all function based. Also, my y values are coming out of a Bessel filter. I don't think this would be affecting anything but I thought I would put it in here incase it does.
    Did I miss one that I haven't tried that works for my application?
    Thanks
    Patrick

    RiversDaddy wrote:
    ... currently I am doing it by looping and reducing the error towards zero to fit the amplitude and phase. (I know the frequency).  If this is what you are looking to do then I will help, or should I be doing things differently? All of the functions I have found to filter or extract tones seem to introduce a larger frequency of phase error than i get using this method, but am I missing something?
    "looping" is a bit vague. What is the actual algorithm to find better estimates (e.g. levenberg marquardt, etc.)
    What problems did you have with extract single tone. Can you show some data where the results from it are not good?
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for