How can I vary a PWM´s duty cycle inside a while loop?

Hi,
I'm using the "Generate Pulse Train.vi" to generate pwm signals in counters 0 and 1 in order to drive a DC motor both ways.
The problem is, I need to control the movement of the dc motor with my PI controller which is inside a while loop. I've tried letting the "generate pulse train.vi" outside the while loop, but the problem is, it only changes the value of the duty cycle when the loop is stopped. I also tried putting it inside the loop, but then it doesn't even work.
So, how can I vary a PWM´s duty cycle inside a while loop?
I'm attaching the VI with the PI controller.
Thanks for your help!
Guilherme
Attachments:
controleValvula.vi ‏332 KB

Here's some code I threw together a while back to change a duty cycle on the fly. It generates a fixed 5KHz or 25KHz frequency depending on laser selection, then allows duty cycle to be changed continously. Maybe you can use the premise of it for your application.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Attachments:
Pulse_Width_Modulator.llb ‏197 KB

Similar Messages

  • How can I reset the value of an indicator in a while loop, from another synchronous while loop?

    I am running 2 synchronous while loops, one which is keep track of time, and the other is measuring periods. In the while loop that is measuring periods, I have a boolean indicator displaying whether the signal is on or off. My problem is that when the signal is off, the VI I use to measure the periods is waiting for the next signal, and displays the boolean value from the previous period measurement. While this VI is waiting, I want the indicator to display false and not the value from the last iteration of the loop.
    I am using LV 5.1 for MAC.

    Two things you can try:
    In preface to the first, the most common (perhaps ONLY) use of local variables should be in transferring data between parallel loops. This is a matter of discipline, and creates programs that are easier to understand, take less time and memory, and are just plain cleaner. Having said that, to transfer data between loops, use a local variable.
    Second solution: Instead of setting the value to false, just hide the indicator in question by using control references (property nodes for prev. version of LabVIEW). Control references are a great way to control items on a dialog or HMI screen.

  • How can i connect FP-PWM-520 8-Channel, 5 or 24 V PWM to computer

    Hi
    How can i connect FP-PWM-520 8-Channel, 5 or 24 V PWM to computer.
    Is it supports for Programmble interface(specially using LABVIEW).
    Give me the details to interface connector hardware and software description.
    Thankq all
    Mahesh. 

    Hi Mahesh,
    It sounds like you are just getting started with using the FP-PWM-520.
    Since you are looking for rather general information I would recommend that you search ni.com for 'FP-PWM-520' and you should find plenty of relevant links.
    Connection info can be found in the Operating Instructions Manual which is linked off of the Product Page.  More general information can be found on the DataSheet.
    As with all other National Instruments products you can easily program
    and control FieldPoint from LabVIEW.  Don't forget to download the
    latest version of FieldPoint (currently NI-FieldPoint Version 4.1 for Windows 2000/XP).
    These links and any other searches should help you find what you are looking for.
    Regards,
    Otis
    Training and Certification
    Product Support Engineer
    National Instruments

  • How can I stream video from my laptop to apple tv while doing a different task on my laptop?

    How can I stream video from my laptop to apple tv while doing a different task on my laptop?  I want to be able to stream a video to my tv while browsing the internet or working on writing on my laptop. Thanks

    You would have to use airplay within iTunes then, unless you want to use 3rd party software (ie Beamer)

  • I have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    Hi fais,
    Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
    You can replace the inner for loop with a while by doing the following.
    1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
    2) Make sure the tunnels you where indexing on with the for loop are still indexing.
    3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
    4) Wire the output of the array size into the new while loop.
    5) Set the condition terminal to "stop if true".
    6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
    7) C
    reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
    8) Drop a "less than" node inside the inner while loop.
    9) Wire your iteration count into the bottom input of the "less than".
    10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
    Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
    I will let others explain how to takle this task using the "case solution".
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How can I get location services to stay on inside?

    I have a WiFi iPad 2 w/iOS 8.1.  I want to use PayPal Here that requires location services in my nursery.  It works fine outdoors but inside our metal buildings with metal roofs the location services do not work (and PayPal Here does not work) even though I am still connected to our WiFi network.  PayPal support is no help.  How can I get location services to stay on inside the buildings?
    <Re-Titled By Host>

    Got to Settings > General > Autolock to set the lock time.

  • How can I see the quantity of battery cycles on Satellite U200-181?

    I have Satellite U200-181, and I use it hard, every. I want to be ready replace my battery, when it will have 400 cycles.
    How can I see the quantity of battery cycles on my laptop?

    You must not see this. You will see that capacity of the battery drops down and will be empty after short time. Nobody say that you will be able to use battery 400 cycles only. Maybe you will be lucky and the battery will have longer life time.
    My Tecra M1 is about 4 years old and still working with original battery.
    Your question is pretty unusual and I am really interested about further comments.

  • How can I view the iMessages that were sent to me while I was out of the country?

    How can I view the iMessages that were sent to me while I was out of the country? They never loaded, but people have told me that they sent me many iMessages while I was gone.
    I figured they would load when I turned on my cellular data, but only my text messages loaded. I would like to see the iMessages I missed because I believe some of them were fairly important.
    I would really appreciate somebody's help!

    As far as I understand with this, iMessage works the same as regular txts.The iMessages are held on the messaging server for 72hrs if it's not picked up by then it expires. So those that you didn't get you will never get. Sorry.

  • How can I turn off the cell service on my phone while traveling out of the country?

    How can I turn off the cell service on my phone while traveling out of the country?

    Airplane Mode

  • 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 to generate a pwm whose duty cycle has to be varied depending on the frequency of the input trigger??

    Sir/madam,
    I am quite new to the Labview FPGA module. 
    I am currently working on an application where i have to generate a pwm to control the ON time duration . The pwm ON time depends on the frequency of an input signal.I want to retrieve the ON time value from a lookup table which contain the duty cycle values for the pwm at different frequencies of the input.This input also has to work as a trigger. The input is pulsed and the trigger has to generate the pwm at every rising edge. I am using a PCI 7831R-  RIO series. I am urgently in need of some help and i have hardly a  couple of weeks before i meet the deadline.
    I am trying hard to learn the basics from the shipping examples but not able to quite make my vi work. 
    Kindly lend a helping hand and i would be very grateful to anybody who can help. Thanks a lot in advance.
    Do ask in case of any clarifications required. I  think i have explained my problem quite well. 

    Hello Manu,
    You can refer 
    Developing a PWM Interface using LabVIEW FPGA or PWM Output with LabVIEW FPGA
    How this helps.
    Best Regards, 
    Hardik Asawa
    AE
    National Instruments  
    Message Edited by Hardik Asawa on 05-05-2010 12:46 AM

  • How can I wire two PWM outputs of Accelerometer into PCI-MIO-16E boad with SC-2043-SG?

    I have been using counter/timer pin since the accelerometer (ADXL202AE, Analog Device) provides about 550Hz PWM signal. The purpose of the project is:
    - To acquire PWM signals with Full cycle(ms) and Posity duty cycle(ms) generated in Accelerometer.
    - To convert the cycles into acceleration value.
    By using counte/timer(GPCTR0_Source) and Trigger(Trig1) on SC-2043-SG board, the signal was obtained.
    However, after converting the PWM signal to acceleration value and plotting with labview on-line, the sampling rate was pretty low (26-28samples/sec).
    Then, I began to doubt that there is a wrong wire connection. Even though I am using one counter/timer pin, the sampling rate
    was low. The purpose of using the acceleration was to obtain two output using two counter/timer pins.
    Could anyone help me wire pins and solve the problem?
    GINO.

    Gino,
    You should definitely be getting many more values in your buffer. You should actually be getting 500,000 values every second because a measurement is being taken for every pulse. I found a couple knowledgebases that describe error -10920 and how to remedy it. One is pasted below and the other can be found through the link.
    But I'm not sure if you're going to be able to fix this problem because you're measuring pulses at a very high rate. What is happening is every time a pulse width measurement is taken it is put into an onboard (DAQ board) FIFO buffer that is 9 samples long. The computer then reads these samples out of the FIFO and into an a buffer that you can see in LabVIEW. I think the FIFO is filling up too fast and the computer is not able to read the data out fast enough. Therefore you are losing samples because they are being overwritten. This is all dependent on your system.
    Here are some benchmarks for pulse measurements:
    The following numbers were derived from a Gateway with 128 MB-RAM and an Athlon 700 for ONE counter of the PCI-6602. The number of counters you are using will affect these numbers.
    Finite Buffer
    Buff Period - 7.25 MHz
    Buff Pulse Width - 7.25 MHz
    Buff Semi-Period - 3.35 MHz
    Continuous Buffer
    Buff Period - 250 kHz
    Buff Pulse Width - 250 kHz
    Buff Semi-Period - 140 kHz
    You should still be getting many more samples than 26 though. Try using this example with a very slow frequency pulse to make sure it operates correctly. Then start speeding up the pulse and determine when you get error -10920.
    Here is an internal knowledgebase that may help you:
    Title:
    After Long Periods of Acquisition with AI and Counters, a -10920 Error Occurs
    Problem:
    A customer has a PCI-MIO-16E-4 and his application is acquiring analog input signals and performing event counting with the buffered event counting mode. The problem is that the buffered event counting is at some arbitrary amount of time (e.g., after 2 days) getting an error with the number -10920. The questions are:
    1. Why is he getting this error?
    2. Do you know how big the FIFO is for this buffered event counting?
    3. When he shares a DMA channel with the floppy controller, how can we make sure they use separate DMA channels?
    Solution :
    Here are the answers to the above questions:
    1. There is probably just some noise on the signal line coming in at some point. The STC is VERY sensitive, so if there is any fast glitching, it will attempt to transfer all of these. This can also happen if the signal does not ramp up fast enough, resulting in double-triggering in the middle region. Use a filter, or a Schmidt trigger*, to clean up the signals. Another suggestion is to use the PCI-6602 with filtering.
    2. There is no FIFO used for the counters. The mMite has its own FIFO, but it is only about 9 samples long.
    3. PCI does not "share" DMA channels. It may technically be the same DMA channel number, but this is just for reference. PCI cards use Bus Mastering. With Bus Mastering, the operating system gives up control of the PCI bus so that the hardware (in this case, our DAQ board) can handle its own data streaming, eliminating the extra step of having the OS monitor the transfers. The DMA channel numbers are just the "channels" that are supported by the mMite chip. You can have 3 PCI cards in the PC, each with DMA 1, 2, 3, and none of them will actually be sharing any resources.
    And another knowledgebase about error -10920
    http://digital.ni.com/public.nsf/websearch/8FB9091CB9BB452B8525642000554799?OpenDocument
    Hopefully this all helps,
    Erick D.
    NI Applications Engineer

  • When drawing with the shape tool in Flash how can I vary the stroke width?

    I created an oval shape and I'd like to vary the stroke width so it's not all just one uniform thickness. However in the Properties window I can only find the uniform stroke width and style options (solid, dotted, hashed, etc...). How can I add some tapering?
    Thank you for your help.
    Sarah

    You probably need to convert the line to a fill and then change the shape of it. .. Modify -> Shape -> Convert Lines to Fills

  • How can i vary the time in adf components according to timezone

    Hello ,
    In my application the time is shown in GMT how can i change it to local time depending upon different TimeZone
    Regards
    Mayur Mitkari

    Hi Mayur,
    I guess this Document will help you in understanding localization concepts in ADF [url http://docs.oracle.com/cd/E15586_01/fusionapps.1111/e15524/ui_localize.htm] http://docs.oracle.com/cd/E15586_01/fusionapps.1111/e15524/ui_localize.htm
    Next time please mention the version of Oracle ADF you are using :)
    Regards,
    Harsha.

  • NI 5105 - Measure PWM Waveform Duty Cycle

    Will the Positive Duty Cycle scalar measurement in the NI-SCOPE software calculate duty cycle correctly on a PWM (pulse-width modulated) waveform?  I have a 400Hz signal that is pulse-width modulated with a 40Hz signal that I need to measure the duty cycle for.  Since this is not a normal, continuous waveform (like a sine wave or square wave) I don't know if the NI-SCOPE software will correctly calculate the Duty Cycle.  Has anyone tried this with success?  I am looking at using the NI-5105 because it has 8 channels, but am open to using other hardware and just multiplex my signals to the digitizer.

    The positive duty cycle scalar measurement should correctly calculate duty cycle on your pulse.  By default, the measurement finds the base and top of your waveform using a histogram of the Y values (there will be peaks in the histogram at the base and top values).  Duty cycle is calculated from the 50% level crossings between these two values.  You must have at least one complete cycle and only the first cycle is measured.
    If that doesn't work for you, there are a plethora of parameters you can change (except for which pulse you measure - it is always the first).  For example, you can set the upper, lower, and level crossing values to specific % or voltage levels.  See the documentation and examples for details.
    If you need to measure the duty cycle of multiple pulses in the same pulse train, there is a LabVIEW function (Pulse Measurements.vi) which allows you to do this.  It uses the same algorithms as the internal NI-SCOPE routines.
    In either case, the measurement is independent of the hardware.  Any NI-SCOPE device will work.  If you have any other questions, let us know.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

Maybe you are looking for

  • Error message when loading a web page

    When I'm online, while the page is still loading I get the following error message : A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete. Script: ch

  • Itunes won't open in windows 7

    I can't get itunes to open on my hp computer using Windows 7 (64-bit) I have downloaded it and tried and it gives me the agreement screen and after I AGREE...nothing happens. I've uninstalled itunes and reinstalled. I attached the ipod thinking that

  • Macbook pro 10.6.8 wont boot up.

    I have an older macbook pro with mac os x 10.6.8 will not boot up the front light comes on but the power botton light dosn't you here the fans running but nothing battery an power supply are good an repaced the ram tryed to boot from a disk an usb st

  • Does Flash Media Encoder pass CC

    We will be streaming a live feed using Flash Media Encoder 2.5. The stream already includes Closed Captions - Does FME 2.5 pass the captions?

  • Need a Single iView Refresh

    Hi Need an iView Refresh  at its own place Business Scenario Have a Portal Page with Layout of 2 columns Column 1  has a Webdynpro iView with drop Down content say Google Yahoo Column 2  has a URL iView with Google web page Now when User selects Yaho