LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop speed for DAQmx

I am currently doing a project about driving 3D printer by LabView. The first step is to drive the stepper motor by a M-series DAQ 6230. There is some examples on driving stepper motors by DAQmx on the forum, but I find the DAQmx will slow down the while loop. I need to use the while loop because I need to update the square wave frequency from the G-code I input. I hope the while loop can go 1ms every loop. However, I find even with the simplest controller shown in the vi I attach below, the speed is still around 20ms. Is there anyway I can improve the while loop speed?

 

btw, my OS is Windows 7, not real time. 

 

0 Kudos
Message 1 of 5
(2,871 Views)

Did you attach one of the NI Example Programs?  If so, at least tell us where to find it, as a picture of a part of the Block Diagram is frustratingly almost-useless.  Suppose I gave you a picture of a listing of Matlab or C++ code and said "Make this run 10 times faster" -- would you like that?  Didn't think so.

 

Have you studied the manual of the NI-6230?  It's designed to create digital pulse trains of varying types using its Digital Outputs and Counter/Timers.  You say nothing about the requirements of your Stepper motors, nor about the requirements of the pulse trains you need to generate.  So without knowing the parameters of the signal(s) you need to generate, it is difficult to say if the 6230 can accomplish this.

 

What frequencies are you trying to generate?  If you are worried about changing the frequency every millisecond, then I'm guessing the square wave(s) you are generating is on the order of hundreds of KHz.  Right?

 

How many independent channels do you need to generate?

 

Bob Schor

0 Kudos
Message 2 of 5
(2,846 Views)

Hi, Bob,

 

Thank you for your reply. The stepper motor I use is a NEMA 23 stepper motor and I use a Sparkfun ROB-12779 easy driver to drive the stepper motor. The easy driver requires a square wave input and a direction signal and I set the mode to be microstepping. Yes, I want to change the frequency around every millisecond depends on the G-code. Actually, the step function is always below 10kHz. Also, I will try some feedforward control and feedback control after I finish the open loop control. So I think a higher update frequency is preferred. At first, I set the wait time to be 20 ms and this vi works fine. Then, after I set the wait time to 1 ms, I find I only get at most 62 loops done every second.

Below is the vi I use for the test. I will drive four stepper motors (x,y,z axes and an extruder) by NI 6230 and all four PFI DOs will be used. 

0 Kudos
Message 3 of 5
(2,842 Views)

If you arusing all 4 Digital Outputs, and you want them to run independently, I think this means that you have to update the four outputs once per millisecond.  This implies that the maximum frequency of TTL pulses you can output is 500 Hz (1 ms high + 1 ms low, repetetively).  It is a pretty trivial exercise to get DAQmx to output such a waveform using a 1 KHz While Loop, but to simultaneously modulate four channels independently (when the top frequency is 500 Hz) seems problematical (and difficult) to me.

 

You might want to consider a different control scheme, like a series of voltage-controlled oscillators, maybe?  But what do I know, I'm not an engineer ...

 

Bob Schor

0 Kudos
Message 4 of 5
(2,828 Views)

 Hi, Bob.

 

Thank you for your suggestions. I think I have found the problem. The thing is that the 'DAQmx Is Task Done' blocks slow down the while loop. I don't know if I understand it correctly. The 'DAQmx Is Task Done ' is to ensure the program has been finished when you hit the stop button. This block is not critical for my vi because the vi will run for hours and I really don't care how the last step goes. So I just simply delete that block. Now you can see, the loop goes 1000 cycles per second, and the output square wave's frequency will not matter. You can try from 100 Hz to 20 kHz, the while loop will always be 1ms per cycle. I know without 'DAQmx Is Task Done', this may create some problems, but so far I don't see any problem. 

0 Kudos
Message 5 of 5
(2,823 Views)