LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I remove time delay in my motor control system?

I have a system which control the AC motor.

 

I make the code of FPGA and use it in the RT code.

In FPGA code, I make the pulse and read encoder pulse by using while loop.

 

But, when I run this system in my code, the result show the time delay.

 

I'm not sure that the reason of delay is my code.

Is there some problems in my code?  

0 Kudos
Message 1 of 10
(3,682 Views)
Have you used LabVIEWs timing analysis to see what takes the most time? I wonder if its the PID loop?

Also, i don't know the hardware configuration but in your FPGA code, are you trying to read any parameter that is not connected yet electrically?

Kudos are the best way to say thanks 🙂
0 Kudos
Message 2 of 10
(3,653 Views)

hmm.. 

 

Have you used LabVIEWs timing analysis to see what takes the most time?

 

You mean that I have checked the timing for loop?  then Yes.. Loop time is proper.

But there is about 14ms in the result...

 

I wonder if its the PID loop?

 

Yes, I make PID loop

 

 i don't know the hardware configuration but in your FPGA code, are you trying to read any parameter that is not connected yet electrically?

 

No.  In my FPGA code, I write and read parameters, but there is no parameter which is not connected.

 

0 Kudos
Message 3 of 10
(3,639 Views)

One of the glaring issues I see is the autoindexing tunnels you have going out of the timed loop.  That is just ever increasing memory usage, which could be slowing you down (memory allocation is really expensive).  Use a RT FIFO to pass your data to parallel loops that are used for logging.

 

The other potential issue I see is your use of Scan Engine variables.  What is your Scan Engine rate set to?  Going less than 10ms is discouraged, less than 1ms often leads to many issues.  Your Timed Loop is set to 500us.  But what are those values coming from?  Can the module handle the data rate you are after?  If so, then you need to perform the read inside of your FPGA instead of getting the values through the Scan Engine.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 10
(3,636 Views)

One of the glaring issues I see is the autoindexing tunnels you have going out of the timed loop.  That is just ever increasing memory usage, which could be slowing you down (memory allocation is really expensive).  Use a RT FIFO to pass your data to parallel loops that are used for logging.

 

=>  I did not consider the memory for autoindexing..    I will try use RT FIFO.

 

The other potential issue I see is your use of Scan Engine variables.  What is your Scan Engine rate set to?  Going less than 10ms is discouraged, less than 1ms often leads to many issues.  Your Timed Loop is set to 500us.  But what are those values coming from?  Can the module handle the data rate you are after?  If so, then you need to perform the read inside of your FPGA instead of getting the values through the Scan Engine.

 

=> I cannot understand what you said perfectly. Scan Engine variable you mean is I/O for torque?(Please confirm the picture. )   The reason for 500us is to control the motor more precisely. Actually, without that I/O for torque, there is also time delay...    It makes me painful...

RT_Torque.PNG

0 Kudos
Message 5 of 10
(3,601 Views)

@ODONG5 wrote:

=> I cannot understand what you said perfectly. Scan Engine variable you mean is I/O for torque?(Please confirm the picture. )   The reason for 500us is to control the motor more precisely. Actually, without that I/O for torque, there is also time delay...    It makes me painful...


You have AI0 and AI3 to read the Torque_Z1 and Torque_Z3 respectively.

 

But looking over your code again...There is A LOT happening in that Timed Loop.  Perhaps too much.  The reason for this is a Timed Loop makes everything inside it a single process.  So nothing in the loop can happen in parallel.  You might want to consider moving the PIDs into other loops, using RT FIFOs to send the data they need and allow them to write to the FPGA.  I am not seeing much need to make those Timed Loops: just let them spin as fast as data comes through the FIFO.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 10
(3,582 Views)

But looking over your code again...There is A LOT happening in that Timed Loop.  Perhaps too much.  The reason for this is a Timed Loop makes everything inside it a single process.  So nothing in the loop can happen in parallel.  You might want to consider moving the PIDs into other loops, using RT FIFOs to send the data they need and allow them to write to the FPGA.  I am not seeing much need to make those Timed Loops: just let them spin as fast as data comes through the FIFO.

 

I agree that there is a lot happening.. But I don't know how I can solve this problem. 

How do I move PID into other loops?   You mean PID loop in FPGA.vi??  
You mean,  If I use FIFO function, there are little things in Timed Loops? 

0 Kudos
Message 7 of 10
(3,577 Views)

You can read the variables in the Timed Loop and then use RT FIFOs to send the data to other loops.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 10
(3,573 Views)

You can read the variables in the Timed Loop and then use RT FIFOs to send the data to other loops.

 

 

Then, Please check my picture for code design. Is it right?

you mean I should make two more loops by using FIFO??

loop_design.PNG

0 Kudos
Message 9 of 10
(3,545 Views)

1. Not everything needs to be in a Timed Loop.  You should use simple While loops for your consumer (PID) loops.  They will run as fast as they can unless they are waiting for data to come into the RT FIFO.  This is highly desired.

 

2. Why can't your PID loop write the variable directly to the FPGA?  I'm not seeing a point in another loop and FIFO just to write a simple value to the FPGA.

 

3. You only need to open your FPGA reference once.  You can fork the wire to pass it to multiple loops.

 

4. Don't wait until everything is done to log your data.  Do it in a parallel While loop, using a Queue or RT FIFO.

 

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 10
(3,527 Views)