Discussion:
how to check and control the PWM in usb 6008
(too old to reply)
Luke G
2007-06-20 16:10:14 UTC
Permalink
Hi Jex,
I'm not sure I understand what you are looking for.  You said that the problem with the other thread was that it was "designed under LabVIEW."  Are you trying to program in a different language? 
The thread that Dennis pointed you to should get you started with the programming.
As far as checking the output, you can always route the signal externally to another input and measure the signal.  I'd recommend measuring it with a counter task.
Luke G
2007-06-20 16:40:15 UTC
Permalink
Hi Jex,
Yes, changing the time delay should change the pulse width of the signal.  It sounds like that should work for you.  Let us know how it goes.
Luke G
2007-06-20 17:40:16 UTC
Permalink
I'm sorry jex, I was incorrect in my previous post.  Pulse width modulation requires a constant period, so you won't want to change the time delay.  You will change the pulse width by simply changing the duty cycle.
For your application, you can have an input DAQ Assistant reading your analog input and use a custom scale to convert the voltage to a desired duty cycle.  Then replace the duty cycle control in the example program with the scaled output.  You could probably leave the rest of the code the way that it is, as shown in the image below.
 
<img src="Loading Image..."> Message Edited by Luke G on 06-20-2007 12:37 PM


modified_PWM_example.JPG:
http://forums.ni.com/attachments/ni/170/254278/1/modified_PWM_example.JPG
Luke G
2007-06-29 21:10:08 UTC
Permalink
Hi Jex,
I'm not sure what you are trying to do with the example code that you attached.&nbsp; Your code isn't interfacing with any hardware, and the period of your output signal is not constant.&nbsp;
&nbsp;
The DAQ Assistants in my code were to read the signal from your fan and write to the controller.
&nbsp;
I configured the first DAQ Assistant to acquire an analog signal.&nbsp; The DAQ Assistant would be configured with a custom scale to convert the measured voltage to the corresponding pulse width.
&nbsp;
The two For Loops and the Build Array function build an array of high and low values that are written to the second DAQ Assistant that outputs a digital waveform.&nbsp;
&nbsp;
Arrays in LabVIEW are essentially the same as any other programming language.&nbsp; They are allocated space in memory and they store a series of values.
&nbsp;
After reviewing your original project description, I see that you want to read a PWM signal and output a PWM signal.&nbsp; I wrote that example for reading an analog signal and outputting a PWM signal.&nbsp; To be honest, I do not think that the 6008 is a suitable device for this project.&nbsp; The digital lines of this device must be software timed (which is very slow compared to hardware timed) and it has only one counter input (which is not enough for a pulse-width measurement) and no counter output.&nbsp; For this type of application, I would recommend considering a device that has two counter inputs and two output counters.
&nbsp;
Please let us know if we can offer an more help.&nbsp; Good luck with your project.
Luke G
2007-07-02 18:10:13 UTC
Permalink
Hi Jex,
&nbsp;
The I32&nbsp;icon is a "To Long Integer" function that converts the dynamic data to a long integer.&nbsp; The dynamic data needs to be converted because the dynamic data that is generated by the DAQ Assistant contains a lot of extra information that can not be manipulated mathematically.&nbsp;&nbsp;
&nbsp;
The n high points need to be set high because that is the portion of the square wave that is "on" or high.&nbsp;
&nbsp;
Please note that the example that I&nbsp;posted is only a slightly modified version of the example program PWM_6008 which was attached to the discussion that Dennis pointed to in his first post.
&nbsp;
Please let us know if you have any further questions.
Luke G
2007-07-07 21:11:20 UTC
Permalink
Hi Jex,
&nbsp;
After reading your most recent question, I think I should state again that this device is insufficient for this application.&nbsp; Keep in mind that every cycle of your program requires an analog data point to be acquired and processed before a digital output can be updated.&nbsp; I assume that you are using a Windows system.&nbsp; Windows makes no guarantee for its own latency.&nbsp; In my experience, nothing in Windows happens in less than 3 milliseconds.&nbsp; If you require an update rate of 1000 Hz, you will need a latency of&nbsp;much less than 3 milliseconds.
&nbsp;
Please let us know if there is anything else that we can do to help.
&nbsp;
David L.
2007-07-09 22:10:10 UTC
Permalink
Jex,




&nbsp;Regarding your first question, if you multiply by 1000
instead of 100, this creates a bigger array along with having to output that larger
array. The while loop will finish all code inside of it before stopping, so it
sounds like the while loop is doing just that after you press the stop button.




Regarding your second question, I am a bit unclear to what
you are asking and would like further clarification or description.




Thanks!
Luke G
2007-07-09 23:10:05 UTC
Permalink
Hi Jex,
In response to one of your previous questions,&nbsp;the extra information that is passed with the dynamic data includes time and timing information.
&nbsp;
It sounds like your output stays at 5V because your program stops while the digital output is high.&nbsp; If you need to guarantee that the output be 0V after the program runs, you can create digital task at the end of your program that writes a zero to the output.
&nbsp;
David L.
2007-07-10 14:10:10 UTC
Permalink
Jex,




LabVIEW comes with many great shipping examples (Help
&gt;&gt; Find Examples &gt;&gt; Hardware Input and Output &gt;&gt; DAQmx
&gt;&gt; ?Digital Generation? or ?Digital Measurement? ) or once in the example
finder, you can limit the examples to only view the ones which will work with
your 6008 (see picture).<img src="Loading Image...">
Message Edited by David L. on 07-10-2007 08:50 AM


Example Finder.JPG:
http://forums.ni.com/attachments/ni/170/257947/1/Example Finder.JPG
Dennis Knutson
2007-07-12 14:10:05 UTC
Permalink
You have auto-indexing enabled on the wire leaving the for loop. This is the default behavior of a for loop so right click on the tunnel and change it. Constants are on the different palettes. For example, there is an array constant on the array palette, and true/false constants on the Boolean palette. You can also right click on a functions input and select Create&gt;Constant.
You should spend a little time learning these LabVIEW basics. A good place to start is <a href="http://www.ni.com/academic/lv_training/how_learn_lv.htm" target="_blank">http://www.ni.com/academic/lv_training/how_learn_lv.htm</a>.
Continue reading on narkive:
Loading...