Go Down

### Topic: Demonstrating PID loop (Read 804 times)previous topic - next topic

#### Yami89

##### Apr 18, 2017, 11:38 am
I've devised a little idea for a circuit to demonstrate PID loop. Basically the idea is controlling the brightness of a led.

How it works :-
LDR placed in front of a 12V led, first I plot a "curve"(reading from the LDR pin) manually by varying the brightness of the LED using a pot.
Then the curve needs to be replayed automatically-led brightness changes according to the previously saved curve.
The brightness need to stick to the curve regardless of other factors like me  flashing a light in front of the LDR (this is where the PID comes into play).

I would like your suggestion regarding the data plotting and playing it back procedures. So basically Arduino needs to send data to a plotter maybe to processing or excel, and when it plays back processing or excel need to send the data back to Arduino as the set point  for the PID loop and also simultaneously plot the new curve at that moment(so that it could be seen what the PID loop is doing).

Thanks in advance for the help.

#### PaulS

#1
##### Apr 18, 2017, 12:31 pm
Quote
I would like your suggestion regarding the data plotting
Plotting data implies that you have some 2D data to draw somewhere. As near as I can tell, you have some 1D data (the value from the LDR at some point in time). If that defines the y coordinate of a point on the plot, what is to define the x coordinate? Where, exactly, do you intend to draw the graph?

Quote
and playing it back
You can't play back a plot. You can use the data that was used to create the plot, and play that back, but you don't have enough information, or haven't told us enough, to be able to do that.

#### Yami89

#2
##### Apr 19, 2017, 07:19 am
@PaulS- Yes first I would like to plot a graph taken from the LDR reading . So at the X-axis it would be time and then the Y-axis shows the LDR reading values, and then the curve is saved. Lets call this the "LEARN" function where the value is saved.

Then there is the "PLAY" function where the brightness of the LED is varied according to the previously saved curve so the new curve should overlap the previous curve. In the play function the data is send from Processing to Arduino.

Thats the first part.

#### pert

#3
##### Apr 19, 2017, 10:00 am
I like the simplicity of the hardware involved but for the purposes of a demonstration it doesn't seem so good because the response time of the system is so fast compared to other typical PID demonstrations, such as a balance bot. I feel like this it would not be detectable to the human eye how good a job it was doing at avoiding overshoot because at worst it will still be able to hit the setpoint after a few tens of milliseconds of oscillation. I suppose the real demonstration will be from looking at the data after but that's not so dramatic as seeing the PID in action in real life.

#### PaulS

#4
##### Apr 19, 2017, 11:21 am
Quote
So at the X-axis it would be time and then the Y-axis shows the LDR reading values, and then the curve is saved.
Do you know how to get time? Do you know what "time" means on an Arduino? Where do you plan to save "the curve"?