Go Down

Topic: Using Arduino-PID-Library on Raspbian (Read 151 times) previous topic - next topic

HermannSW

Nov 19, 2019, 09:14 pm Last Edit: Nov 20, 2019, 12:09 am by HermannSW
I got aware of Arduino-PID-library years ago when I did more stuff with Arduinos.
https://playground.arduino.cc/Code/PIDLibrary/
Especially the article series describing in detail the design decisions impressed me:
http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
So it was clear that I would do my first PID project with that library.
Only now I really have to do my first PID controller.

I want to automatically center video on an approach for landing airplane.
I do use this simple stepper PT camera system (just 4 drops of superglue needed):
https://forum.arduino.cc/index.php?topic=647703.0


Later for capturing real airplanes, I will use a 70mm lens.
The small camera is for inhouse algorithm development.
I simulate bright air with white background, and airplane with a non-reflecting black pendulum ball.
A simple P only PID controller basically works for both stepper motors (animation speed 0.25):
https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=252176&p=1568093#p1568093



Because the 20-90fps image processing of Raspberry cameras is done on Raspbian, I wanted to make Arduino-PID-library usable there as well. After an intitial checkin of the unmodified library into my repo, I did commit some glue code in Arduino.cpp/.h (only "millis()" function was needed), and a simple PID_test.cpp that just proves that compilation works, and that millis() and using the library works as well:
https://github.com/Hermann-SW2/userland/commit/05aaed5580c39ac835317b3a771f120c7cf87d4a
Code: [Select]
$ g++ -Wall -Wextra PID_test.cpp Arduino.cpp Arduino-PID-Library/PID_v1.cpp -o PID_test
$ ./PID_test
0
100
70.000000
$


Now I will have to learn how to use the PID library, and how to manually tune PID parameters:
https://en.wikipedia.org/wiki/PID_controller#Manual_tuning


P.S:
millis() returns 0ms on first invocation.
In case you want 0ms correspond to program start, just call millis() as first statement.
αβ, xy & L₁/L₂ positioning systems with two 28BYJ48 stepper motors:
https://forum.arduino.cc/index.php?topic=649769.0
stepper PT camera system:
https://forum.arduino.cc/index.php?topic=647703.0
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Robin2

There is some simple PID code in this link. It may be easier to adapt for the RPi.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

HermannSW

There is some simple PID code in this link.
Much simpler, misses most of the features implemented by by Brett.

Quote
It may be easier to adapt for the RPi.
I already adapted it, see the commit link in previous posting, was easy and works.
αβ, xy & L₁/L₂ positioning systems with two 28BYJ48 stepper motors:
https://forum.arduino.cc/index.php?topic=649769.0
stepper PT camera system:
https://forum.arduino.cc/index.php?topic=647703.0
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Robin2

Much simpler, misses most of the features implemented by by Brett.
But are the missing features of any value?

Quote
I already adapted it, see the commit link in previous posting, was easy and works.
As you posted in the Project Guidance section I had assumed you were looking for advice. The Exhibition / Gallery section is more appropriate if you are just presenting a finished project.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

HermannSW

My fault, you are right.
I asked moderator to move, and now its where you proposed.
αβ, xy & L₁/L₂ positioning systems with two 28BYJ48 stepper motors:
https://forum.arduino.cc/index.php?topic=649769.0
stepper PT camera system:
https://forum.arduino.cc/index.php?topic=647703.0
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Go Up