LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ball and Beam (pid to pwm) problem

Hi,

 

I am a college student and I have learned so much from reading these forums but I haven't learned enough. I have a problem where I am reading the ball position from a Sharp analog distance sensor. I am feeding that 1-3 volt into the process variable of the PID controller. I am trying to tune it using ziegler nichols method. I have been struggling with it for too long and I now need some help. I tried to scale the output from my controller by simultaneous equations to keep the PID output within my duty cycle range of (0.045 to 0.1) set at 50 hz for a Futaba s3003 motor. this works until I change the gain and my range from my PID shifts. can somebody help me with this?

i have attached my VI sorry its so bad I am just starting out with all of this and a real newbie!

0 Kudos
Message 1 of 7
(1,140 Views)

Guys,

 

could you explain how to use the output of a pid to control the duty cycle for a dc motor? i know its pwm but how do I keep the output within the range for the Duty cycle?

0 Kudos
Message 2 of 7
(1,051 Views)

Hi Paddy,

 


@Paddyirishman wrote:

how do I keep the output within the range for the Duty cycle?


You can set the output range limits when you use the PID functions provided by NI! (Even the basic PID provides that feature…)

 

Mind to downconvert your VI to LV2017 and attach it again?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(1,041 Views)

First of all thanks GerdW,

I did set my output range limits but my controller goes from end to end of the range really quick. the range for my PWM is tiny (.045-0.1) duty cycle. i have tried to downconvert my vi. hope it works.

0 Kudos
Message 4 of 7
(1,033 Views)

Hi Paddy,

 


@Paddyirishman wrote:

I did set my output range limits but my controller goes from end to end of the range really quick. the range for my PWM is tiny (.045-0.1) duty cycle. i have tried to downconvert my vi. hope it works.


Thanks for the VI, I can open it in LV2017.

 

Your output range is set to [-100, 100]! How does that fit to your requested [0.045, 0.1] range?

Which kind of PWM control do you use when the range is that small? Why only output PWM signals from 0.045% to 0.1% when a PWM usually ranges from 0% to 100%?

Are your PID gains really determined using some well-known principles like Ziegler-Nichols? The integral parts seems very large with its default value of 0.0054min (Ti in PID gains2)!?

 

Btw.:

Why do you need ExpressVIs and DDT wires?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(989 Views)

I had set the output range at (-100 to 100) trying to allow the controller to work within a range because when the range was smaller the output would bounce from min to max output with nothing in between. I am using simultaneous equations to scale the PID output to suit the PWM range.

The PWM range I am working off might be wrong. I am using a Futaba s3003 dc motor and I have set the frequency to 50hz?? I am not 100% if this is correct. but when it's set at 50hz, when the duty cycle is at 0.45 my motor has rotated 90 degrees one direction from center and when I set the duty cycle to .1 it rotates 90 degrees in the other direction from the center.

i have not managed to tune the PID gains yet as my output range keeps shifting etc but I have been trying to tune by Ziegler-Nichols. The Gains values that are in the vi atm are not tuned values.

 

to be honest I was not aware I was using express VIs as I have not learned about them. the wiring was the default that LabVIEW picked. sorry for my lack of knowledge.

0 Kudos
Message 6 of 7
(986 Views)

Hi Paddy,

 


@Paddyirishman wrote:

The PWM range I am working off might be wrong. I am using a Futaba s3003 dc motor and I have set the frequency to 50hz?? I am not 100% if this is correct. but when it's set at 50hz, when the duty cycle is at 0.45 my motor has rotated 90 degrees one direction from center and when I set the duty cycle to .1 it rotates 90 degrees in the other direction from the center.


Ahh, that kind of application…

I found a datasheet, which explains that small PWM duty cycle range. You should set the output range to [0.05, 0.1] and adapt your PID gains to allow finer control of the position!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 7
(981 Views)