LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

square wave from digital output

Our lab has a usb-6008 device.  I'm curious to know what the highest frequency square wave I can create using one of the digital output lines.

We are trying to control a stepper motor which takes a step every time it stops seeing a voltage.  So the fastest I can make the motor step is equal to the highest frequency square wave I can output from the device.  Problem is that this highest speed is pretty slow.  We are trying to deduce wether it is a the 6008 unit, the usb cable (limitted data transfer), or the computer processor which is limitting the square wave generation.
0 Kudos
Message 1 of 8
(4,089 Views)
It is a limitation of the device and software. Without a timer/counter on board, you have to use a digital output line which is what you are doing. The rate at which you can turn it on and off is a function of how your software is written and what Windows is up to. I would guess you could approach almost 1000Hz. You may want to post your code to see if we can offer up any potential improvements.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 2 of 8
(4,083 Views)
Here is a copy of the code I've written to make the motor go as fast as possible.  I have another vi that allows the user to set how often the voltage goes on and off, but this is the bare bones to see how fast the motor can step.

I should point out that the direction that the motor goes is controlled by whether the motor controller receives a voltage or not (through a different digital output).  The motor is connected to a threaded rod - hence the 'up/down' on the direction control.  And I want the direction to be set prior to the motor starting and not change while the motor is working (which is why the direction is outside the loop).

Message Edited by Mustard on 05-05-2006 02:18 PM

0 Kudos
Message 3 of 8
(4,076 Views)
Mustard,

The main thing is that the Express DAQ assistant VI configures, starts, writes, and closes the IO driver on each iteration of the loop. Either use the regular DAQ VIs or open the Express VI and move everything except the DAQmx Write.vi part outside the loop. This will speed things considerably.

Another thing is that buiding an array inside a while loop will cause frequent memory re-allocations, which can be slow. You always have a two-element array, so this will not be significant, it is something to be aware of in general. If you create a large array of the pattern you want ahead of time and feed it to the DAQmx Write.vi via loop autoindexing, this may run faster than calculating on the fly althoug I suspect that this calculation is not a limiting factor in your case.

Using integer divide and comparing the remainder to zero is about thrre times faster than your calculatiosn. See attached VI.

Lynn
0 Kudos
Message 4 of 8
(4,064 Views)

Hi Mustard,

It's actually OK to use the DAQ Assistant inside the WHILE loop.  The code is written in such a way that the configuration, start, and stop code is only executed once, and the Write is done on every iteration.  If you are interested in seeing how this is done, just right click on the Express VI and choose "Open Front Panel".  This will allow you to view the block diagram being used by the Express VI.  Be careful though, once you open the front panel, the VI is no longer an Express VI (meaning no more pop up configuration window!), and it cannot be converted back.  I'd suggest creating a new VI and DAQ Assistant, and viewing the block diagram of that VI.

As far as your program is concerned, I agree that you are limited because this is a software-timed application.  The output can only be as fast as the loop can iterate and Windows can communicate with the device.  Lynn made some great suggestions on improving the speed of the WHILE loop, which should make the code run a little faster.  However, if you are unable to reach the speeds you need using the USB-6008, I suggest taking a look at the NI motion control products, which were more specifically designed for applications such as yours.  See the following link:

Motion Control - Motion Controllers and Advanced Motion Control Systems

I hope this helps!

Thanks,

Justin M
National Instruments

Message 5 of 8
(4,049 Views)
Thanks for the help.  I'm fairly certain that it's not the speed of the while loop since if I remove the DAQ assistant and replace it with an led, I get guite fast speeds.  So the way I figure it, it's probably either the DAQ assistant that's slowing the loop down or just trying to send the information to the device.  I'm relatively new at using labview so it may take me some time to figure out the inner workings of the DAQ assistant!

In any event, it's not really a big deal because we can just set the motor to a given speed and then control direction and start/stop using labview.
0 Kudos
Message 6 of 8
(4,041 Views)

Hi All,

 

I am trying to use the Motor Control.vi program to run my digital servo. Exactly how would i connect the digital outputs? Do both go into the 'signal" wire and then I program a separate 5V+ generation DAQ-Assistant into the program?

 

Thanks,

Le

0 Kudos
Message 7 of 8
(3,458 Views)

Hello Le,

 

This thread is nearly eight years old and is unlikely to get much attention.  If you have questions on wiring or configuring your DAQmx device I would recommend creating a new question on the Multifunction DAQ forums:

 

NI.com forum: Multifunction DAQ

http://forums.ni.com/t5/Multifunction-DAQ/bd-p/250

 

If possible, you should also post the code you have already written as well as a clear description of the behavior you want and the behavior you are currently seeing.  Letting us know what hardware you are using would also help.

 

What do you mean by "digital outputs"?  What do you mean by "signal wire"?  Are these physical channels or wires on your block diagram? Where did you get "Motor Control.vi" from?

 

Try and provide as much information as you have or are able to give. The more information you provide, the less everyone has to guess at!

 

Regards,

 

Tom L.
0 Kudos
Message 8 of 8
(3,441 Views)