1

I'm new to PID. My goal: control the motor to get it to run a given RPM by a potmeter (which is setpoint). Sensor is optical (detects white line, reflections), counts 100 round in x amount of time. Small calculation gives detected RPM. I'm using an Arduino and the PID library.

Now my question. Let's say I've implemented the PID lib on the arduino. It all calculates and so on, but it gives a PID_value which I don't understand.

Ex: setpoint = 5000 detected = 4999 received PID value = 40

It's my guess that this (or rather: all) PID-lib I'm using always gives a value between 0 and 255 and I have to map/scale that value to my AC trigger. Could someone point me in the right direction? Thanks!

  • Which PID library? Can you post your code? – Nick Gammon Dec 28 '18 at 5:45
1

See PID Library - SetOutputLimits() - you can change the limits.

For a meaningful result you need to make the output do something reasonable to the speed. Since your detected speed is lower than the desired speed, you have found it outputs a positive value, which is good, as far as it goes. But you have to interpret that in the context of what you are currently sending to the motor. If you are using PWM to control the motor you could feed the output (40 in this case) to the motor. If that makes it go even slower hopefully the PID library will compensate.

It's hard to make more suggestions without seeing the code.

  • you, sir, are a genius. Thank you, my brain did stop at #include <PID.h> I will look into the RTFM bit of PID.... – user3810130 Dec 28 '18 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.