LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating a case structure from pid output

Solved!
Go to solution
Hi, I have a vi attached and need to add another case to my case structure so i can adjust the duty cycle of a pwm output with the vi running. I currently have it wired to the duty cycle with a split wire. I can adjust my duty cycle and the temperature changes but adjusting my pid gains has no affect. Can someone please help me out on this as i am totally lost!Everytime i try to add another case i just get broken wires. Thanks
0 Kudos
Message 1 of 14
(3,040 Views)
Can you also post a screen shot or the vi for 8.0?
0 Kudos
Message 2 of 14
(3,039 Views)
Hi, Attached are screenshot and vi save for 8.0, thanks
Download All
0 Kudos
Message 3 of 14
(3,029 Views)
Run your VI with execution highlighting (the light bulb icon in the toolbar) and I think you'll see what's happening.  You only read the values of your P, I, and D controls once when the code first starts, so of course any further changes don't make any difference.  Also, it looks like your PID only executes once, although since you didn't include that VI I can only guess at it.  It should be inside the larger loop that handles the PWM output, as should the P, I, and D control terminals.
0 Kudos
Message 4 of 14
(3,018 Views)

Hey Rebel320,

 

You would need to put your PID VI inside of the while loop so the gains would be updated as the VI is running. 

Andy Chang
National Instruments
LabVIEW Control Design and Simulation
0 Kudos
Message 5 of 14
(3,005 Views)

Thanks for your help guys, I have the pid vi inside the while loop now and ran it with the "highlight execution" The ouput from the PID will still only run at the start and will not update any more after that?

0 Kudos
Message 6 of 14
(2,987 Views)
Did you put the P, I and D control terminals inside the loop too?  Can you post your revised code?
0 Kudos
Message 7 of 14
(2,979 Views)
Yes i put the PID controls inside the main while loop also. Heres the code. Should be save version for 8.0, Thanks
0 Kudos
Message 8 of 14
(2,973 Views)

Moving the PID loop into the while loop solves part of the problem, but there's another one: how do you intend to select between using the Duty Cycle control, versus the PID output?  The way you have it wired right now, the PID output is never used.  When you convert the dynamic data (the output of merge signals) to a U32, it just takes the first signal (the Duty Cycle control) and ignores the second signal (your PID output).  As a side note, dynamic data has to be one of the worst new ideas in LabVIEW, because it allows this sort of confusion.

 

The simplest solution here is to remove "Merge Signals" and replace it with a Select.  Create a new button on your front panel that selects whether to use manual or PID control, and use that as an input to the Select.

0 Kudos
Message 9 of 14
(2,969 Views)

I will give that a try, thanks.I have tried putting in a third case in the small true/false case structure but that wont work.

Thanks for your help, I really appreciate it. Regards

0 Kudos
Message 10 of 14
(2,961 Views)