PID loop with a different command and feedback units / types

In summary: Attenuation is variable with something in the setup other than just distance. Maybe thermal expansion. The linear position resolution is not known, but it is probably not very high because of the distance variation.
  • #1
btb4198
572
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
  • #2
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?
 
  • #4
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.
 
  • #5
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?
 

1. What is a PID loop?

A PID (proportional-integral-derivative) loop is a type of control system used in engineering and science to regulate a process. It uses feedback from a sensor to continuously adjust a control variable in order to maintain a desired output.

2. How is a PID loop different with a different command?

The command in a PID loop refers to the desired setpoint or target value for the output. With a different command, the PID controller will adjust the control variable to maintain a different desired output, rather than the original setpoint.

3. What are feedback units in a PID loop?

Feedback units in a PID loop refer to the units of measurement used by the sensor providing feedback to the controller. For example, if the sensor measures temperature, the feedback units would be degrees Celsius or Fahrenheit.

4. What are the different types of feedback in a PID loop?

The three types of feedback used in a PID loop are proportional, integral, and derivative. Proportional feedback adjusts the control variable in proportion to the difference between the setpoint and the actual output. Integral feedback integrates the error over time and adjusts the control variable accordingly. Derivative feedback predicts the future error based on the current rate of change and adjusts the control variable to prevent overshooting the setpoint.

5. How is a PID loop used in scientific research?

PID loops are commonly used in scientific research to control and regulate various processes, such as temperature, pressure, and flow rate. They are also used in experiments to maintain a constant setpoint and minimize variation in the output, allowing for more accurate and precise data collection.

Similar threads

  • Electrical Engineering
Replies
12
Views
2K
Replies
5
Views
3K
  • Atomic and Condensed Matter
Replies
7
Views
2K
Replies
6
Views
983
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Programming and Computer Science
Replies
1
Views
757
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top