PID loop with a different command and feedback units / types

Click For Summary

Discussion Overview

The discussion revolves around the implementation of a PID control loop for adjusting the position of a laser based on feedback from light intensity measurements. Participants explore the feasibility of using PID control given the differing units of command (motor steps) and feedback (light intensity percentage), as well as the factors affecting laser intensity.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their setup involving a laser, motor, and sensor, and poses a question about how to configure a PID controller when the command and feedback units differ.
  • Another participant questions the necessity of PID control, suggesting that if the attenuation of laser intensity is fixed except for distance, a binary search method might suffice to achieve the desired intensity ratio.
  • A later reply inquires about the nature of the attenuation and its potential variability, asking how fast it can change and how quickly the laser position can be adjusted.
  • Participants discuss the specific motor being used and clarify the target intensity ratio, correcting a previous typo regarding the percentage.
  • One participant challenges the need for servo control, asking what factors might require adjustments after the initial setup is verified, such as thermal expansion or resolution of the position control.

Areas of Agreement / Disagreement

Participants express differing views on the necessity and implementation of PID control in this context. Some believe PID is appropriate, while others suggest alternative methods may be more effective depending on the stability of the system's parameters.

Contextual Notes

There are unresolved questions regarding the variability of attenuation and the specific conditions under which the PID controller would be effective. The discussion also highlights the dependence on the characteristics of the motor and the overall setup.

btb4198
Messages
570
Reaction score
10
I have a laser and I am adjusting it's position using a motor, and I am reading the laser light intensity at the top and bottom using a sensor.
then I divide the top from the bottom and the goal is to get around 0.97%. This is called delta, if delta is too high, you move the motor lower and if delta is too lower we move it up.

now I coded a PID, the program I have my command is in motor steps(position) but my feed back is in light intensity percent.

so how do I set up my PID ? can I even use a PID this way ?

here is my code:
Code:
  GetValue()
  {
 
    PID_controller PID = new PID_controller(2, 1, 0);
  ****
 
  stepsize = (int)PID.UpdatePID(Convert.ToDouble(stepsize), delta);
                 stepsize = changeStepSize( stepsize);
                
                
    ***
                
                 }
    public PID_controller(int Proportional, int Integral, int differential)
        {
            this.Proportional = Proportional;
            this.Integral = Integral;
            this.differential = differential;
             Istate = 0D;
            error_counter = 0;
             lastposition = 0;
        }        double getPTerm(double command , double position)
        {
            double error = command - position;

            Istate += error;
            error_counter++;
            return error;
        }

        double getITerm()
        {
            double Integralvalue = Istate / error_counter;
            return Integralvalue;
        }

        double getDTerm(double position)
        {
            lastposition = position;
            double differential = lastposition - position;
            return differential;
        }

       public double UpdatePID( double command, double position)
        {
            double error = getPTerm(command, position);
            double perror = getITerm();
            double derror = getDTerm(position);
            command = (Proportional * error) + (Integral * perror) + (differential * derror);
            return command;
        }
 
Engineering news on Phys.org
btb4198 said:
I have a laser and I am adjusting it's position using a motor, and I am reading the laser light intensity at the top and bottom using a sensor.
then I divide the top from the bottom and the goal is to get around 0.97%. This is called delta, if delta is too high, you move the motor lower and if delta is too lower we move it up.
What is attenuating the laser intensity to around 1%? Is that attenuation variable with something in the setup other than just distance?

If the attenuation is fixed except for the distance variation, there is no need for PID control, IMO. Just do a binary search on distance to get your best match to the 0.97% intensity ratio. If the attenuation is variable with some other part of the setup, how fast can it vary, and how fast can the laser position be changed?

EDIT / ADD -- And what kind of motor is it?
 
Sorry, there was a typo. It is 97%, but we are working in decimal form 0.97. The laser beam is going through a expansion lens.
 
btb4198 said:
The laser beam is going through a expansion lens.
Why do you think you need a servo to control the position of the laser? If nothing is varying in the setup after the initial position and attenuation are verified, what are you having to correct for? Maybe thermal expansion? What linear position resolution do you have with your setup?
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
9
Views
2K