Controller The main controller is a PIC16F876A running at 20mHz. Pitch angle feedback is provided by an ADXRS300 Rate Gyro and a ADXL202 dual axis accelerometer from Analog Devices. The gyro signal is integrated and mixed with 0.5% of the gravity signal from the accelerometers (this corrects for drift). There's a better way to do this - it's called a Kalman Filter and is one of the next improvements I'll make to the control. The main control loop runs at 100Hz and is a simple PID controller. The controller outputs a PWM signal to the OSMC using locked antiphase (I can highly recommend this), resulting is super smooth control of the motor with inherent regenerative braking. Setting up the integral gains and limits is a bit of a pain, but I think I have it right as the deck now stays level on hills and at speed. At the moment there's no speed limiting which is a pain as a bit of headroom is required to stop the rider from falling off the front. I'm either going to add a buzzer indicating that the integrator is wound up and you're near max speed or some kind of auto lean back type thing.