About Me Assignments Projects

Week 9 Assignment

OUTPUT DEVICES

This weeks assigmenat was to test output devices using different development boards so i stared with the neo pixel led that attached with my board,and i wanted to build something related to my project i tried to build a mosfet driver that i will used to test a spark generator

WS2812

WS2812 is a type of addressable RGB LED (Light Emitting Diode) commonly used in various lighting and display applications. These LEDs are often referred to as NeoPixels, a trademarked name by Adafruit, one of the leading manufacturers of WS2812-based products. The WS2812 LED integrates the LED die, control circuitry, and a communication interface into a single package, making it easy to control individual LEDs or groups of LEDs with a microcontroller or other digital control devices. Each WS2812 LED has a built-in shift register, which allows it to receive data serially and pass on the data to the next LED in the chain. One of the key features of WS2812 LEDs is their ability to be individually addressed, meaning that each LED in a chain can be assigned a unique color and brightness. This makes them ideal for applications such as LED matrix displays, decorative lighting, and wearable electronics. WS2812 LEDs communicate using a simple serial protocol, typically using a single data line to transmit color and brightness information to each LED in the chain. The communication protocol requires precise timing to ensure accurate data transmission, and there are various libraries and software tools available to simplify the process of controlling WS2812 LEDs with microcontrollers

Sample Image

Sample Image

sws2812 datasheet

WS2812 LIGHTUP

So i used a basic programme to light up and run a animation on the single led

this is the sketch that i used for the WS2812B individual addressable led

    
    #include Adafruit_NeoPixel.h

      // Pin connected to the NeoPixels (WS2812B)
      #define LED_PIN 15
      
      // Number of NeoPixels
      #define LED_COUNT 1
      
      // Create NeoPixel object
      Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
      
      void setup() {
        // Initialize NeoPixel strip
        strip.begin();
        strip.show(); // Initialize all pixels to 'off'
      }
      
      void loop() {
        // Cycle through different colors
        rainbow(20); // Change colors every 20ms
      }
      
      // Function to cycle through rainbow colors
      void rainbow(uint8_t wait) {
        for (uint16_t i = 0; i < 256; i++) {
          uint32_t color = Wheel((i + strip.numPixels()) & 255);
          for (int j = 0; j < strip.numPixels(); j++) {
            strip.setPixelColor(j, color);
          }
          strip.show();
          delay(wait);
        }
      }
      
      // Input a value 0 to 255 to get a color value.
      // The colors are a transition r - g - b - back to r.
      uint32_t Wheel(byte WheelPos) {
        WheelPos = 255 - WheelPos;
        if (WheelPos < 85) {
          return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
        }
        if (WheelPos < 170) {
          WheelPos -= 85;
          return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
        }
        WheelPos -= 170;
        return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
      }
      

  

HOW DOES THE CODE WORK

ESC (Electronic Speed Controller) and BLDC Motors

Brushless DC Motor

ESC Circuit Diagram

As the name suggests, BLDC motors do not use brushes and a commutator. Instead:

In contrast to brushed motors where rotation is controlled by current through rotor coils:

This design offers advantages such as improved efficiency, higher reliability, and reduced maintenance compared to brushed motors.

How BLDC Motors Work with ESC

BLDC motors operate based on ESC control:

ESC Circuit Diagram

ESC (Electronic Speed Controller)

An Electronic Speed Controller (ESC) is a device used to control the speed of an electric motor, crucial in applications like RC vehicles, drones, and more. It utilizes Pulse Width Modulation (PWM) signals for precise speed control.

ESC Circuit Diagram

Principles of ESC

An ESC regulates the speed of electric motors, such as BLDC (Brushless DC) motors, which are widely used due to their efficiency and performance advantages over brushed motors.

PWM (Pulse Width Modulation)

PWM is key to an ESC’s function. It encodes analog signals digitally, determining motor speed based on the duty cycle of the signal it receives:

Types of ESC

There are two main ESC types:

Sensored BLDC Motors and ESCs

Sensored BLDC motors use feedback from sensors (Hall effect or similar) for precise motor control:

ESC Circuit Diagram

Sensorless BLDC Motors and ESCs

Sensorless BLDC motors operate without sensors, relying on ESC algorithms to determine rotor position:

ESC Circuit Diagram

HOW BLDC MOTOR WORK WITH ESC

An Electronic Speed Controller (ESC) is essential for controlling Brushless DC (BLDC) motors, providing precise speed and direction control in various applications such as drones, RC vehicles, and industrial equipment. Here’s how ESCs work with BLDC motors:

1. Signal Processing

The ESC receives commands from a controller (like a microcontroller or transmitter/receiver system) via a PWM (Pulse Width Modulation) signal. This signal dictates the desired speed and direction of the motor.

2. Commutation

BLDC motors require precise commutation (switching of current in the motor windings) to generate the rotating magnetic field necessary for rotor movement. The ESC electronically commutates the motor by sequentially energizing the stator coils in the correct sequence based on rotor position feedback.

3. Rotor Position Sensing

To accurately commutate the motor, some ESCs use sensorless techniques that estimate rotor position based on back EMF (Electromotive Force) detection, while others employ sensors (such as Hall effect sensors) to directly measure rotor position.

4. Speed Control

The ESC adjusts the speed of the BLDC motor by varying the amplitude and timing of the current pulses sent to the motor windings. This control allows for precise speed regulation and response to changing load conditions.

ESC Circuit Diagram

BUIDLING THE PCB

PCB Design with ATtiny1614 Microcontroller

Components Used:

ESC Circuit Diagram

Guide to Drawing Schematic and Designing PCB with EasyEDA

Drawing the Schematic in EasyEDA

  1. Create a New Project: Log in to EasyEDA and start a new project. Name it accordingly.
  2. Add Components to the Schematic:
  3. Connect Components:
  4. Label and Annotate:
  5. Save and Validate:
ESC Circuit Diagram

downloded the schematic

Designing the PCB in EasyEDA

  1. Convert to PCB: Click "Convert to PCB" to transition from schematic to PCB layout.
  2. Import Components: Arrange components on the PCB canvas, placing the microcontroller centrally.
  3. Routing Traces:
  4. Adding Vias: Place vias where traces switch layers.
  5. Routing Pads and Connections: Connect pads to microcontroller pins and other ICs.
  6. Ground Plane and Power Planes:
  7. Design Validation:
  8. ESC Circuit Diagram

    downloded the gerber here

    here are the original design files [easy eda]

    download the easyeda files here

    By following these steps in EasyEDA, you can effectively design a PCB for programming with the ATtiny1614 microcontroller, ensuring proper component placement, routing, and design validation.

    Converting Gerber to PNG Using OurPCB's Gerber Viewer

    To convert Gerber files to PNG format, you can use OurPCB's Gerber Viewer tool. This tool allows you to visualize and convert Gerber files into more accessible image formats like PNG.

    Steps to Convert Gerber to PNG:

    1. Upload Gerber Files:
      • Go to Ourlabs Gerber Viewer website or platform.
      • Upload your Gerber files (.gbr, .gtl, .gbl, etc.) to the viewer.
    2. View and Verify Layers:
      • Use the Gerber Viewer interface to view each layer of your PCB design.
      • Verify that all layers are correctly displayed and oriented.
    3. Convert to PNG:
      • Locate the option or tool in the Gerber Viewer to export or convert the displayed layers to PNG.
      • Specify the resolution or settings for the PNG output if applicable.
    4. Download PNG Files:
      • Once the conversion process is complete, download the PNG files generated from your Gerber layers.
      • The PNG files will represent each layer of your PCB design as an image file.

    Converting Gerber files to PNG using OurPCB's Gerber Viewer tool simplifies the process of visualizing and sharing PCB designs. It allows you to inspect design layers and communicate design intent effectively.

    PRODUCTION

    then i used fab modes to send the files to the milling machine and milled the pcb and assembled it

    ESC Circuit Diagram

    Controlling ESC with PWM

    To control an ESC with PWM, a microcontroller or dedicated PWM signal generator sends pulses to the ESC. The width of each pulse (duty cycle) determines the motor speed.

        // Example code for controlling ESC with PWM
        #include <Servo.h>
          Servo esc;       // Create a servo object to control the ESC
          int ledPin = 2;  // LED pin
          
          void setup() {
            esc.attach(1);            // Attach ESC signal to pin 9
            pinMode(ledPin, OUTPUT);  // Set LED pin as output
              esc.writeMicroseconds(2000);  // Send 1000us pulse width
              delay(2000);
                esc.writeMicroseconds(1000);  // Send 1000us pulse width
                delay(1000);
          
          
          }
          
          void loop() {
            // Arm the ESC
            esc.writeMicroseconds(1000);  // Send 1000us pulse width
            digitalWrite(ledPin, HIGH);   // Turn on LED
            delay(2000);                  // Wait for ESC to arm
          
            // Increase throttle gradually
            for (int throttle = 1000; throttle <= 2000; throttle += 10) {
              esc.writeMicroseconds(throttle);  // Set throttle
              delay(20);                        // Delay between increments
            }
            delay(2000);  // Hold throttle at maximum
          
            // Decrease throttle gradually
            for (int throttle = 2000; throttle >= 1000; throttle -= 10) {
              esc.writeMicroseconds(throttle);  // Set throttle
              delay(20);                        // Delay between decrements
            }
            esc.writeMicroseconds(1000);  // Set throttle back to minimum
            digitalWrite(ledPin, LOW);    // Turn off LED
            delay(2000);                  // Wait before repeating
          }
          
      

    ESC Control Code Explanation

    Setup Function (setup())

    Loop Function (loop())

    download the code

    download the CODE here

    DOWNLOAD THE DESIGN FILES

    downloded the gerber here

    here are the original design files [easy eda]

    download the easyeda files here

    ESC and BLDC MOTOR in Action