Changing the duty cycle of PWM on during the race

Hello

I am trying to generate a my C Code PWM signal.

It works fine except for the fact that I can not change the operating factor during execution of the generation of PWM signals.

Here's what I do:

//Init DAQmxCreateTask("masterP",&task_pwmout);
DAQmxCreateCOPulseChanFreq(task_pwmout,taskchans1,NULL,DAQmx_Val_Hz , DAQmx_Val_Low , 0.0,freq,duty);
DAQmxCfgImplicitTiming(task_pwmout,DAQmx_Val_ContSamps,1000);
DAQmxStartTask(task_pwmout);

...//Stop DAQmxStopTask(task_pwmout);

It works well, but the duty cycle is fixed.

I tried to change the cyclical report but it seems that the only way it works is like this:

//Init DAQmxCreateTask("masterP",&task_pwmout);
DAQmxCreateCOPulseChanFreq(task_pwmout,taskchans1,NULL,DAQmx_Val_Hz , DAQmx_Val_Low , 0.0,freq,duty);
DAQmxCfgImplicitTiming(task_pwmout,DAQmx_Val_ContSamps,1000);
DAQmxStartTask(task_pwmout);
...
//Change Duty Cycle DAQmxStopTask(task_pwmout);
DAQmxSetCOPulseDutyCyc(task_pwmout,taskchans1,duty);
DAQmxStartTask(task_pwmout);
...
//Stop DAQmxStopTask(task_pwmout);

I have to stop the task, set the new cycle and restart the task.

Unfortunately, it takes some time (~ 100 ms) which means that during this time, the PWM is turned off.

Is there a way to change the smoother operating factor, so there is no gap between?

Thanks in advance.

Christian

Hi Christian,

You are right. Stop a restart of the task is a very slow way to adjust the pulse width. This page describes the option adjust the factor of market during execution by using the function "DAQmxWriteCtrFreqScalar". By calling this function in a loop, after the start of your task, you will be able to adjust the frequency and factor use of your task, simply by changing the settings.

I would like to know if it works for you.

Concerning

Tags: NI Software

Similar Questions

  • updated duty cycle in PWM/PID temperature control

    Hi fellow users of Labview,.

    I control the temperature in a box by reading the temperature (voltage) of a PT100 element and output pulses PWM with PCI 6221 counter to close the circuit of a relay to solid state to power my heating unit.

    Using PID (not quite yet set in the code below), I expect the cycle also adapt according to the proximity we are at the point (i.e. it would be pulse refine put it to not be 50% when sound near the set point, but rather be like 10% so it is not exceeded). Right now my code does nothing at the time when the process variable exceeds the set value (I have the operating factor set to 1E-5 in this case, mainly off the coast, because if I don't do this, the counter always pulse outputs...)

    How to integrate the update of the PWM pulses in my code?

    Thank you!

    HessenMob

    I think I solved the problem.

    As a new person on these forums, I didn't know how to remove my post...

    An updated version is attached below!

    Any thoughts on how to tune the K_p, K_i, K_d settings?

    Thank you

    HessenMob

  • duty cycle PWM of PID.

    I'm trying to find examples of PID controlling the duty cycle of PWM. Is there a simple example? Helps share if you have.

    I coundn't find this topic in the viewfinder of the example


  • How to generate the digital output of the variable duty cycle and clock source being contrary?

    I want to generate a digital pulse every front amount of my pulse counters. He must have a variable duty cycle. until now, I've been able to generate a digital output, but I can't change its duty cycle.

    pls tell how I should proceed?

    Thank you in advance...


  • Change the thickness of a font.

    Hello good evening.

    I have a challenge to change the thickness of a font, I use Illustrator to create the Visual identity or the famous logo.

    The principle is to be one of the easiest, but it became a book challenge. A friend has the identity of his company in the PS, but low resolution, such as an exchange of services, I offered to vectorize on illustrator, got the logo and the police f
    ound a 90% similar, but much thicker thick, it has the original file, to do this in PS this would be a matter of selection > modify > contract and loan , but the problem when I go back to the source for the Illustrator uses the image and the trace of the police is slight distortion.


    Let the challenge, necessary to reduce the weight of the font in Illustrator without losing the features.
    I know only two options.
    1 because it uses a graphite color background and put in the same color and sussa to use the web with applied the same background color is perfect. But if you change the background you need to keep changing the race and soon png or thinking. (This was the solution I found initially)
    2nd trace source in the tool pen and will merge together to form the letters of the name. It will take some work but I'll be able to deliver the logo without restriction and dependence to change this and that.

    I wonder what other options I have to reduce the thickness of this source in the illustration, if you use the PS without problem, but when you open the precise IT sure features to vectorize know only the image option it draw.

    Let the police.

    Source language

    Original.png

    You want

    Desejada.png

    The solution that I found without merits.

    Solução.png

    1. Set the "frame of character', 'None '.
    2. ' Use 'Lag' effect on an attribute of ""fill object "in the appearance Panel.

    Edit:

    In fact, you can assign only the "offset" to the object Type. The character frame is affected.

  • Why can't I change the thickness of the stroke of my form?

    Hello!

    I drew a shape with illustrator, but I can't change the race less 1pt. When I change it to 0, 25pt or 0, 5pt, this does not work, there is 1 pt.

    Any help please?

    I can't change the thickness of 1 pt from the outline below of LUN.

    Thank you.

    Dan,

    In such cases, the first assumption is aligned to the pixel grid.

    You can select the entire document and untick finally align on the pixel grid in the Transform palette and uncheck also align new objects to the pixel grid in the options of the Launcher. It is crucial that the checkbox is disabled completely, not just a - which also count as ticked.

    It may be noted that even align with the pixel grid is cleared with all the selected objects, align new objects to the pixel grid is checked as the creation of new objects will result in these new objects being aligned, even when they are created from existing objects that can happen with Pathfinder operations.

    You can avoid the types of documents with the default (RGB for the web and other) or change the default value for such documents.

    Here is a screenshot of exquisite made per ton in the first post:

    https://forums.Adobe.com/message/7841770#7841770

  • Moving anchor points and the whole shape gets distorted to change the line weight

    I have a fairly simple drawing that I drew in a larger size, so I could be more specific with it, and now I want to reduce up to the finished size and thicken the line, but when I make the line thicker, my anchor points are moving and the whole drawing is distorted.

    Using Adobe Illustrator of 24 years, I never saw that happen. When I click on the "up" arrow in the stroke palette a lot of time to gradually increase the thickness of line, I can watch made anchor 'walk' around like my shape gets distorted.

    If I go to the place a numeric value for the thickness of line, it doesn't.

    However, if I use the scale tool to shrink the design down to the size of 10% or 20%, or whatever, with traits of the scale and effects UNCHECKED, yet once, move the anchor points and the drawing is distorted.

    It's all about a brand new installation of Illustrator CS 6 for Mac (although I use CS 6 for about 2 years now, my hardrive crashed this past weekend and I had to reinstall everything).

    I missed a little box somewhere that I never saw elsewhere that is what actually happen?

    This post editing to add:

    Also, some of these objects in my drawing I cannot change the race less than 1 point thickness. If I choisis.5 ou.25 pt in the context menu, or even if I enter the numeric value, it jumps to 1 point. Other objects in the drawing are not.

    These objects in question are "rounded rectangle" forms I used the scissors tools to cut and then used the "join" command to put them as well as other forms that have been "scissored"as well."

    All forms of "Ellipse" and "Rounded Rectangle" that I have left intact do not exhibit this problem with stroke and distortion.

    You are being bitten by the Align-to - pixel grid. Select the entire document and go to the transformation Panel and turn off snap to Pixel - grid at the bottom of the Panel. Then go into the rollout (small triangle in the upper-right) and disable align objects on the pixel grid.

  • Why does the race partly disappear when I line up outside?

    Hello

    I have a simple rectangle with a gradient, and a race of 1 point.  There are two strange things going that I can't understand: I can't change the weight of the race to 0,5, at least I have change the race to line up outside or inside.  The problem is that when I change the line to align to center align on outside or inside, appeas to race for pushing left and down the path to the large and completely disappears on the low left side.

    Any suggestions would be greatly appreciated.

    Thank you

    Paul

    1. what version do you use? Maybe CS5

    2. what type of document is it? Maybe a web document?

    3. If so, it may be the "Snap to grid of pixels" option turned on (he died in the transformation Panel)

  • Simple question about the race of the Illustrator borders - help please!

    Hello

    I'm new to Illustrator, and I can't understand something.

    I have a simple rectangle with a fill color, say red and a color of outline of us Let's say blue. Then, I use the drop down menu on the horizontal tool bar options change the race of a simple contour to something that looks more like a decorative edge. In CS4, I use the last option on the drop down menu, which has to stroke brain/border corners around the inside of the curve. When I chose this option, the filling remains as a rectangle with sharp corners that 'out' where the accident vascular cerebral/border curve inwards.

    I would like to know how to keep the race/border while getting rid of corners of the rectangle that die. I tried the erasure of the rectangle, but negatively affecting the border/stroke shape.

    Thank you very much for your help.

    David

    There are a few ways (or maybe more) to do. Both involve separating the object into two parts, one with a fill and no respect and the other of a sudden and no fill. Make sure that the trace object is on top and apply the brush line, then lock it. Add and remove anchor points at the four corners to get the below form (magenta rectangle) that will be hidden by the brush line. You can also do it using object > decaying appearance to generate the two forms of the original.

  • Change of the dynamic Cycle for PWM

    Hello people of LabView warned there!
    I'm doing PWM for the servo using LabView.
    I was able to manually move my servo with this: http://www.ni.com/white-paper/2991/en

    My goal is to automate the position of the servo as a movement of sinuisoidal and to do,

    I need to automate the cycle to oscillate in 5% ~ 10% automatically over time.
    I looked into stuff like:

    http://forums.NI.com/T5/counter-timer/PCI-6602-PWM-generation-dynamic-sine-duty-cycle/TD-p/1522442

    But it was not too helpful, that I was getting too error-200301.

    I want to be able to move the position of the servo to ~ 10 Hz, if it's important and the FREQ square to wave the

    servo signal (PWM) must be 50 Hz.

    Any help? Thank you!

    ____________________________________
    Attached, that's what I'm trying to do. The sinusoidal movement of the servo is (supposed to be) really pair upwards with

    a counsel of the BNC-2120 of the analog output. The part of the servo control is separated on the upper part.

    The error occurs on the first iteration of the loop? What is the initial delay value on? If the initial delay is greater than the length of the loop, you can still get this error.

    This is important if you use a (ms) waiting rather than wait for the next "millisecond" several?

    And checking against the local variable duty cycle is still useless. You should check against the previous cycle which was set, not the local variable cycle duty.

  • Strict & Duty cycle value changes - every time

    Hi all

    IM using pcie 6320 to measure the frequency and the use of a signal.i factor tied my vi & data measured for reference. Values in red, is my frequency and duty cycle but values real changes for all the 1 sec. Please correct me if I am wrong.

    You must set the CI. Pulse. Freq.DigFltr.Enable and CI. Pulse. Freq.DigFltr.MinPulseWidth.

    You have selected CI. Freq.DigFltr.Enable CI. Freq.DigFltr.MinPulseWidth.

    These are two different types of task meter entry (although they are called unfortunately very similar to the other).

    Best regards

  • measure PWM duty cycle

    Hi all

    I have never done in time real before LabVIEW and have a pretty simple question.

    I know that there is a measure of pulse width as VI in the palette of waveform and it can be used to measure the duty cycle and frequency of the PWM. My question is, is it necessary to use this measure of vi on a platform time pulse width real (compactRIO, compactDAQ etc...) so that it works? In other words, can I just use normal LabVIEW to measure the duty cycle and frequency of the PWM?

    Is there an alternative to the duty cycle and frequency of measurement without using compactRIO or compactDAQ platform? My concern is because I did no real time programming and the deadline is tight and there is not a lot to invest in learning programming in real time.

    I just want to know the experiences of others who have done it before.

    Thank you

    Yours sincerely,

    chati

    Oh yes RT is not really necessary for sample DAQ of things like that.  If you have a condition like assess each cycle of a PWM, and if the signal falls then to send a command within the period of a cycle, then you want RT or FPGA to respond deterministically.  But if you agree with a bunch of samples taken, then evaluate the data after having been taken then a cheap DAQ card probably will work fine.

    Speed can be a matter of concern.  Lets say you have a square wave of 1 kHz at 50% duty cycle.  If you enjoy at 2 kHz, then you should be able to see that the signal is weak for a sample, then up for a sample and you can determine that the signal is at duty cycle of 50%.  But if you have your wave to the duty cycle of 10%, while most of the time, you will see two samples of low, thinking that it's 0% duty cycle, but then from time to time you will get a top and a bottom and get 50% of reading, who don't agree.

    This is why it is recommended that you enjoy at a rate at least 10 times faster than your input signal.  So if you have an example of signal of 1 kHz to 10 kHz.  Then, if your duty cycle is 10%, you will see a small sample of top and 9.  But even that might not be enough if you need to have more precision to your measurement.  Fortunately, NEITHER sells cheap and expensive material for that.  The hardware cheaper that might work for you is the following:

    http://sine.NI.com/NIPs/CDs/view/p/lang/en/NID/212383

    or perhaps cela

    http://sine.NI.com/NIPs/CDs/view/p/lang/en/NID/212384

    But you probably want to call OR and describe your situation and they can recommend the best material to use if you are not familiar with their offers.  Depending on your situation, you may be able to use an Arduino too.  NOR has a toolbox where it can collect samples and send them via USB.  The sent message can be the rated frequency and the duty cycle, but once again it is quite limited and does not have any help from NEITHER a material point stand, they provide just the box tool.

  • change the frequency of the signal during execution

    Hi, I'm working on a VI to calculate excess of signal I think VI seems to be good (not sure) but now my problem is

    change the frequency during execution, which I am not able to do only when I stop and run the vi frequency changes... pls

    someone help me I tried to put in an event... but no use... maybe iam missing something pls help me...

    I noticed that you have some time a loop around the entire block diagram - I'm not entirely sure why that is.  The way you have your VI wrote that the two inner loops will never come out unless there is an error-'stop' buttons are hidden.  Thus, the outer loop is not do anything for you.

    Once you take it, it is easy to see why you cannot change frequency.  It is defined once, outside of the loops and so never gets checked again.  The best way to resolve this, in your case, is to use registers with shift on the upper loop and check if the value of the frequency has changed since the last iteration.  If so, generate a new waveform and feed DAQmx writing instead.

    See the version annexed to your main VI for what I mean.  (I also replaced the controls to stop with one that is visible and which will stop the two loops without your duty to hit the button abandon.) I'm also an error on the DAQmx read in the loop at the bottom, but I'm sure it will work fine on your equipment.

    See you soon,.

    Michael

  • Get the duty cycle of DAQ to analog voltage input module

    Hello.

    I'm new to labview. I have an analog voltage input data acquisition module. I try to get the duty cycle of a square (generated from a function generator). What is the best way to go about this? When I use the vi to acquire an analog wave cyclical report, the values are incorrect.

    Post your VI as well as real data of your signals so we can see what is happening.

    Lynn

  • PXIe6556 - how to change the voltage of output during the generation?

    I would like to know if it is possible to change the voltage output (data lines) during the generation?

    1. start the generation - Vout = 1V

    2. change of output voltage without stopping the generation of Vout = 1.2V

    3. change of voltage output of...

    TKS

    Try searching for "Advanced: incarceration strategy property attribute ' and ' voltage levels: data voltage range property" in aid of generator/analyzer of signals for the digital waveform installed with your driver. This should allow you to change the levels of tension on the fly. To use this attribute, you must have the latest driver HSDIO (2.0).

    Is that what you are looking for? It is an advanced attribute, and most of the use cases should not dictate it you have been warned. I hope this helps!

Maybe you are looking for