LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID control of Inverted pendulum using arduino

Hi everyone, first of all i would not class myself as a good programmer so my code is not the best to look and i have probably made loads of mistakes.i also dont have alot of experience with labview.

 

Background:

Im using the labview arduino interface and im trying to control the angle of an inverted pendulum using a PID algorithm. the project is part of my FYP and therefore i want to try writing my own PID algo instead of using a labview PID.vi. now the code for the PID algorithm still needs work but my main question is this.

 

i want to be able to control the range of pendulum angle that the control algorithm will work on. so basically i want to constantly read the angle value, then once inside a specified range the PID algo would kick in. while its not in the range the program will still run and would still be checking the angle. i was thinking of placing a case statement before and outside the PID loop to check the angle, but i think this would only work once at the start of the program. so then i taught of inserting the PID loop and the case statement inside a bigger while loop. so would this be the way to think about this or is there a better way. please all comments are welcome.

 

 

0 Kudos
Message 1 of 5
(4,196 Views)

Hi. You can use the method you suggested and it will work so long as you place both the "read angle" function and the PID algorithm inside the same loop for every iteration of the control loop. Additionally I recommend you to put your VI algorithm in a sub vi to keep your code cleaner, especially if you'll place that in a case structure. You can do it easily by selecting all of the nodes (functions) you use in your algorithm and then going to Edit->Create SubVI.

 

Regards.

 

Aldo

Aldo H
Ingenieria de Aplicaciones
0 Kudos
Message 2 of 5
(4,188 Views)

Hi Aldo, thanks very much for the reply so soon. That's great ill try do that so. Just to be sure I know what you mean by your demo example, is the whole demo example code to be put into a while loop? Maybe I'm wrong, apologies if so.

0 Kudos
Message 3 of 5
(4,173 Views)

Yes, you can do the entire program in a single loop. In your VI you can do it exactly as you originally suggested and just put the entire PID algorithm inside a case structure.

Aldo H
Ingenieria de Aplicaciones
0 Kudos
Message 4 of 5
(4,169 Views)

Thanks very much Aldo i really appreciate the help. i intend also to try to implement a fuzzy logic controller, and then hopefully a neural network approach too. so if i need any assistance on those i will post my problems and progress here. thanks again

 

Regards

Fran

0 Kudos
Message 5 of 5
(4,159 Views)