LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop slow initially, then normal speed

Hi All

 

Need help!!!! I have a VI which counts the signal from a hall sensor (the signal are generated as a motor rotates). A PID finction reads the hall signals, and stops the motor after whatever amount of revolutions I program it to. The PID function slows the speed of the motor as it approadhes setpoint, by altering the duty cycle of a PWM signal.

I have four while loops in the VI, but one of them, the PID / PWM one, does not run as it should. I have  attached a numeric indicator to this loop, and also to the other loops, to read the speed of the loops. All the other loop act as expected but PID / PWM one runs as follows:

 

For the first 3 seconds, the loop iterates once per second

After the third second, it speeds up to normal speed

 

My CPU performance is only 20% while the VI runs, so this is not the problem.

The PID function is constantly outputting 100% duty cycle during this period (as it should)

 

This particular loop has a lot going on. There is actually two loops, inside a case structure, and then there is the PWM code, which passes through the loops.

The two loops have almost identical code, one loop is for controlling the speed of the motor and distance the motor moves, during normal operation. The other one automatically resets the motor to its home position.

 

Everything works as expected, except for slow loop iterations for the first 3 seconds

 

I have attached a pdf showing what is inside each case of the case structure

 

 

All suggestions greatly appreciated

 

Greg

 

 

0 Kudos
Message 1 of 17
(2,960 Views)

The pdf is useful, but it might be easier for us to help if we can inspect the actual code. Are you able to post the VI?

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 17
(2,949 Views)

Sure no problem, should have attached it the first time

 

Also, meant to include in my first post,  I took the PWM code outside the case structure, but this made no difference

 

Greg

0 Kudos
Message 3 of 17
(2,930 Views)

If you have a number of cores a 20% load might mean 1 core is spinning wildly.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 17
(2,920 Views)

@Greg Flynn 01 wrote:

I have four while loops in the VI, but one of them, the PID / PWM one, does not run as it should. I have  attached a numeric indicator to this loop, and also to the other loops, to read the speed of the loops. All the other loop act as expected but PID / PWM one runs as follows:


 

You are actually running six while loops in parallel, several of them without any timing. Then the entire thing is programmed like a text based program, with tons of hidden indicators and controls, reading from and writing to local variables in parallel and in random oder. Why do you need multiple instances if the same local variable in the same loop? One instance is enough. You are actually allowed to brance a wire. 😉 Shoudn't your case structure be inside the loop instead of vice versa? You are doing a >= and a < on the same inputs (motor running), one comparison is enough, the other output is simply the inverted result.

Sorry, I am on a laptop, so I cannot efficiently inspect your diagram because it is way too big. I have another look at it tomorrow.

 

You say it is running at 20% CPU. How many cores are in your processor?

0 Kudos
Message 5 of 17
(2,915 Views)

 

Thanks for all the advice so far. I have put the case structure inside the while loop and rewired all the local variables. Still no joy with the program do.

 

The spec for my laptop are shown below. I assume from this, it is a single core.

 

Asus K53E 15.6 inch Notebook (Intel Core i3 2330 2.2GHz, RAM 4GB, HDD 500GB, LAN, WLAN, Webcam, Windows 7 Home Premium 64 Bit)
 
I have attached my edited VI below
 
Thanks
Greg
0 Kudos
Message 6 of 17
(2,900 Views)

The mobile i3 is dual core with hyper threading, so 4 logical processors.

 

I cant look at the code here, but i'd wager there's some starving loop running.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 17
(2,892 Views)

As you can see from my post, I am a not an expert at labview or technology in general.

I appreciate your help and hopefully you (or somebody else out there) can come up with a suggestion to solve this problem

 

Many thanks

0 Kudos
Message 8 of 17
(2,890 Views)

Hey Guys

 

Has anyone got any suggestions for me? I have no idea at this stage!

 

Yameada, do you think it is possible that it may still be processor performance, even though only one loop appears to be running slow.

I am going to have my laptop checked for viruses etc.

Is it possible I simply need a higher performance laptop?

 

Is there anything else I can do to improve the performance of the slow PID loop?

 

Thanks

Greg

0 Kudos
Message 9 of 17
(2,850 Views)

HI all

 

I have elimated most of the code in my VI and still have the same problem (see attached VI). The PWM while loop still iterates only once a second for the first three seconds and then runs fine.

This is my last throw of the dice as I have to submit my project soon.

Can anyone see anything in the PWM while loop (main while loop) that could be slowing down the loop initially?

 

Regards

Greg

 

0 Kudos
Message 10 of 17
(2,821 Views)