Problem with Arduino PID control

I want to write a simple temperature control program, using the PID_v1.h library. Unfortunately it seems I don't get any meaningful result, so I tried the example from here:

https://playground.arduino.cc/Code/PIDLibaryBasicExample

When I print the value of the variable Output, it is always 0 (zero).

I don't see any errors in the code I copied from the above example, and it compiles correctly.
In my temp. control program I also get only 0 as output; the temp. measurement I simulate with a potentiometer.

Can someone help with this?

Regards, Hans

I hope this is in the correct subforum...

you didn't give us any usable information. so my magic ball ask s simple question. did you connect the sensor to corresponding analog port?

Post a link to the PIR sensor you are using. Some have settings which may make the use of the PIR library irrelevant for your application. You may, instead of using the library, be able to use digitalRead() in the loop to determine the state of the PIR sensor.

6v6gt:
Post a link to the PIR sensor you are using. Some have settings which may make the use of the PIR library irrelevant for your application. You may, instead of using the library, be able to use digitalRead() in the loop to determine the state of the PIR sensor.

OP doesn't mention a PIR sensor. He has a temperature sensor and a PID algorithm.

Juraj:
OP doesn't mention a PIR sensor. He has a temperature sensor and a PID algorithm.

Oops. Yes. I got the abbreviations mixed up. PID is proportional integral derivative controller.

@OP. If you are using this linked example code , how have you modified the sketch to print the output ? Best is to post your sketch.

Hi gents, thank for the answers.
First I want to omit those talking about PIR sensors.
Then I would like to say that although English is nit my first language, I try hard to give all necessary information when I write about a problem. So the question " did you connect the sensor to corresponding analog port?" leaves me a bit lost. In the linked example there is no sensor. Only a pot is connected to analog input 0, acting as an input to the PID. The setpoint is a constant.

The example code is modifieed as follows:
...
input=analogRead(0);
myPID.Compute();
Serial.println (output);
...

As I wrote, output is always zeroindependent if the input is less or more than the (fixed) setpoint of 100.

As my sketch is on another computer, and it is just the code in the link above, I think it is useless to copy it here again.

Kind regards,
Hans

Explain "pot is connected to port"

Juray wrote:
"Explain "pot is connected to port"

My pleasure!
Pot is an abbreviation for potentiometer, commonly used in my language/surroundings. The slider of that potentiometer is attached to analog input 0. Its purpose is to serve as a simulated measurement, e.g. instead of a temperature sensor.

Kind regards,
Hans

I can not confirm your findings. When I download the version of PID.h available through the library manger, and then run the sketch, I can see output of 0 when 5v is connected to the analog pin and output of 255 when ground is to the analog pin.

What do you see if you add a print out of the analogRead() value to the sketch?

soha6:
Pot is an abbreviation for potentiometer, commonly used in my language/surroundings.

sorry, I forgot that you did write about the potentiometer in your first post.

Ah, now we are getting somewhere...

When I print out the analogRead value, I get numbers between 0 and 1023, depending on the position of the potentiometer slider.
However, and I really don't know why I've never seen that before, when I twiddle the potentiometer (I really try hard to not use that word pot...), then I sometimes see other values in the output. I mean numbers different from zero.
Especially with input=0, output is 255. For inputs around 100 (setpoint), output is between 70 and 90.

Again, I'm really sorry why I didn't see these results before, so I apologise for describing a non-existant problem.
I've seen also that in the examples in the library packages there is one for switching a relais on and off, that's similar to what I want do do with my temperature controller.

Again, many thanks to all giving their best to put me out of that misery...

Kind regards,
Hans