Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope MODSERIAL QEI mbed
Fork of PI_control_pot by
Revision 2:d0076e9d0a7f, committed 2015-09-24
- Comitter:
- Gerth
- Date:
- Thu Sep 24 16:27:40 2015 +0000
- Parent:
- 1:b75c4b9f1c98
- Commit message:
- pi controller to make the motor follow the potmeter;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 24 15:58:55 2015 +0000
+++ b/main.cpp Thu Sep 24 16:27:40 2015 +0000
@@ -22,8 +22,8 @@
//frequencies
//const float pwm_frequency=1000;
-const double hidscope_frequency=100;
-const double pi_control_frequency=5;
+const double hidscope_frequency=100;//frequentie waarop data naar HIDScope wordt gestuurd
+const double pi_control_frequency=5;//frequentie waarop er een control actie wordt uitgevoerd. kan hoger, voorzichtig bij ruis!
//tickers
Ticker hidscope_ticker;
@@ -84,10 +84,11 @@
pi_control_ticker.attach(&pi_control_activate,1.0/pi_control_frequency);
while(1) {
- //control motor 1 with a p controller
+ //control motor 1 with a pi controller
if (pi_control_go==true) {
double error=2*PI*pot1.read()-counttorad*encoder1.getPulses();
- float signal_motor1=pi_control(error,motor1_pi_kp,motor1_pi_ki,1/pi_control_frequency,motor1_error_int);//send error to p controller
+ double signal_motor1=pi_control(error,motor1_pi_kp,motor1_pi_ki,
+ 1/pi_control_frequency,motor1_error_int);//send error to p controller
if (signal_motor1>=0) {//determine CW or CCW rotation
motor1_direction.write(CW);
} else {
