03-15-2012 04:25 PM
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
03-15-2012 05:45 PM
03-16-2012 02:25 AM
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
03-16-2012 03:00 AM
If you have a number of cores a 20% load might mean 1 core is spinning wildly.
/Y
03-16-2012 03:14 AM
@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?
03-16-2012 05:42 AM
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.
03-16-2012 06:27 AM
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
03-16-2012 06:34 AM
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
03-20-2012 03:55 PM
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
04-03-2012 05:00 AM
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