Nicholas RyanAaron Dubiansky
Published © GPL3+

Bike Wheel Truing Using a Linear Potentiometer - MEGR 3171

Linear potentiometers can do the job of measuring small distances much better than eyeballing, making them perfect for truing wheels.

IntermediateShowcase (no instructions)Over 1 day574
Bike Wheel Truing Using a Linear Potentiometer - MEGR 3171

Things used in this project

Hardware components

Photon
Particle Photon
×2
Breadboard (generic)
Breadboard (generic)
×2
SparkFun Momentary Pushbutton Switch
×2
Adafruit MONOCHROME 1.3" 128X64 OLED GRAPHIC DISPLAY
×1
9605R1.7kl2.0-Potentiometer
×1
Resistor 1k ohm
Resistor 1k ohm
×2

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Schematics

OLED and zeroing button diagram

Used to zero a distance, and shows the distance out or in relative to the set zero.

oledschematic_ofTJ4VXQrA.PNG

Potentiometer and maximum distance reading button

This is the photon that takes resistance from the potentiometer and converts it to distance. Distance data is sent to the second photon to be displayed by the OLED. The button on this board starts a ten second data recording and finds the largest distance measurement read.

potentiometerschematic_rjThi0K4ha.PNG

Code

potentiometerdisplaycode

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_SSD1306.h>

/*****************************************************************************
Particle Maker Kit Tutorial #2: Next Bus Alert

This tutorial uses a Particle Photon and the OLED screen from the Particle
Maker Kit. It uses a webhook to retrieve bus prediction times from the
NextBus Public XML feed, which must be set up first along with the webhook.
See https://docs.particle.io/tutorials/topics/maker-kit to learn how!

NOTE: This code example requires the Adafruit_SSD1306 library to be included,
so make sure to add it via the Libraries tab in the left sidebar.
******************************************************************************/

// use hardware SPI
#define OLED_DC     D3
#define OLED_CS     D4
#define OLED_RESET  D5

Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
int button1 = D2;
int yes = 1;
int power=A0;
void setup()   {
  Serial.begin(9600);
pinMode(power,OUTPUT);
  digitalWrite(power,HIGH);
  pinMode(button1,INPUT);
  // by default, we'll generate the high voltage from the 3.3v line internally
  display.begin(SSD1306_SWITCHCAPVCC);
  // init done
  display.display(); // show splashscreen
  delay(100);
  display.clearDisplay();  // clears the screen and buffer
  // Subscribe to distance variable
  Particle.subscribe("DistanceTrue6", DistanceRead);
}

//Get data from cloud
void DistanceRead(const char *Distance, const char *data)
{
  // display the distance
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.printlnf(data);
  display.display();
  display.clearDisplay(); // clears the screen and buffer
  
 Particle.variable("button1", yes); 
  digitalRead(button1);
  if(digitalRead(button1) == HIGH){
      Particle.publish("yeszero", String(yes));
  }
}

potentiometersensorcode

C/C++
int power = A5;
double Count = A0;
double countoffset;
int Button=D2;
int led=D7;
double maximum;
double minimum;
double maxvariance;

    void setup() {
  pinMode(Count,INPUT);
  pinMode(power,OUTPUT);
  digitalWrite(power,HIGH);
  pinMode(Button,INPUT);
  pinMode(led,OUTPUT);
  Particle.variable("MaxVarianceTrue", maxvariance);
    Particle.subscribe("yeszero", zerocheck);
    }
      


 int zerocheck(const char *yeszero, const char *data){
if(data >0)
    countoffset = analogRead(Count);} //checks if the button on the OLED is activated. If yes, then an offest is saved. Recomended to zero at point farthest from sensor.  

  
void loop()  
{if(digitalRead(Button) == HIGH){ 
digitalWrite(led,HIGH);                   //If button on sensor board is pushed (hold for atleast .5sec), a blue LED will light up and the for loop will be run to calculate maximum variance. 
    int i;
    maximum=(analogRead(Count)/264.651);
    minimum=maximum;
    for (int i=0; i<100; i++) {
        if((analogRead(Count)/264.51)>=maximum){ //calculate maximum and minimum points laterally on the wheel relative to the sensor
        maximum= (analogRead(Count)/264.651) ;  
        }
        else if((analogRead(Count)/264.51)<maximum & (analogRead(Count)/264.51)>=minimum){;}
        
        else{minimum= (analogRead(Count)/264.651);}
        
        delay(100);
    }
   float maxvariance= maximum-minimum;  //calculate maxvariance
    Particle.publish("MaxVarianceTrue",String(maxvariance)); //publish max variance
    } 
   else {
digitalWrite(led,LOW); 
    String Distance=String(((analogRead(Count)-countoffset)/264.651));
    Particle.publish("DistanceTrue6", Distance);

  
 delay(1000);
  
  
 
  
}}

Credits

Nicholas Ryan

Nicholas Ryan

1 project • 0 followers
Aaron Dubiansky

Aaron Dubiansky

1 project • 0 followers

Comments

Add projectSign up / Login