HOME ABOUT ASSIGNMENT PROJECT CONTACT

FINAL PROJECT


Slide




presentation




The project itself is about making a Digital Measuring Tape, a modernized version of the traditional tape measure, integrating electronic components for enhanced functionality and precision. Unlike a conventional tape measure with marks and numbers along its length, it will have a digital screen, accurate measurements, that displays measurements in digits, making it easier to read and interpret, for lenghts i intend to make model suitable for construction or industrial use with centimeters as the unit, not too big but one that can also be used to bridge the gap between industrial and other function where the tape measure is needed. for power supply i intend to batteries as the source, lipo in this case


PROCESS PCB MAKING


I started off with making connections on the bread to get a better understanding and build a PCB with no errors so i after receiving certain components which i got from this sources below:

  • So with the rotary encoder with an extenction board and the breadboard and the xiao ESP32C3 with resistors and a couple jumper wires then i made the connection. i made the connection by connecting the ground of the encoder to the ground of the microcontroller and the vcc of the rotary encoder to the 3V3 of the xiao of the microcontroller, usually the rotary encoder has 2pins on the front/back and 3pins on the front/back (depending from you look at it) but due to it being on an extenction board it had all five pins in a row so i connected the CLK and the DATA pins to the digital pins of the XIAO_ESP32C3; respectively D9 and D10 then using the codes below started to check for the output on the arduino IDE




    CODES & TESTING


    This code initializes the rotary encoder and uses interrupts to update the position count every time the encoder is turned, the result is printed to the Serial port so that you can read it out from the Serial Monitor. I found it online looking for a way to work around and understand how a rotary encoder works so i took the codes from this article to try to see how the encoder will respond and i found it to be positively responding so i kept on building on it so below i will share the codes.




      
    
        // Define the pins used for the encoder
        const int encoderPinA = D10;
        const int encoderPinB = D9;
        
        // Variables to keep the current and last state
        volatile int encoderPosCount = 0;
        int lastEncoded = 0;
        
        void setup() {
          Serial.begin(250000);
        
          // Set encoder pins as input with pull-up resistors
          pinMode(encoderPinA, INPUT_PULLUP); 
          pinMode(encoderPinB, INPUT_PULLUP);
        
          // Attach interrupts to the encoder pins
          attachInterrupt(digitalPinToInterrupt(encoderPinA), updateEncoder, CHANGE);
          attachInterrupt(digitalPinToInterrupt(encoderPinB), updateEncoder, CHANGE);
        }
        
        void loop() {
          static int lastReportedPos = -1; // Store the last reported position
          if (encoderPosCount != lastReportedPos) {
            Serial.print("Encoder Position: ");
            Serial.println(encoderPosCount);
            lastReportedPos = encoderPosCount;
          }
        }
        
        void updateEncoder() {
          int MSB = digitalRead(encoderPinA); // MSB = most significant bit
          int LSB = digitalRead(encoderPinB); // LSB = least significant bit
        
          int encoded = (MSB << 1) | LSB; // Converting the 2 pin value to single number
          int sum  = (lastEncoded << 2) | encoded; // Adding it to the previous encoded value
        
          if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderPosCount++;
          if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderPosCount--;
        
          lastEncoded = encoded; // Store this value for next time
        }
      
    

    After getting the result that the encoder could function with these codes i designed a roller that's to be the extension of the encoder so again this is an initial design for testing and then progress with what's working. I started with with designing in coreldraw a circle with marked numbers to be able to count the revolution of the roller in conjunction with the pulse of the encoder. So the design is a circle of 70MM with the middle of the circle shaped like the extension of the encoder so that it may fit firmly with the encoder.


    I traced or engraved on The circle a line as an indicator of the beginning of a revolution and the end of the revolution to make sure we set up the codes that counts the exact measurement, in other words; how many times the wheel/roller turns while moving it in certain amount of distance. This roller i ended up not using it due to it not having measures traced on it so this can be counted as what didn't work because i ended up not using this.



    I designed a second one with measures equating to the diameter of the roller which was wrong because i had to draw around the roller measures equating the circumference of the roller



    I calculated the circumference using the formula Diameter*π then with the diameter being 70mm, the circumference was 210.905⁓220MM so i designed the roller with a 220MM engraved as i circumference so to design this in coreldraw, you first draw a circle then i add the line of 6mm in height then double click that line and then take its center of rotation put it in the center of circle withe 70MM diameter then go to the properties bar located on the right side of the workspace you can also activate it by using the shortcut; ALT+Enter then go to Transform in its tab, click on Rotate. We will set the angle of rotation to 1.637, this number came from dividing the 360° with the circumference. Below it toggle on rotate the orientation of the object, then set the coopies to 219 since we already have one then print it. For print i learned that another tool called color maping which you can use to cut or engrave part of a same file differently so i wanted the measures to be engraved but i vectorized it so that they can be thin as possible and take less time to do it, then using color map i set the circle to be cut off to a blue color and i cut it using the settings below.

    <

    i proceeded with editing the codes to which i added certain functions to the code i found from another simmilar project. The improved line of codes is potrayed below:


      
        // Define the pins used for the encoder
        const int encoderPinA = D10;
        const int encoderPinB = D9;
        
        // Variables to keep the current and last state
        volatile int encoderPosCount = 0;
        int lastEncoded = 0;
        
        void setup() {
          Serial.begin(250000);
        
          // Set encoder pins as input with pull-up resistors
          pinMode(encoderPinA, INPUT_PULLUP); 
          pinMode(encoderPinB, INPUT_PULLUP);
        
          // Attach interrupts to the encoder pins
          attachInterrupt(digitalPinToInterrupt(encoderPinA), updateEncoder, CHANGE);
          attachInterrupt(digitalPinToInterrupt(encoderPinB), updateEncoder, CHANGE);
        }
        
        void loop() {
          static int lastReportedPos = -1; // Store the last reported position
          if (encoderPosCount != lastReportedPos) {
            Serial.print("Encoder Position: ");
            Serial.println(encoderPosCount);
            lastReportedPos = encoderPosCount;
          }
        }
        
        void updateEncoder() {
          int MSB = digitalRead(encoderPinA); // MSB = most significant bit
          int LSB = digitalRead(encoderPinB); // LSB = least significant bit
        
          int encoded = (MSB << 1) | LSB; // Converting the 2 pin value to single number
          int sum  = (lastEncoded << 2) | encoded; // Adding it to the previous encoded value
        
          if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderPosCount++;
          if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderPosCount--;
        
          lastEncoded = encoded; // Store this value for next time
        }
      
    

    after running the codes i made a few test but first i uploaded the codes to the XIAO_ESP32C3 using a type c cable now to upload the codes you hit the microcontroller boot button then you plug the cable and then you upload it and when it's 100% uploaded you press reset then turn the roller on a specified distance. You start by first measuring an object with normally used tape measure or any other that can take measurement and then use the roller to measure the same object, we found that our roller was taking close to absolute accurate measurement that is in regard to the object that have static known measurements like paper and also using the normal tape measure, so we did couple test, which came pretty close to each others count

    Designing the PCB


    i started off by designing the schematic design of the circuit using KICAD a software for making pcb , so in the schematic you can add components to create a cicruit board




    BOM

    No Item Quantity U.price Total Comment Link
    1 li po battery 3 30000frw 30000frw final project Link
    2 rotary encoder 2 3500frw 7000frw final project Link
    3 PLA 1 53000frw 53000frw final project & mold/casting nyereka
    4 plastic board 1 30,000frw 30000frw molding and casting Fred
    5 XIAO ESP32C3 2 20000frw 40000frw final project Link
    6 copper pcb board 5 4000frw 20000frw final project & the rest assignment FRED
    7 candle wax 3KG molding and casting lambert

    Total: 175000frw


    Assignment Files


    output device