The Miniature balancing robot: 
A low-cost mobile lab experiment kit for education


Click here to edit subtitle

Simulink SFunctions, Diagrams, and Supporting Libraries For Arduino:

New: Arduino Library, Curriculum and all files and demos are available here:

NOTE: We are updating files and libraries -  Some downloads may be temporarily unavailable.  Please contact us if you need something.

For the MinSeg kit  simply:

  1. download the files
  2. connect the USB cable
  3. open the simulink diagram, specify the COM port
  4. press control+B to build, program, and run the code 

                                             it's that easy!


  • Sending Float and Int data: Creating a Byte Stream with a SFunction using a Union
    • These example SFunctions create byte stream from float and int to send data from Arduino with the supported serial transmit block.  It includes an example m-file to reconstruct the data on the PC side.
  • Quadrature decoding of a rotary encoder
    • Download and unzip Quadrature Encoder files and open Matlab in this folder
    • Open MPU6050_SFunction.slx, select Tools -> Run on Target Hardware -> Run
    • This file uses interrupts on pins 2, and 3.  A uno can only use pins 2 and 3.  A mega can use 2, 3, 18, 19, 20, and 21.  If you change the pin numbers the SFunciton must be compiled. instructions are provided in the README provided

  • Driving a DC Motor with PWM: Sine Wave Test with SN754410 driver
    • Download Motor_Test_Sine_Wave.slx and open Matlab in the same directory
    • Open Motor_Test_Sine_Wave.slx, select Tools -> Run on Target Hardware -> Run
    • The motor should oscillate back and forth at with a period of 3 seconds


  • Reading accelerometer and gyroscope data from MPU6050 with I2C.
    • Download and unzip MPU6050 files and open Matlab in this folder
    • Open MPU6050_SFunction.slx, select Tools -> Run on Target Hardware -> Run
    • To change accelerometer or gyro range, implement low pass filters, or other capabilities of the MPU6050 the SFunction must be compiled - instructions are provided in the README provided

  • Reading distance data from HC-SR04 ultrasonic sensor.
  • Download and unzip HC-SR04  files and open Matlab in this folder
  • Open HCSR04_SFunction.slx, select Tools -> Run on Target Hardware -> Run
    • The current SFunction is hard coded with pin 6 the trigger pin and pin 7 the echo pin.  To change the pins the SFunciton has to be compiled.  Instructions to compile the SFunction are provided in the README. 
    • The current version blocks the code when it is computing the distance causing the code to overrun for fast sample times (5ms - MinSeg still balances).  We are working on improving this - stay tuned!

  • Reading gyroscope data from a L3GD20 with I2C (The MinSeg does not use this sensor anymore - it uses the MPU6050):

  • Bluetooth Send and Recieve
send and receive data with Bluetooth to the PC 

Check Back soon!  Many more coming soon... 
- digital IO
- getting data in external mode
- reading analog 
- communicating with bluetooth
- DC motor speed control
- DC motor position control
- Basic filtering
- Simulation

Need something now? Send us a note at [email protected]