LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closed loop PID step motor driver trough parallel port.

Hi, I'd just started with LabView. What I am trying to do is to build a step motor driver with closed loop PID. My input and output is a while loop with In Port.vi and Out Port.vi inside that writes and reads boolean data from/to parallel port (input-encoder output-motor driver). While loop speed without delays is about 120khz (measured by logic analyzer). With even 1ms delay it  is 250Hz. Minimal speed that should be ok for my motor and keeping enough acuracy is about 8khz (maximum speed of motor and encoder is about 800hz).


My problem is to convert boolean stream to frequency value for PID input and output from PID to generate frequency in boolean and still keep running read/write to parallel port loop with good speed. Also my encoder is 100 pulses per turn and my step motor is 96 so every 4th of encoder signals is wider than 3 others so i think of measuring average frequency from every 4 last signals to compensate that.

So now I think I should have two while loops runing independently. I have one for read/write to parallel port. Now I am trying to build another one that will handle frequency measure, boolean generator and PID. I have a giant problem about how to do that. In attached IV file I build a very early concept of my driver. I don't even know if this have the right to work. Now I am trying to force the boolean generator to work but I am getting an error and I don't know how to repair it, it seems to me that the square waveform generator is unable to work but I don't know why.

 

I am looking for ideas and advices about that boolean generator and a whole concept of my driver. Perhaps there is a simpler way to do it that I don't know about. I will be grateful for any help.
Regards

 

P.S. Sorry for my language skills, I'm not a native.

0 Kudos
Message 1 of 2
(2,655 Views)

Hi kaczy99!

 

I'm sorry that you had to wait so long for the first answer.

 

First of all I'm really happy you decided to use LabVIEW in your project 🙂

I'm not sure I fully understood you, but I think you want to use this two while loops in parallel. That's what are you doing in this program is completely opposite, because flat sequence structure means that the right sequence can start ONLY when the left is finished.

 

I would advise you to use Producer / Consumer Design Pattern. Here you have short tutorial: http://www.ni.com/white-paper/3023/en/. The producer loop would be responsible for encoder, the consumer one for PID. In that case they would be work completely independent and parallel.

 

Try to rewrite your code and see if it works 🙂

 

If you have any questions or troubles don't hesitate to ask;)

 

Best Regards

Marcin Twardak
Applications Engineer
National Instruments

0 Kudos
Message 2 of 2
(2,596 Views)