this code is for inverted pendulum balancer. it is based on two-loop PID controller. One controller is for Angle and another one is for velocity.

Dependencies:   HCSR04 L298HBridge mbed

Revision:
0:489498e8dae5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/controller/controller.h	Fri Aug 25 21:10:23 2017 +0000
@@ -0,0 +1,38 @@
+//#ifndef CONTROLLER_H
+//#define CONTROLLER_H
+
+#include "mbed.h"
+#include "PID.h"
+#include "L298HBridge.h"
+
+#define controllerAng_update_dt 0.005
+#define controllerVel_Update_dt 0.005
+
+#define AngleOutputLimit 600 //attitude output limit at 60% power
+#define AngleErrLimit 450 //attitude pitch error limit at 45degree * 10 = 450
+#define velOutputLimit 600 //altitude output limit at 60% power
+#define VelocityLimit 100
+#define offset_moving 400 //the duty start at 40%
+
+
+
+extern PidObject pidAngle;
+extern PidObject pidVelocity;
+
+//extern float pitchOutput;
+//extern float AngleOutput;
+
+extern L298HBridge Motor_PWM;
+extern float Motor;
+
+extern float I_term;
+
+void controller_init(void);
+float controller_Angle_PID(float angle_result); 
+float controller_Velocity_PID(float Velocity_result); 
+void controllerResetAllPID(void);
+float controllerGetActuatorOutput();
+void MOTOR_Update(float Motor);
+
+
+