Draaiende motor op commando van knopje (WERKEND)
Dependencies: Encoder MODSERIAL mbed
Fork of P_controller_motor by
Diff: main.cpp
- Revision:
- 9:3278558361a5
- Parent:
- 8:80cb1f5d561e
- Child:
- 10:1d8b21515ed1
--- a/main.cpp Thu Sep 17 12:18:40 2015 +0000 +++ b/main.cpp Thu Sep 17 12:33:42 2015 +0000 @@ -4,7 +4,7 @@ // Define the HIDScope and Ticker object HIDScope scope(1); -Ticker scopeTimer; +Ticker scopeTime; // Define Encoder @@ -28,17 +28,16 @@ // Error measurement and apply the output to the plant -double motorP_Controller() +void motorP_Controller() { double reference_position = potmeter1.read(); double position = Convert_volt_to_position*encoder1.getPosition(); - return P(reference_position-position, motorP_Kp); + double motorP = P(reference_position-position, motorP_Kp); } int main() { - motorP = motorP_Controller(); - motorP.attach(&motorP_Controller,0.01f); //100Hz + motorP.attach(&motorP_Controller, 0.01f); //100Hz while(1){} }