Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency Modulation with DAQ

Hi,

I'm using a 6025E DAQ on a Windows 2000 system with Labview 7.0 to control a stepper motor. To control the motor I am using a counter implementation to generate a continuous pulse train with varying frequency. I used this example which allows for the variation of duty cycle and frequency in real time.

This example seems to work but I periodically receive this error:

Error -200301 occurred at Property Node DAQmx Channel (arg 1) in Pulse Width Modulator-daqmxb.vi

Possible reason(s):
Cannot update the pulse generation property.
The pulse generation with previous property settings must complete a full cycle before the property can be updated.
Task Name: _unnamedTask


It seems that the program is trying to overwrite a counter property before a single cycle has completed. However this error occurs even when i'm not changing the frequency or duty cycle inputs. When I use the cpu for other tasks such as browsing the internet, this problem seems to occur more frequently.

Is there anyway around such a problem? Are there other ways to control a stepper motor with my particular control setup? Thank you in advance.

~Himesh P.
0 Kudos
Message 1 of 11
(4,683 Views)
himesh...


Couple of things I saw after looking at this example.

1. You probably want to go ahead and use the counter write VIs instead of the property node. You don't have to but it might make the code a little more readable.

2. In DAQmx 7.4 there is a new property called Ready for new value. You can query this to see if it is OK to write a new value/update the frequency. The property is found at DAQmxChannel>>CO>>General Properties>>More>>Advanced

I have also sent in a request to have that example updated.

StuartG
0 Kudos
Message 2 of 11
(4,661 Views)
Hi himesh-

I'm not able to see the example you're mentioning- the link is broken. Despite this, it seems like you might be experiencing the problem described in KnowledgeBase Error -200301 When Using Property Node to Update Counter Pulse Output

Please let us know if you have any additional questions.

Thanks,
Tom W
National Instruments
0 Kudos
Message 3 of 11
(4,644 Views)
Hi Stuart,

Thanks for the reply. After upgrading to DAQmx 7.4, the error is less frequent. I used the "Ready for new value" property as well as a check that a new frequency has been entered as the input logic to control whether an update of the frequency is to occur. The error hasn't popped up yet, so I think this probably solved the problem.

Just as a tip for others who need a DAQmx type device to output PWM or a frequency varied signal in Real Time, that the limitation on how fast you can vary the two paramaters are limited by:

1. Your loop delay (obviously)
2. It is also limited by what frequency your counter is outputting at. For instance, at 10Hz frequency even if your loop delay is 1ms you can only update the frequency and or PWM every 1/10th of a second (ie 1 period at 10Hz).

I don't know if an engineer knows whether there is an advanced way around this limitation. Possibly by resetting the counter in mid period.

Again, thanks for the help.

~Himesh P.

(PS. I accidentally rated your post with 1 star, and I wanted to hit 5 stars. It is unfortunate that I can't change my rating)
0 Kudos
Message 4 of 11
(4,644 Views)

Hi,

I've been using the example you linked as a stepping stone to creating a Pulse Width Modulation program that will control a DC motor by means of Pulse postitioning: is there a way to make this setup send a finite number of pulses as opposed to the continous/infinite number of pulses it does just now?

Any help would be greatly appreciated

Thanks,

John

0 Kudos
Message 5 of 11
(4,347 Views)

Hi,

 

You can create a finite pulse train with custom frequency and duty cycle by simply using the LabVIEW example program, “Gen Dig Pulse Train-Finite.vi”.  During the creation of the virtual channel, you can set the duty cycle and frequency before starting the task.  However, these parameters cannot then be modified during the actual output.

 

On the other hand, you could still use a continuous counter output, but use software to stop the task after a certain time period.  For instance, in the example posted above, the frequency and duty cycle can be changed once per second according to the execution timing of the while loop.  Instead of stopping the loop when the Stop button is clicked or when an error is received, consider stopping the while loop after a certain number of iterations, giving it similar functionality to a for loop.  You can include the execution timing, and you will still be able to change the frequency and duty cycle during the output. 

 

If you decide to take this approach, I would recommend using a while loop instead of a for loop because you can include the error cluster as a stop condition – for loops don’t have easily implemented break statements in LabVIEW.  There is a picture of this below.

 

I hope this helps.  Post back if you have any further questions.

 

Ed W.

Applications Engineer

National Instruments

Message Edited by Ed W on 03-30-2007 12:56 PM

0 Kudos
Message 6 of 11
(4,333 Views)
I did something similar using the Analog Output.  See attached.

You essentially vary the sampling rate of the analog output to vary the frequency of the output.  This should be in LV 7.0
Randall Pursley
0 Kudos
Message 7 of 11
(4,313 Views)

Hi,

Thanks for responding so quickly; and thankyou for the suggestion: I've taken the vi and made a couple of small modifations.

As you may have guessed, I'm something of a novice with Labview, so forgive me if this next question sounds stupid!

How do I implement a "Go" button into the program so that when the program is run, the pulses are not generated until the user clicks the "Go" button? I presume a structure of some description is required (case or stacked/flat?), but I can't seem to get any structures to work properly.

Any help would be greatly appreciated,

Thanks,

John

0 Kudos
Message 8 of 11
(4,279 Views)

Hi John,

 

To implement this functionality, you’ll probably want to use an event structure around your code.  The event structure will allow you to execute code when a specific event has taken place.  In this case, the event will be a button press and the code will be your data acquisition.  There is a nice example program that demonstrates this functionality, along with a PPT presentation that goes into more detail about event structures.

 

Using the Event Structure in LabVIEW with a Boolean

 

I would recommend going through the presentation to make sure you fully understand the subtleties of event structures.  Event structures do not follow LabVIEW’s dataflow paradigm, so be sure to not overuse them as it may introduce bugs into your program that are difficult to troubleshoot.

 

I hope this helps. 

 

Ed W.

Applications Engineer

National Instruments

0 Kudos
Message 9 of 11
(4,261 Views)
Hi Ed,
 
Thats perfect, thankyou!
 
One last question: I need to change the state of the outputed pulse depending on the direction I want the motor to rotate: is it possible to configure the the Gen Dig Pulse-Finite.vi to produce a low output state for anticlockwise rotation and a high output state clockwise rotation?
 
Cheers,
 
John
0 Kudos
Message 10 of 11
(4,255 Views)