Pramod C Wickramasinghe
Published © GPL3+

Digital Angle Divider

Divider is an instrument for measuring, transferring, or marking off distances, consisting of two straight adjustable legs hinged together.

IntermediateShowcase (no instructions)24 hours756
Digital Angle Divider

Things used in this project

Hardware components

ATmega328
Microchip ATmega328
Atmega328P-AU
×1
Li-Ion Battery 100mAh
Li-Ion Battery 100mAh
180mAh
×1
USB Li Ion Battery Charger
Adafruit USB Li Ion Battery Charger
×1
0.96" OLED 64x128 Display Module
ElectroPeak 0.96" OLED 64x128 Display Module
I2C interface
×1
Tactile Switch, Ultra Small
Tactile Switch, Ultra Small
×2
Texas Instruments 3.3v Low-Dropout-Regulators
×1
Vishay 10k smd 1206
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
10k
×1

Software apps and online services

Arduino IDE
Arduino IDE
MATLAB
MATLAB
Solidworks - 2017
Proteus

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot Air Station, Industrial
Hot Air Station, Industrial
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

Angle Divider Enclouser

The enclosure designed using Solid-works - 2017. Use these files to 3D print the enclosure.

Angle Divider - Design

Schematics

Angle Divider Schematic

Angle Divider PCB

Code

Angle Divider C++ Code

Arduino
/*=============================================
    Program : Digital Angle Divider
    Author  : wickPro-PC\wickPro
    Time    : 9:30 PM
    Date    : 02/08/2018
    Coded by: Pramod C Wickramasinghe
    E-mail  : wick.pro@gmail.com
    Mobile  : +94774585875
  =============================================*/

#include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"

#define I2C_ADDRESS 0x3C
#define zero 2
#define units 3

SSD1306AsciiWire oled;

int measureValue, unitsVal, zeroVal = 0;
int noOfReadings = 10;
double _value, buff_1, buff_2, buff_3, buff_4, setZero = 0;
//-----------------------------------------------------------------------------

void reading() {

  if (unitsVal % 2 == 0) {
    //_value = (map(measureValue, 0, 1023, 0, 254) / 10.0) ;

    // _value = (-0.0001)*(measureValue)*(measureValue) + (0.3249)*(measureValue) + (40.78) - 1; // 1.0 offset occured

    buff_1 = (-0.00010954) * (measureValue) ;
    buff_2 = buff_1 * (measureValue);
    buff_3 = (0.32620281) * (measureValue);
    buff_4 = buff_3 + 44.64231864;
    _value = buff_2 + buff_4 - setZero;

  } else {
    //_value = (map(measureValue, 0, 1023, 0, 10) / 10.0) ;

    buff_1 = (-0.00000426) * (measureValue) ;
    buff_2 = buff_1 * (measureValue);
    buff_3 = (0.01289839) * (measureValue);
    buff_4 = buff_3 + 1.72506535;
    _value = buff_2 + buff_4 - setZero; // coEff =
  }

  oled.setFont(Callibri15);
  oled.setLetterSpacing(2);
  oled.set2X();
  oled.setCursor(0, 2);
  oled.print("            ");

  if (_value < 1000 && 100 <= _value) {
    oled.setCursor(15, 2);
  } else if (_value < 100 && 10 <= _value) {
    oled.setCursor(28, 2);
  } else if (_value < 10 && 0 <= _value) {
    oled.setCursor(40, 2);
  } else if (_value < 0 && -10 <= _value) {
    oled.setCursor(30, 2);
  } else if (_value < -10 && -100 <= _value) {
    oled.setCursor(20, 2);
  } else if (_value < -100 && -1000 <= _value) {
    oled.setCursor(7, 2);
  } else {
    oled.setCursor(0, 2);
  }

  oled.print(_value);
}
//------------------------------------------------------------------------------
void setup() {

  Wire.begin();
  oled.begin(&Adafruit128x64, I2C_ADDRESS);

  oled.setFont(Callibri11_bold);
  oled.setCursor(0, 0);
  oled.println("Measurement:");
  //oled.setCursor(100, 2);
  //oled.print("mm");
  oled.setCursor(5, 6);
  oled.print("Zero");
  oled.setCursor(100, 6);
  oled.print("Units");

  pinMode(zero, INPUT);
  pinMode(units, INPUT);
}
//------------------------------------------------------------------------------
void loop() {

  if (digitalRead(units) == LOW) {
    unitsVal++;
    delay(100);
  }
  if (digitalRead(zero) == LOW) {
    setZero = 0;
    reading();
    setZero = _value;
    delay(100);
  }
  if (unitsVal % 2 == 0) {
    oled.setFont(Callibri11_bold);
    oled.setLetterSpacing(1);
    oled.set1X();
    oled.setCursor(100, 2);
    oled.print("mm");
  } else {
    oled.setFont(Callibri11_bold);
    oled.setLetterSpacing(1);
    oled.set1X();
    oled.setCursor(100, 2);
    oled.print("inch");
  }

  for (byte i = 0; i < noOfReadings; i++) {
    measureValue = measureValue + analogRead(A0);
    delayMicroseconds(1000);
  }
  measureValue = measureValue / noOfReadings;
  reading();
}

Angle Divider - Calibration Codes

MATLAB
format long

metric_y = [50 75  90 110 130 140 160 180 200 210];
metric_x = [16 96 147 217 288 330 411 497 592 651];
poly_metric = polyfit(metric_x, metric_y, 2)

imperial_y = [2.0 2.3 3.0 3.5 4.1 5.0 5.5 6.5 7.5 8.0 8.5];
imperial_x = [ 20  43 104 145 198 283 333 434 526 611 685];
poly_imperial = polyfit(imperial_x, imperial_y, 2)

Credits

Pramod C Wickramasinghe

Pramod C Wickramasinghe

4 projects • 27 followers
The kind of person who turns ideas into projects, and projects into success.

Comments