Need arduino coding for PID

I want arduino uno r3 coding since I’m a beginner so I need help. I want to control the temperature using thermoelectric cooler (peltier) and the sensors ds18b20 . The peltier supply is 7.9 and Imax 4A… I have circuit ready to power up the peltier . I just need PID coding with explanation of calculation since I want to learn too . I will be using 5 ds18b20 sensors on different location but one of them I will use for setpoint. So plzzz give me PID coding accordingly :pray::pray::pray:

A quick web search and...

"Arduino PID controller with relay and DS18B20 · GitHub

Sir I need PID formula based coding.

What is your background? How much do you already know about control theory?

The PID controller is one of the most ubiquitous control strategies, it has been covered by countless books, tutorials and articles that you can easily find online.

For example:

On this forum, we usually don't write the code for you, but if you have specific questions, we'll be happy to answer them.

1 Like

Start here

why do you think you need a PID controller to control temperature?

Is this project of yours a school work?

You were given links containing the formulas and example code. You did not ask any specific questions, so there's nothing I can help you with.
Assuming this is a school project, the goal is for you to learn, not to get other people to write the code for you.

Which arguably is a very convenient skill to have.

1 Like

Start earlier in your school work, and plan ahead.

You don’t use a measurement for set point. You use it for feedback to the PID controller. I don’t understand what you mean by PID coding. If you mean the code needed to implement a PID controller the GitHub reference is what you want. If you mean show you how to tune the PID parameters that is something beyond the scope of a forum.

For me learning PID tuning took several days of training and some lab time just to get enough knowledge to tune using trial and error methods. This gave me adequate tuning skills to make a controller settle down. Later in my career I took more courses to learn the finer points of the science.

Check YouTube for tuning methods videos.

Unless it's a management course, in which case, you should be prepared to offer incentives - bonus, medical, dental, pension; that sort of thing.

Actually I’m confused about it. When I put the value for kp , ki, kd so I don’t know what exactly I am doing. Am I changing PID or tunning. If it is tunning so what exactly the meaning of tunning. People maybe misunderstanding me but in real I’m confused. I got the code but can’t understand it :disappointed::disappointed::disappointed:

Changing the “k” values is the tuning. I haven’t read the documentation for the referenced controller but some minimum configurations for all PID controllers are connecting a feedback connecting an output and configuring the controller for increase-increase or increase-decrease action.

Now you may understand how much you don’t understand about process control. There is a reason some people earn a university degree in just that. I spent half a lifetime learning about it. At the end of my career the apprentices were showing me things I didn’t know. We learned from each other.

I cannot condense all of that into a few responses in a forum. You will have to put in the work.

I think you can google

found this
To tune a PID use the following steps:

  1. Set all gains to zero.
  2. Increase the P gain until the response to a disturbance is steady oscillation.
  3. Increase the D gain until the the oscillations go away (i.e. it's critically damped).
  4. Repeat steps 2 and 3 until increasing the D gain does not stop the oscillations.
  5. Set P and D to the last stable values.
  6. Increase the I gain until it brings you to the setpoint with the number of oscillations desired (normally zero but a quicker response can be had if you don't mind a couple oscillations of overshoot)

What disturbance you use depends on the mechanism the controller is attached to. Normally moving the mechanism by hand away from the setpoint and letting go is enough. If the oscillations grow bigger and bigger then you need to reduce the P gain.

If you set the D gain too high the system will begin to chatter (vibrate at a higher frequency than the P gain oscillations). If this happens, reduce the D gain until it stops.

and it links to this

2 Likes

Yup, you just twiddle around with it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.