Pigeon-KickerBoian Mitov
Published © MIT

Cutsie Whun & Visuino: Finding Your R.O.C (Rate Of Change)

Cutsie Whun is a tough and fast, RC-controlled, 2-wheeled balancing fun machine.

AdvancedWork in progressOver 1 day758
Cutsie Whun & Visuino: Finding Your R.O.C (Rate Of Change)

Things used in this project

Schematics

Visuino Screen

Code

Compiled IDE code

C/C++
t//----------------------------------------------
//
//        Sketch Generated by Visuino
//              www.visuino.com
//          Version  7.8.2.198
//
//------------------ Source --------------------
//
// CUTSIE_WHUN_R_O_C.owarduino
//
//----------------------------------------------

#define VISUINO_ARDUINO_PRO_MINI

#include <OpenWire.h>
#include <Mitov.h>
#include <Mitov_FormattedSerial.h>
#include <Wire.h>
#include <Mitov_Basic_I2C.h>
#include <Mitov_MPU6050.h>
#include <Mitov_Math.h>
#include <Mitov_Text.h>
#include <Mitov_KalmanFilter.h>
#include <Mitov_SpeedChangeMeter.h>

// Arduino Board Declarations

namespace BoardDeclarations
{
Mitov::SerialPort<SERIAL_TYPE, &Serial> SerialPort0;
Mitov::ArduinoSerialStringInput<Mitov::SerialPort<SERIAL_TYPE, &Serial>, &SerialPort0> SerialPort0_String_1;
} // BoardDeclarations

// Declarations

namespace Declarations
{
Mitov::MPU6050I2C MPU6050 = Mitov::MPU6050I2C( Wire );
Mitov::SubtractValue<float> SubtractValue1;
Mitov::SubtractValue<float> SubtractValue2;
Mitov::FormattedText_Fixed FormattedText1;
Mitov::FormattedTextLengthElementTyped<Mitov::FormattedTextElementAnalog> TArduinoFormattedTextElementAnalog1( FormattedText1 );
Mitov::FormattedTextLengthElementTyped<Mitov::FormattedTextElementAnalog> TArduinoFormattedTextElementAnalog2( FormattedText1 );
Mitov::AveragePeriod AveragePeriod1;
Mitov::AveragePeriod AveragePeriod2;
Mitov::MapRange MapRange1;
Mitov::KalmanAnalog Kalman1;
Mitov::SpeedChangeMeter SpeedChangeMeter2;
Mitov::MapRange MapRange2;
} // Declarations

//The setup function is called once at startup of the sketch
void setup()
{
  Wire.begin();
  Declarations::MPU6050.Accelerometer.FullScaleRange = Mitov::ar4g;
  Declarations::MPU6050.Accelerometer.X.SelfTest = true;
  Declarations::MPU6050.Accelerometer.Y.Enabled = false;
  Declarations::MPU6050.Accelerometer.Z.Enabled = false;
  Declarations::MPU6050.Accelerometer.OutputPins[ 0 ].Connect( Declarations::SubtractValue1.InputPin );
  Declarations::MPU6050.Gyroscope.FullScaleRange = Mitov::gr500dps;
  Declarations::MPU6050.Gyroscope.Units = Mitov::auRadians;
  Declarations::MPU6050.Gyroscope.X.SelfTest = true;
  Declarations::MPU6050.Gyroscope.Y.Enabled = false;
  Declarations::MPU6050.Gyroscope.Z.Enabled = false;
  Declarations::MPU6050.Gyroscope.OutputPins[ 0 ].Connect( Declarations::SubtractValue2.InputPin );
  Declarations::MPU6050.Thermometer.Enabled = false;
  Declarations::MPU6050.Thermometer.InFahrenheit = true;
  Declarations::MPU6050.Interrupt.OnRawReady = true;
  Declarations::MPU6050.FrameSynchronization.EnableInterrupt = true;
  Declarations::MPU6050.LowPowerMode.Enabled = false;
  Declarations::MPU6050.Filter = Mitov::f_AB_94Hz_GB_98Hz_F_1KHz;
  Declarations::SubtractValue1.Value = 0.904540002346039;
  Declarations::SubtractValue1.OutputPin.Connect( Declarations::MapRange1.InputPin );
  Declarations::SubtractValue2.Value = 0.124779999256134;
  Declarations::SubtractValue2.OutputPin.Connect( Declarations::MapRange2.InputPin );
  Declarations::FormattedText1.OutputPin.Connect( BoardDeclarations::SerialPort0_String_1.InputPin );
  Declarations::TArduinoFormattedTextElementAnalog1.Precision = 5;
  Declarations::TArduinoFormattedTextElementAnalog2.Precision = 5;
  Declarations::FormattedText1.AddReadyElement( (char *)"", 0 );
  Declarations::FormattedText1.AddReadyElement( (char *)" ", 1 );
  Declarations::FormattedText1.AddReadyElement( (char *)" ", 2 );
  Declarations::AveragePeriod1.OutputPin.Connect( Declarations::Kalman1.InputPin );
  Declarations::AveragePeriod2.OutputPin.Connect( Declarations::SpeedChangeMeter2.InputPin );
  Declarations::MapRange1.InputRange.Min = -1;
  Declarations::MapRange1.OutputPin.Connect( Declarations::AveragePeriod1.InputPin );
  Declarations::Kalman1.OutputPin.Connect( Declarations::TArduinoFormattedTextElementAnalog2.InputPin );
  Declarations::SpeedChangeMeter2.OutputPin.Connect( Declarations::Kalman1.RateInputPin );
  Declarations::SpeedChangeMeter2.OutputPin.Connect( Declarations::TArduinoFormattedTextElementAnalog1.InputPin );
  Declarations::MapRange2.InputRange.Min = -1;
  Declarations::MapRange2.OutputPin.Connect( Declarations::AveragePeriod2.InputPin );

  OpenWire::Component::_SystemInit();
}

// The loop function is called in an endless loop
void loop()
{
  OpenWire::Component::_SystemLoop();
}

Credits

Pigeon-Kicker

Pigeon-Kicker

19 projects • 31 followers
Computer guru from the 80's, currently disabled veteran. Building this stuffs for my son to learn robotics.
Boian Mitov

Boian Mitov

75 projects • 438 followers
CEO of Mitov Software, and creator of Visuino

Comments