Phone

    00852-6915 1330

arduino Related Articles

Stay Ahead with Expert Electronics Insights,
Industry Trends, and Innovative Tips

Development Boards

Transitioning from Arduino to ESP32: A Comprehensive Guide

IntroductionThe transition from Arduino to ESP32 has become a significant topic for enthusiasts and developers alike. If you're looking to enhance your projects with wireless capabilities and advanced features, ESP32 is the way to go. This blog post will serve as your comprehensive guide, walking you through the key differences, board selection, programming, and much more. Whether you're a beginner or an experienced maker, get ready to unlock the full potential of ESP32 and take your creations to new heights.Performance ComparisonLet's kick things off with a comparison of the Arduino Uno and the ESP32 DevKitC. In a prime number finding test that ran for 30 seconds, the results were staggering. The Arduino Uno, equipped with a 16MHz ATmega328P microcontroller, managed to find around 3,000 prime numbers. In contrast, the ESP32 DevKitC, housing a 240MHz chip, soared past with over 125,000 prime numbers. This isn't just a marginal difference; it showcases the ESP32's superior processing power, making it a far more capable choice for complex and computationally demanding tasks.Board Selection for BeginnersIf you're just starting your journey with ESP32, the ESP32 DevKitC is highly recommended. It's an entry-level development board that comes with a built-in antenna and a total of 38 pins. Out of these, 26 are GPIO pins, providing you with a wide range of connectivity options for your projects. The board also features a standard ESP32 chip, ensuring reliability and compatibility. You can easily find clones of this board in the market, like the one used in the video, which function almost identically. This availability makes it convenient and cost-effective for beginners to get started. When purchasing, make sure to check for any additional components or accessories you might need, such as micro USB cables for power and programming. With the ESP32 DevKitC, you'll have a solid foundation to build upon as you explore the world of ESP32.Programming Setup with Arduino IDEOne of the most convenient aspects of working with ESP32 is the ability to program it using the familiar Arduino IDE. Here's a step-by-step breakdown:Install the ESP32 Board Package: Open the Arduino IDE and navigate to the Board Manager. In the search bar, type "ESP32" and install the latest version of the board package. This step is crucial as it provides the IDE with the necessary files and configurations to recognize and work with the ESP32.Select Your ESP32 Board: Once the installation is complete, go to the "Tools" menu, select "Board," and then choose the specific ESP32 model you're using, such as the ESP32 DevKitC. This ensures that the IDE compiles and uploads the code correctly for your particular board.Code Compatibility: When writing your sketches, remember that most Arduino libraries have ESP32 equivalents. However, be cautious as some libraries may not be fully compatible. For instance, if you're using Arduino functions in your code, make sure to include "Arduino.h" at the top. Additionally, certain libraries like Servo and TimerOne might have issues. In such cases, look for ESP32-specific versions like ESP32Servo and ESP32TimerInterrupt, which offer similar functionality.By following these steps, you'll be able to harness the power of the Arduino IDE to program your ESP32 with ease, opening up a world of possibilities for your projects.Power Options and PrecautionsWhen it comes to powering your ESP32, you have several options, each with its own considerations. The most straightforward way is via a USB cable, which is not only convenient but also provides a stable power source, especially when you're programming or testing your device. This is often the go-to method for beginners and during the initial setup phase.Another option is to supply power through the 5V and GND pins. This can be useful when you have a 5V power supply readily available, such as from a wall adapter or a battery pack. However, it's crucial to note that the ESP32 has built-in voltage regulation for the 5V input, which means it can handle this voltage level without issues. But always make sure the power source is reliable and within the specified range to avoid any potential damage.For more power-sensitive applications or when you want to power the ESP32 directly from a 3.3V source, you can use the 3.3V and GND pins. This is the native operating voltage of the ESP32, and using a 3.3V supply can help optimize power consumption. But be extremely cautious not to over-volt this pin. Unlike the 5V pin, the 3.3V pin does not have extensive voltage regulation, and applying excessive voltage can quickly damage the board.In any case, always double-check your power connections and ensure that the voltages are stable. Using a multimeter to measure the voltages at the pins can be a good practice to confirm everything is in order before powering up your project. This attention to detail will save you from potential headaches and protect your valuable ESP32 board.Pinout and FunctionalityNow, let's delve into the pinout of the ESP32. With a total of 38 pins, it offers a wealth of connectivity options. Out of these, 6 pins are dedicated to power, and another 6 are reserved or have specific limitations, leaving us with 26 GPIO (General Purpose Input/Output) pins. These GPIO pins are where the real magic happens.Compared to the Arduino's GPIO pins, the ESP32's offer enhanced functionality. For instance, 22 of the ESP32's GPIO pins support 16-bit PWM (Pulse Width Modulation), allowing for much finer control of devices like LEDs or motors. This means you can simulate values from 0 to 65,535, as opposed to the 0 to 255 range on the Arduino. Additionally, 16 pins have 12-bit ADC (Analog-to-Digital Converter) capabilities, enabling them to read analog signals with a resolution of 0 to 4,095. In contrast, the Arduino typically has a 10-bit ADC, limiting its analog reading range to 0 to 1,023. The ESP32 also features 2 DAC (Digital-to-Analog Converter) channels, which can generate analog signals, opening up possibilities for audio and other analog applications.To make the most of these pins, it's essential to refer to the official pinout diagrams, especially when connecting peripherals. Incorrect pin usage can lead to unexpected behavior or even damage to the board. For example, some pins have specific functions like being connected to internal components and should not be used for general I/O. By understanding the pinout and functionality, you can design more efficient and reliable circuits for your projects.Connecting PeripheralsConnecting peripherals to your ESP32 requires some careful consideration due to its 3.3V operating voltage. Many common peripherals, such as sensors and actuators, are designed to work with either 3.3V or 5V. If you're using a 3.3V peripheral, like a specific type of temperature sensor, you can usually connect it directly to the appropriate GPIO pins of the ESP32. However, when dealing with 5V peripherals, things get a bit more complicated.For instance, let's say you want to connect an ultrasonic sensor that operates at 5V to your ESP32. In this case, you can't simply wire it up directly, as the higher voltage could potentially damage the ESP32. This is where level shifters come into play. A level shifter acts as a translator between the two different voltage levels. It takes the 5V signal from the ultrasonic sensor and converts it down to 3.3V, making it safe for the ESP32 to receive. Similarly, if the ESP32 needs to send a signal back to a 5V peripheral, the level shifter can boost the 3.3V signal up to 5V.Here's a simple example of how to establish communication between an ESP32 and an Arduino using a level shifter. First, you'd define the pins on each board that will be used for communication. Let's say you choose GPIO 2 on the ESP32 and digital pin 9 on the Arduino. Then, you'd connect these pins to the appropriate channels on the level shifter. Once everything is wired up, you can use code to initialize the serial communication. On the ESP32 side, you might use the Serial.begin() function to set up the communication speed, and on the Arduino side, you'd do something similar. By sending and receiving data through these connected pins and the level shifter, you can achieve seamless interaction between the two devices, opening up a world of possibilities for combining the strengths of both the ESP32 and Arduino in your projects.Communication ProtocolsCommunication protocols play a crucial role in the seamless operation of microcontrollers. When it comes to the Arduino Uno and ESP32, there are significant differences in their support and utilization of protocols like UART, I2C, and SPI.The UART (Universal Asynchronous Receiver/Transmitter) protocol is widely used for serial communication. The Arduino Uno typically has one UART port, which limits its ability to handle multiple simultaneous serial connections. In contrast, the ESP32 boasts three UART ports. This abundance of ports provides greater flexibility, allowing you to connect multiple devices that require UART communication, such as GPS modules, fingerprint sensors, or other serial peripherals. For instance, you could have a GPS module providing location data while simultaneously communicating with a serial display to show relevant information, all without the need for complex multiplexing.Moving on to the I2C (Inter-Integrated Circuit) protocol, which is excellent for connecting multiple devices using just two wires (SDA and SCL). The Arduino Uno has a basic implementation with limited flexibility. On the other hand, the ESP32 takes I2C to the next level. It allows for more advanced configurations and the ability to connect a larger number of I2C devices. This is particularly useful when building projects that involve multiple sensors or actuators that communicate over I2C. You could effortlessly attach a temperature sensor, a humidity sensor, and an accelerometer to the ESP32 using the I2C bus, retrieving data from all of them with ease.Finally, the SPI (Serial Peripheral Interface) protocol is known for its high-speed, synchronous data transfer. The Arduino Uno has a fixed set of pins dedicated to SPI, which can be restrictive when you want to use other peripherals that might conflict with these pins. The ESP32, however, offers more versatility. It provides multiple SPI interfaces, such as VSPI and HSPI, and allows you to reconfigure the pins used for SPI communication through software. This means you can optimize the pin usage based on your project's requirements, whether it's interfacing with high-speed SD card readers, displays, or other SPI-compatible devices.In conclusion, the ESP32's enhanced support for these communication protocols makes it a more adaptable and powerful choice, especially for projects that demand complex interactions between multiple peripherals. Understanding these differences will help you make the most of your microcontroller and design more efficient and feature-rich projects.Wi-Fi and Bluetooth CapabilitiesOne of the most remarkable features of the ESP32 is its built-in Wi-Fi and Bluetooth capabilities, which open up a world of possibilities for wireless connectivity.The Wi-Fi functionality of the ESP32 supports three modes: Station, Access Point, and Dual Mode. In Station mode, the ESP32 functions much like your smartphone or laptop when it connects to an existing Wi-Fi network. This allows it to access internet services, download data, and interact with web APIs. For instance, you could build a weather display project that fetches real-time weather data from an online service. Or, you could even integrate GPT functionality, enabling your device to have intelligent conversations or perform advanced text-based tasks.In Access Point mode, the ESP32 creates its own Wi-Fi network. Other devices can then connect to this network, and you can host a web server on the ESP32. This means that other devices can send information to it via a web browser. You could use this to control a set of smart home devices connected to the ESP32, adjusting settings like lighting brightness or temperature, all through a simple web interface accessible from your phone or computer.The Dual Mode is where the ESP32 truly shines. It can simultaneously connect to an existing Wi-Fi network and act as an access point. This unique feature allows it to maintain internet access while also providing a direct connection for other devices. For example, in a local network setup, you could have multiple sensors connected to the ESP32's access point, and the ESP32 could then forward the collected data to an internet server in Station mode. This enables seamless data transfer between local devices and the wider internet.In addition to Wi-Fi, the ESP32 also supports Bluetooth connectivity. This allows it to pair with other Bluetooth-enabled devices, such as smartphones, tablets, or even other microcontrollers. You can use apps like "Dabble" to send information from your phone to the ESP32. This is incredibly useful for applications where a direct, short-range connection is needed. For instance, you could create a wearable device that sends health data, like heart rate or step count, to your phone for further analysis. Or, you could build a wireless control system for a robotic project, where commands are sent from a Bluetooth-connected device to the ESP32 to control the robot's movements.Overall, the Wi-Fi and Bluetooth capabilities of the ESP32 make it a versatile and powerful choice for a wide range of wireless applications, from home automation and IoT projects to wearable technology and robotics.ESP-NOW: A Unique Wireless ProtocolIn addition to Wi-Fi and Bluetooth, the ESP32 offers yet another powerful communication tool: the ESP-NOW protocol. Developed by Espressif, ESP-NOW is designed to enable direct, low-latency communication between multiple ESP32 devices without the need for a Wi-Fi router.Think of it as a dedicated, high-speed link that allows for quick data transfer. For example, in a home automation project, you could have multiple ESP32-based sensors scattered throughout your house. Instead of relying on Wi-Fi for every data transmission, which can introduce latency and consume more power, ESP-NOW can be used to send sensor readings from one node to another in real-time. This is especially useful for applications where immediate action is required, like a security system that needs to trigger an alarm as soon as a sensor detects an intrusion.Compared to Wi-Fi, ESP-NOW offers lower power consumption and faster response times for short-range, device-to-device communication. While Wi-Fi is great for connecting to the internet and handling large amounts of data over longer distances, ESP-NOW excels in scenarios where you need to quickly exchange small packets of information between nearby devices. In contrast to Bluetooth, ESP-NOW provides a more reliable and persistent connection. Bluetooth connections can sometimes be interrupted or have pairing issues, especially in environments with multiple devices. ESP-NOW's pairing process is more straightforward, and once paired, the connection remains stable, making it suitable for critical applications where data integrity and continuous communication are essential.To use ESP-NOW, you first need to pair the devices. This involves obtaining the MAC address of the receiving ESP32, which serves as its unique identifier. Once paired, you can send and receive data with minimal overhead. The protocol supports both encrypted and unencrypted communication, giving you the flexibility to choose the level of security based on your project's requirements. For instance, if you're transmitting sensitive data like personal health information from a wearable device to a central hub, you can opt for encryption to protect the data. On the other hand, for simple sensor readings in a less critical environment, unencrypted communication can save processing power.Overall, ESP-NOW expands the capabilities of the ESP32, making it an even more versatile choice for a wide range of projects, from industrial control systems to smart home networks and beyond. By leveraging this unique protocol, you can create more efficient, responsive, and reliable wireless applications.ConclusionIn conclusion, the ESP32 offers a remarkable upgrade over traditional Arduino boards, especially when it comes to wireless capabilities and processing power. Its ability to handle complex tasks, communicate seamlessly with other devices, and support a wide range of peripherals makes it a top choice for modern IoT and embedded projects. Whether you're a hobbyist looking to add some smart features to your home automation setup or a professional developer working on industrial-grade applications, the ESP32 has the potential to meet and exceed your expectations.Don't be afraid to dive in and start experimenting. The learning curve might seem a bit steep at first, but with the wealth of resources available, including online tutorials, forums, and official documentation, you'll be well-equipped to overcome any challenges. Remember, every great project starts with a single step, and the ESP32 could be that first step towards unlocking your creative potential in the world of microcontrollers. So, go ahead, grab your ESP32 board, and start building something amazing today!For further learning and exploration, here are some useful resources:Espressif Official Website: The home of ESP32, providing detailed technical specifications, product information, and the latest updates.Arduino IDE Download: To get started with programming your ESP32 using the familiar Arduino IDE.ESP32 Community Forum: A vibrant community where you can ask questions, share your projects, and learn from experienced developers.
Daisy On 2025-01-06   473
Robots

Arduino Based Line Follower Robot

catalogintroductionComponents RequiredBlock DiagramDescriptionHardwareWorkingArduino CodeApplicationsFuture WorkIntroductionA Line Follower Robot is an autonomous vehicle that follows a visual line on the floor or ceiling. The path of the line follower robot is typically a black line on a white surface, but it can also be a white line on a black surface. More advanced line follower robots use invisible magnetic fields as their guide.Large line follower robots are often utilized in industrial settings to aid in automated production processes, as well as in military, human assistance, and delivery services.The Line Follower Robot is often the first robotic project that beginners and students undertake, and in this project, we have developed a simple Line Follower Robot using Arduino and other components. Components RequiredArduino UNOL293D Motor Driver ICGeared Motors x 2Robot ChassisIR Sensor Module x 2Black Tape (Electrical Insulation Tape)Connecting WiresPower supplyBattery ConnectorBattery Holder Block Diagram  Hardware:Circuit Diagram of Arduino Based Line Following RobotThe primary controller utilized in this project is the Arduino UNO, which receives input data from the IR sensors and subsequently provides corresponding signals to the Motor Driver IC.The L293D Motor Driver IC is responsible for driving the motors of the robot, receiving signals from the Arduino based on the information obtained from the IR Sensors.It is important to note that the power supply provided to the motors must be from the motor driver IC, and thus it is necessary to select an appropriate power supply capable of powering all components, including the motors.Two geared motors have been implemented at the rear of the line follower robot, providing increased torque and the capability of carrying a load. WorkingWe have created a Line Follower Robot using Arduino, which operates by detecting a black line on a surface and following it. The project's operation is relatively straightforward and is explained in more detail below.As indicated in the diagram, sensors are necessary to detect the line. We utilized two IR Sensors for line detection, which include an IR LED and a Photodiode. The sensors are positioned side by side in a reflective manner so that when they come into contact with a reflective surface, the light emitted by the IR LED is detected by the Photodiode.The picture below demonstrates the operation of a typical IR Sensor (IR LED - Photodiode pair) in front of a light-colored surface and a black surface. The infrared light emitted by the IR LED will be mostly reflected and detected by the Photodiode since the reflectivity of the light-colored surface is high. If the surface is black and has low reflectivity, the light is completely absorbed by the black surface and doesn't reach the Photodiode.To apply the same principle, we will install the IR Sensors on the Line Follower Robot in such a way that the two sensors are on either side of the black line on the floor. The arrangement is depicted below. As the robot moves forward, both sensors are active and waiting to detect the line. If IR Sensor 1 detects the black line as shown in the image above, it implies that there is a right curve or turn ahead.Arduino UNO detects this variation and sends a signal to the motor driver to adjust accordingly. To turn right, the motor on the right-hand side of the robot is slowed down via PWM, while the motor on the left-hand side continues to operate at the normal speed. If the IR Sensor 2 detects the black line first, it indicates that there is a left curve ahead, and the robot must turn left. To execute a left turn, the motor on the left-hand side of the robot is slowed down (or can be halted entirely or turned in the opposite direction), while the motor on the right-hand side continues to operate at the normal speed.The Arduino UNO continually monitors information from both sensors and directs the robot to follow the line detected by them. Arduino Codeint mot1=9;int mot2=6;int mot3=5;int mot4=3;int left=13;int right=12;int Left=0;int Right=0;void LEFT (void);void RIGHT (void);void STOP (void);void setup(){  pinMode(mot1,OUTPUT);  pinMode(mot2,OUTPUT);  pinMode(mot3,OUTPUT);  pinMode(mot4,OUTPUT);  pinMode(left,INPUT);  pinMode(right,INPUT);  digitalWrite(left,HIGH);  digitalWrite(right,HIGH);    }void loop() { analogWrite(mot1,255);analogWrite(mot2,0);analogWrite(mot3,255);analogWrite(mot4,0);while(1){  Left=digitalRead(left);  Right=digitalRead(right);    if((Left==0 && Right==1)==1)  LEFT();  else if((Right==0 && Left==1)==1)  RIGHT();}}void LEFT (void){   analogWrite(mot3,0);   analogWrite(mot4,30);         while(Left==0)   {    Left=digitalRead(left);    Right=digitalRead(right);    if(Right==0)    {      int lprev=Left;      int rprev=Right;      STOP();      while(((lprev==Left)&&(rprev==Right))==1)      {         Left=digitalRead(left);         Right=digitalRead(right);      }    }    analogWrite(mot1,255);    analogWrite(mot2,0);    }   analogWrite(mot3,255);   analogWrite(mot4,0);}void RIGHT (void){   analogWrite(mot1,0);   analogWrite(mot2,30);   while(Right==0)   {    Left=digitalRead(left);    Right=digitalRead(right);    if(Left==0)    {      int lprev=Left;      int rprev=Right;     STOP();      while(((lprev==Left)&&(rprev==Right))==1)      {         Left=digitalRead(left);         Right=digitalRead(right);      }    }    analogWrite(mot3,255);    analogWrite(mot4,0);    }   analogWrite(mot1,255);   analogWrite(mot2,0);}void STOP (void){analogWrite(mot1,0);analogWrite(mot2,0);analogWrite(mot3,0);analogWrite(mot4,0);  } ApplicationsLine follower robots have a wide range of applications, including industrial automation, military uses, and consumer applications.Their capability to operate without human intervention, functioning as automatic guided vehicles, makes them highly beneficial.With the addition of features such as obstacle avoidance and other safety measures, line follower robots have the potential to be utilized in driverless cars. Future WorkTo improve the accuracy of black line detection, it is possible to add more sensors. An array of sensors is more precise than just two sensors.In this project, where only two sensors are utilized, their placement is critical for optimal performance. The size of the black line also influences the sensor placement.An alternative way to construct a line-detecting sensor is by using an LED and LDR pair.   
Karty On 2023-04-13   199
Sensor

Smart Walking Stick for Visually Impaired

CatalogIntroductionComponents RequiredSoftware RequiredHardwareUltrasonic Sensor (HC-SR04)WorkingCOMPLETE HARDWARESoftwareConclusion Future Enhancement in the Project IntroductionThe aim of this undertaking is to educate ourselves on the creation of a Blind Walking Stick that utilizes an Arduino and an Ultrasonic Sensor HC-SR04. There are Billions of people who are blind in this world. These individuals require assistance from others to navigate and move around as they are unable to do so independently. To address this issue, we have developed a device called the Blind Walking Stick which enables visually impaired individuals to walk more easily without relying on others for assistance. To enhance the device's accuracy and efficiency, two or three Ultrasonic Sensors can be incorporated into the project.  Components Required: Arduino UNO BoardHC-SR04 Ultrasonic SensorBuzzer9 Volt BatterySwitch (Optional) Software Required:Arduino IDE  Hardware: Connection of Ultrasonic Sensor with Arduino.  Vcc pin of Ultrasonic Sensor  is connected to 5-volt pin of ArduinoTrigger pin of Sensor is connected to D9 pin of ArduinoEcho pin of Sensor is connected to the D10 pin of ArduinoThe ground of Sensor is connected to the GND pin of Arduino.The positive terminal of the 9-volt battery is connected to the Vin pin of Arduino and the negative terminal is connected to the GND pin of Arduino.A buzzer is connected between the D9 pin of Arduino and the GND pin Ultrasonic Sensor (HC-SR04)An electronic device known as an ultrasonic sensor is utilized to determine the distance of an object by emitting ultrasonic sound waves and then transforming the reflected sound into an electrical signal. These ultrasonic waves travel at a faster rate than audible sound, which cannot be perceived by humans. The ultrasonic sensor is comprised of two major components: the transmitter, which uses piezoelectric crystals to emit the sound, and the receiver, which detects the sound after it has traveled to and from the object. To compute the distance between the object and the sensor, the sensor calculates the time taken for the sound to travel from the transmitter to the receiver. This calculation is based on the formula D = ½ T x C, where D represents distance, T denotes time, and C is the speed of sound, roughly 343 meters/second. As an illustration, if an ultrasonic sensor is pointed at a box and it takes 0.025 seconds for the sound to return, then the distance between the sensor and the box can be calculated.D = 0.5 x 0.025 x 343  Ultrasonic sensors are used primarily as proximity sensors. They can be found in automobile self-parking technology and anti-collision safety systems. Ultrasonic sensors are also used in robotic obstacle detection systems, as well as manufacturing technology. In comparison to infrared (IR) sensors in proximity sensing applications, ultrasonic sensors are not as susceptible to interference of smoke, gas, and other airborne particles (though the physical components are still affected by variables such as heat).  Ultrasonic sensors are also used as level sensors to detect, monitor, and regulate liquid levels in closed containers (such as vats in chemical factories). Most notably, ultrasonic technology has enabled the medical industry to produce images of internal organs, identify tumors, and ensure the health of babies in the womb. WorkingThe primary aim of this project is to facilitate blind individuals in walking without difficulty and provide them with alerts whenever their path is obstructed by obstacles. The device utilizes a buzzer that emits a warning signal, the frequency of which changes based on the distance of the object. The buzzer will beep more frequently when the obstruction is closer. The core component used in the device is the Ultrasonic Sensor HC-SR04, which functions by transmitting a high-frequency sound pulse and then measuring the time taken to receive the sound echo reflection. The sensor is equipped with a transmitter and a receiver surface, with one transmitting ultrasonic waves and the other receiving the echoed sound signal. The sensor's calibration is based on the speed of sound in air, which is approximately 341 meters per second. After the distance measurement, Arduino makes a beep format using a buzzer also the led glow as well, The frequency of the beep is reduced when the distance is greater, and increased when the distance is shorter. COMPLETE HARDWARE  This is the Complete Hardware of our Project. Since this is a Prototype circuit so we used Selfie stick because it can extend and also We did not used 9V battery but instead we used 2 Lithium Ion cell and one rechargeable circuit to charge these cells, but for simple explanation of the project 9v battery can be used. We used On and Off simple switch to power On and Off the circuit and at the front of the stick we placed our Buzzer, Arduino and Ultrasonic Sensor. You can build the hardware the way you like but the circuit remains same.      Software // defines pins numbersconst int trigPin = 9;const int echoPin = 10;const int buzzer = 11;const int ledPin = 13; // defines variableslong duration;int distance;int safetyDistance;  void setup() {pinMode(trigPin, OUTPUT); // Sets the trigPin as an OutputpinMode(echoPin, INPUT); // Sets the echoPin as an InputpinMode(buzzer, OUTPUT);pinMode(ledPin, OUTPUT);Serial.begin(9600); // Starts the serial communication}  void loop() {// Clears the trigPindigitalWrite(trigPin, LOW);delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro secondsdigitalWrite(trigPin, HIGH);delayMicroseconds(10);digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microsecondsduration = pulseIn(echoPin, HIGH); // Calculating the distancedistance= duration*0.034/2; safetyDistance = distance;if (safetyDistance <= 5){  digitalWrite(buzzer, HIGH);  digitalWrite(ledPin, HIGH);}else{  digitalWrite(buzzer, LOW);  digitalWrite(ledPin, LOW);} // Prints the distance on the Serial MonitorSerial.print("Distance: ");Serial.println(distance);}   Conclusion Smart Walking Stick is very useful especially for blind people who want to go out for a walk. It helps them to walk smoothly  Future Enhancement in the Project We can add GPS in order to pinpoint the exact location of the personAlso we can add Voice recognition system which can tell where we are going and if any obstacle comes in our way it will let us know
Kynix On 2023-03-21   294
IC Chips

Arduino Based Home Security Alarm System

Catalog IntroductionComponentsArduino Code Introduction The idea of this project is to create an Arduino based home security alarm system that can be used to monitor and control the various appliances in the house. The main purpose of the system is to detect any unusual activity and notify the user about it in an efficient manner. The system will also use a web server to push notifications to mobile devices such as smartphones and tablets. The project consists of an Arduino Uno board connected to a Debounce shield which contains a piezo buzzer, LED, power supply and other components necessary for interfacing with Arduino Uno board. A passive infrared sensor, or PIR, is a Pyroelectric device that senses motion. For this reason, it is sometimes referred to as a motion detecting sensor. It may be able to detect motion by detecting variations in the infrared levels emitted by nearby objects. This gadget is a basic motion-activated alarm. Its brain is an Arduino microcontroller. It is connected to a PIR motion sensor, a buzzer, a resistor, and two external connectors. The system is very portable because it is entirely battery-powered. As soon as you get the code, you may link all of the external components. This is the easiest thing to do with a breadboard. To check everything out, you can create bogus connections.  The whole system Is powered by 12V DC power supply which powers all other components except Arduino Uno board itself. The MCU receives digital commands from Arduino Uno through SCI interface and sends appropriate analog or digital signals on its pin according to the command received by it. This project has been inspired by many previous projects that use Arduino boards for controlling various electronic devices such as lamps, lights etc., but this project focuses more on controlling various appliances. The Arduino Uno Is based on the ATmega328 chip, which has built-in USB support for serial communications. It also has a built-in 5V power regulator that allows it to be powered directly from the USB connection or from a battery. Components 1Arduino2Motion Sensor3LED’s4Buzzer5LCD Module Arduino Code#include  <LiquidCrystal.h>   int ledPin = 13;                int inputPin = 7;               int pirState = LOW;             int val = 0;                    int pinSpeaker = 10;           LiquidCrystal lcd(12, 11, 5, 4, 3, 2);                           void setup() {  pinMode(ledPin, OUTPUT);  pinMode(pinSpeaker, OUTPUT);  Serial.begin(9600);  lcd.begin(16, 2);  lcd.setCursor(2, 0);                                              lcd.print("P.I.R Motion");                                        lcd.setCursor(5, 1);                                             lcd.print("Sensor");                                              delay(4000);  lcd.clear();  lcd.setCursor(2, 0);                                              lcd.print("Displaying");                                       lcd.setCursor(2, 1);                                              lcd.print("A");                                         delay(5000);                                                      lcd.clear();                                                    lcd.setCursor(0, 0);      lcd.print("Processing Data.");      delay(3000);      lcd.clear();      lcd.setCursor(3, 0);      lcd.print("Waiting For");      lcd.setCursor(3, 1);      lcd.print("Motion....");     }void loop(){  val = digitalRead(inputPin);  if (val == HIGH) {                digitalWrite(ledPin, HIGH);      playTone(300, 300);    delay(150);        if (pirState == LOW) {      Serial.println("Motion detected!");      lcd.clear() ;      lcd.setCursor(0, 0);                                                 lcd.print("Motion Detected!");             pirState = HIGH;    }  } else {      digitalWrite(ledPin, LOW);      playTone(0, 0);      delay(300);         if (pirState == HIGH){            Serial.println("Motion ended!");      lcd.clear() ;      lcd.setCursor(3, 0);      lcd.print("Waiting For");      lcd.setCursor(3, 1);      lcd.print("Motion....");            pirState = LOW;    }  }}// duration in mSecs, frequency in hertzvoid playTone(long duration, int freq) {    duration *= 1000;    int period = (1.0 / freq) * 100000;    long elapsed_time = 0;    while (elapsed_time < duration) {        digitalWrite(pinSpeaker,HIGH);        delayMicroseconds(period / 2);        digitalWrite(pinSpeaker, LOW);        delayMicroseconds(period / 2);        elapsed_time += (period);    }} 
Kynix On 2023-02-07   507
LED

LCD Interface Types Explained with Details

Introduction There are many kinds of LCD interfaces, with wide range of applications. The classification criteria mainly depends on the driving mode and control mode of the LCD. At present, there are generally several connection modes for color LCDs on mobile phones: MCU mode, RGB mode, SPI mode, VSYNC mode, MDDI mode, DSI mode, etc. and only the TFT module has RGB interface. Basics of LCD Interfacing Catalog Introduction Ⅰ LCD Interface Modes 1.1 MCU Mode 1.2 VSYNC Mode 1.3 M6800 Mode 1.4 Intel 8080 Mode 1.5 RGB Mode 1.6 SPI (Serial Peripheral Interface) Mode 1.7 MDDI (Mobile Display Digital Interface) Mode 1.8 DSI (Display Serial Interface) Mode Ⅱ MCU Mode vs RGB Mode Ⅲ TFT-LCD Interface Explained 3.1 TTL Interface 3.2 LVDS 3.3 EDP (Embedded Display Port) 3.4 MIPI Interface Ⅳ FAQ Ⅰ LCD Interface Modes The following is a detailed explanation of the different interface modes: 1.1 MCU Mode It is mainly used in the field of single-chip microcomputers. Later, it is widely used in low-end mobile phones, and its main feature is that it is cheap. The standard term for the MCU-LCD interface is the 8080 bus standard proposed by Intel. Figure 1. Intel 8080 Therefore, 8080 is used to refer to the MCU-LCD screen in many documents. It can be mainly divided into 8080 mode and 6800 mode, and the difference between the two is mainly the timing. There are 8 bits, 9 bits, 16 bits, 18 bits, and 24 bits for data bit transfer. Connections are divided into: CS/, RS (register selection), RD/, WR/, and data lines. The advantages are: the control is simple and convenient, no clock and synchronization signals are required. The disadvantage is: it consumes GRAM, so it is difficult to achieve a large screen (above 3.8). For LCM with MCU interface, the internal chip is called LCD driver. The main function is to transform the data/command sent by the host into the RGB data of each pixel, so that it can be displayed on the screen. This process does not require point, line, frame clocks.The LCD Driver IC of the MCU interface is equipped with GRAM. As a co-processor of the MCU, it accepts the Command/Data sent by the MCU and can work relatively independently. Pay attention to, the internal chip of LCD Module (LCM) is called the LCD driver. The main function is to transform the data/commands sent by the host computer into the RGB data of each pixel, so that it can be displayed on the screen. This process also does not require point, line, frame clocks. 1.2 VSYNC Mode In fact, this mode is to add a VSYNC signal to the MCU mode and applied to the update of the moving picture, which is very different from the above interface. This mode supports the function of direct animation display. It provides a solution for animation display with minimal changes to the MCU interface. In this mode, the internal display operation is synchronized with the external VSYNC signal. Animation display at a higher rate than internal operations can be achieved. However, due to the difference in its operation mode, this mode has a limit on the speed, that is, the write speed to the internal SRAM must be greater than the speed of the display read internal SRAM. 1.3 M6800 Mode The M6800 mode supports selectable bus widths of 8/9/16/18-bit (the default is 8 bits). The actual design idea is the same as that of Intel 8080. The main difference is the bus control read and write signals in this mode. Combined on one pin (with a latch signal (E) data bit transmission has 8, 9, 16 and 18 bits). Figure 2. M6800 Mode 1.4 Intel 8080 Mode Intel 8080 LCD interface is divided into: CS/, RS (register selection), RD/, WR/, and the data line. Advantage: Simple and convenient control, no clock and synchronization signals are required. Disadvantage: It consumes GRAM, so it is difficult to achieve a large screen (above QVGA). Figure 3. Intel 8080 Mode 1.5 RGB Mode The large screen adopts more modes, and the data bit transmission also has the 6-, 16- and 18-, 24-bit. The connections are generally: VSYNC, HSYNC, DOTCLK, CS, RESET, some also need RS, and the rest is the data line. Its advantages and disadvantages are just the opposite of MCU mode. The main difference between the MCU-LCD screen and the RGB-LCD screen is the location of the video memory. The video memory of RGB-LCD is acted by system memory, so its size is only limited by the size of system memory. Where RGB-LCD can be made larger, such as 4.3" can only be regarded as entry-level, and 7" in MID, 10" screens have begun to be widely used. At the beginning of the design of MCU-LCD, it was only necessary to consider that the memory of the single-chip microcomputer was small, so the video memory was built into the LCD module, and then the software updated the video memory through special display commands with small MCU screen. At the same time, the display update speed is slower than RGB-LCD. The display data transmission mode is also different. RGB screen only needs to organize the data in the video memory. After starting the display, the LCD-DMA will automatically transfer the data in the video memory through the RGB interface to the LCM, while the MCU screen needs to send a drawing command to modify the internal RAM of the MCU (that is, the RAM of the MCU screen cannot be directly written).Therefore, the RGB display speed is significantly faster than that of the MCU, and the MCU-LCD is also slower in terms of video playback. For the LCM of the RGB interface, the host directly outputs the RGB data of each pixel without conversion (except for GAMMA correction, etc.). For this interface, an LCD controller is required in the host part to generate RGB data and sync signals. Figure 4. RGB Mode Here gives a note. The color TFT LCD screen mainly has 2 kinds of interfaces: TTL interface (RGB color interface), and LVDS interface (differential signal transmission). The TTL interface is mainly used for small-sized TFT screens below 12.1 inches, and the LVDS interface is mainly used for large-sized TFT screens above 8 inches. The TTL interface has many lines and the transmission distance is short, while the LVDS interface has a long transmission distance and a small number of lines. The large screen adopts more modes, the control pins are VSYNC, HSYNC, VDEN, VCLK, S3C2440 supports up to 24 data pins, and the data pin is VD[23-0].The image data sent by the CPU or graphics card is a TTL signal (0-5V, 0-3.3V, 0-2.5V, or 0-1.8V), and the LCD itself also receives a TTL signal, which is transmitted at a high rate over long distances. However, its performance is poor, and the anti-interference ability is relatively poor. With the time goes by, a variety of transmission modes were proposed, such as LVDS, TDMS, GVIF, P&D, DVI and DFP. They actually just encode the TTL signal sent by the CPU or graphics card into various signals for transmission, and decode the received signal on the LCD side to obtain the TTL signal. No matter what transmission mode is used, the essential TTL signal is the same. Note: TTL/LVDS are two signal transmission modes: TTL is a mode in which high level means 1, and low level means 0; LVDS is the difference of a positive and negative corresponding waveform used to indicate the 1 or 0. 1.6 SPI (Serial Peripheral Interface) Mode It is less used. There are 3-wire and 4-wire, the connection is CS/, SLK, SDI, and SDO, and the software control is more complicated. 1.7 MDDI (Mobile Display Digital Interface) Mode  Qualcomm's MDDI, which can improve the reliability of mobile phones and reduce power consumption by reducing wiring. It will replace SPI mode as a high-speed serial interface in the mobile field. The main connection is host_data, host_strobe, client_data, client_strobe, power, and GND. 1.8 DSI (Display Serial Interface) Mode This mode is a serial bidirectional high-speed command transmission mode, with D0P, D0N, D1P, D1N, CLKP, CLKN connected.   Ⅱ MCU Mode vs RGB Mode Among them, there are more applications in MCU mode and RGB mode. The differences are as follows:1) MCU interface: it will decode commands, generate timing signals by timing generator, and drive COM and SEG.RGB interface: When writing LCD register setting, it is no different from MCU interface. The difference is only in how the image is written.2) When using the MCU mode, since the data can be stored in the IC's internal GRAM first and then written to the screen, the LCD in this mode can be directly connected to the memory bus. It is different when using RGB mode, and has no internal RAM, HSYNC, VSYNC, ENABLE, CS, RESET, RS can be directly connected to the GPIO port of memory, and use the GPIO port to simulate waveforms.3) MCU Interface vs RGB InterfaceThe main differences between the MCU interface and the RGB interface are:MCU interface mode: display data is written into DDRAM, often used for still picture display.RGB interface mode: The display data is not written into DDRAM, but directly written to the screen, which is fast and often used to display video or animation.   Ⅲ TFT-LCD Interface Explained The commonly used interfaces of TFT-LCD, including TTL (RGB), LVDS, EDP, and MIPI. Here roughly talk about the basic principles of the signal composition of these interfaces. Figure 5. TTL (Transistor-Transistor Logic) Schematic 3.1 TTL Interface 🔺Interface OverviewTTL is transistor-transistor logic, and TTL level signals are generated by TTL devices. TTL devices are a large category of digital integrated circuits. They are manufactured by bipolar technology and have the characteristics of high speed, low power consumption and many varieties.The TTL interface is an interface for transmitting data in parallel. When using it, it is not necessary to use a dedicated interface circuit at the driver board end and the LCD panel end of the liquid crystal display, but the TTL data signal output by the main control chip of the driver board is transmitted through the cable. It is directly transmitted to the input interface of the LCD panel. Due to the high signal voltage, many connections and long transmission cables of the TTL interface, the anti-interference ability of the circuit is relatively poor, and it is easy to generate electromagnetic interference (EMI). In practical applications, TTL interface circuits are mostly used to drive small-size (below 15in) or low-resolution LCD panels. The highest pixel clock of TTL is only 28MHz.TTL is the only signal that TFT-LCD can recognize. Early digital processing chips are all TTL, that is, RGB is directly output to TFT-LCD.🔺Signal TypesThe TTL output interface of the driver board generally includes three types of signals: RGB data signal, clock signal and control signal. As shown below:(1) RGB Data-Signala. Single Channel6-BitAs for it, there are 18 RGB data lines in total, including 6 R0~R5 red primary color data lines, 6 G0~G5 green primary color data lines, 6 B0~B5 blue primary color data lines, a total of 18 strips. Since the primary color RGB data is 18bit, it is also called 18-bitTTL interface.8-BitFor it, there are a total of 24 RGB data lines, including 8 R0~R7 red primary color data lines, 8 B0~B7 green primary color data lines, 8 BO~B7 blue primary color data lines, a total of 24 strips. Since the primary color RGB data is 24-bit, it is also called 24-bit TTL interface.b. Dual ChannelDual channels, that is, two sets of RGB data, which are divided into odd channels and even channels. Some clocks are also divided into OCLK/ECLK, and some share one. The following figure has two, as shown below:6-BitIt has 36 RGB data lines in total, including 18 odd RGB data lines, 18 even RGB data lines. Since the primary color ROB data is 36-bit, it is also called 36-bitTTL interface.8-BitIt has 48 RGB data lines, including 24 odd RGB data lines and 24 even RGB data lines. Since the primary color RGB data is 48bit, it is also called 48-bit TTL interface.(2) Clock SignalIt refers to the pixel clock signal, which is the benchmark for transmitting data and reading the data signal. When using odd/even pixel dual way to transmit RGB data, different output interfaces use different methods of pixel clock. Some output interface odd/even pixel dual data share a pixel clock signal, and the others set odd pixel data clock and even pixel two clock signals to meet the needs of different LCD panels.(3) Control SignalThe control signals include a data enable signal (or an effective display data strobe signal) DE, a horizontal sync signal HS, and a vertical sync signal VS. 3.2 LVDS 🔺Overview of LVDS InterfaceLVDS is a low-voltage differential signaling technology interface. A digital video signal transmission method developed to overcome the shortcomings of large power consumption and large EMI electromagnetic interference when transmitting broadband high bit rate data in TTL level mode. The LVDS output interface uses a very low voltage swing (about 350mV) to transmit data differentially on two PCB traces or a pair of balanced cables, that is, low-voltage differential signaling. Using the LVDS output interface, the signal can be transmitted at a rate of several hundred Mbit/s on the differential PCB line or balanced cable. Due to the low-voltage and low-current driving method, low noise and low power consumption are achieved.🔺Composition of LVDS Interface CircuitIn a liquid crystal display, the LVDS interface circuit includes two parts, the LVDS output interface circuit (LVDS transmitter) on the motherboard side and the LVDS input interface circuit (LVDS receiver) on the LCD panel side. The LVDS emitter converts the TTL signal into an LVDS signal, and then transmits the signal to the LVDS decoding IC on the receiving end through the flexible cable (line) between the driver board and the LCD panel, and the LVDS receiver then serializes the serial signal which is converted into a parallel signal of TTL level, and sent to the LCD screen timing control and row and column drive circuit. In other words, TFT only recognizes TTL (RGB) signals.🔺Signal type of LVDS interfaceLVDS signals are composed of data differential and clock differential signals. As shown below:(1) Single Channel6-Bit DataThere are 4 sets of differential lines, 3 sets of signal lines, and one set of clock lines, including Y0M, Y0P, Y1M, Y1P, Y2M, Y2P, CLKOUT_M, CLKOUT_P.8-Bit DataThere are 5 groups of differential lines, 4 groups of signal lines, and a group of clock lines. They are Y0M, Y0P, Y1M, Y1P, Y2M, Y2P, CLKOUT_M, CLKOUT_P.(2) Dual ChannelWhen LVDS transmits data with higher resolution, the anti-interference ability is relatively strong. But when the resolution is higher than 1920×1080, the single channel is overwhelmed, so there is a dual interface. Its purpose is very simple, speed up and enhance anti-interference ability.6-Bit DataIt is exactly twice as long as the single channel, and the clock is also two channels. The red part: the two sets of signals: Y3M, Y3P, Y3M1, and Y3M1 are not connected.8-Bit DataSimilar to the previous comparison. 3.3 EDP (Embedded Display Port) EDP is a communication interface of the computer display screen. The resolution of the computer using the EDP display interface will be higher than that of the LVDS interface. Generally, high-definition screens use this communication interface. It is a fully digital interface based on the DisplayPort architecture and protocol. It can transmit high-resolution signals with simpler connectors and fewer pins, and can achieve simultaneous transmission of multiple data, so the transmission rate is much higher than LVDS. 3.4 MIPI Interface Compared with the LVDS interface, the MIPI interface is rare, but in fact, it has many advantages. The MIPI interface module has the advantages of high speed, large amount of data transmission, low power consumption, and good anti-interference when compared with the parallel port. It is more and more favored by customers and is growing rapidly. For example, an 8M module with both MIPI and parallel port transmission requires at least 11 transmission lines and an output clock of up to 96M to achieve a full pixel output of 12FPS when using an 8-bit parallel port. Channel 6 transmission lines can achieve a frame rate of 12FPS at full pixels, and the current consumption will be about 20MA lower than that of parallel port transmission. Since MIPI uses differential signal transmission, the design needs to be strictly designed according to the general rules of differential design. The key is to achieve differential impedance matching. The MIPI protocol stipulates that the differential impedance of the transmission line is 80-125 ohms.   Ⅳ FAQ 1. What is LCD interface?16x2 LCD means that there are two rows in which 16 characters can be displayed per line, and each character takes 5X7 matrix space on LCD. ... In this tutorial we are going to connect 16X2 LCD module to the 8051 microcontroller (AT89S52). 2. What is LCD parallel interface?LCD Displays that use a parallel interface include Character, Graphic and TFT. ... The initial step is to energize the LCD. Reads and Writes are sent via 8 data lines and 3 control lines. These control lines are Read/Write (R/W), Enable (E) and Register Select (RS). 3. What is TFT interface?A TFT LCD display module consists of a TFT LCD panel, one or more COG (chip-on-glass) or COB (chip-on-board) driver ICs, a backlight, and an interface. Several TFT display interface technologies exist today. Picking the right interface depends on specific end-product concerns. 4. What are the different types of LCDs?Different Types of LCD PanelsTwisted Nematic (TN) Twisted Nematic LCDs are the most commonly manufactured and used types of monitors across a wide range of industries. ...IPS Panel TechnologyVA PanelAdvanced Fringe Field Switching 5. What is MCU interface?The MCU interface has two standard types, the Intel-8080 and Motorolla-6800 series. These interfaces communicate through read, write and chip-select signals to address registers or display RAM. The slight difference between the two pertains to the direction and separation of the write and read signals. 6. What is MCU interface LCD?These interfaces communicate through read, write and chip-select signals to address registers or display RAM. Depending on color depth (8, 9, 16 or 18-bit), MCU sends RGB signals directly to LCM's display memory. 7. Is TFT an LCD?TFT is a kind of LCD. The TFT(Thin Film Field-effect Transistor) is a video in which every single pixel in the liquid crystal display is actuated by a Thin Film Transistor embedded in the rear. Thus can achieve high speed, high brightness, high contrast display screen information.
kynix On 2022-01-18   2944
Motors, Solenoids, Driver Boards/Modules

Servo Motors:Control with an Arduino and Raspberry Pi

Introduction In this lesson, we'll look at what a servo motor is and how it works. First, let's define what a servo motor is and look at some of the unique characteristics of the different types of servo motors and their applications. You will also learn how to control Servo Motors with an Arduino and a Raspberry Pi in this blog. Introduction Ⅰ What is a Servo Motor? Ⅱ Servo Motor Related Video: Ⅲ Types of Servo Motors 3.1 AC or DC 3.2 Brushed or Brushless 3.3 Synchronous or Asynchronous Ⅳ Servo Motor Working Principle Ⅴ Applications of Servo Motors Ⅵ Difference Between Stepper Motor and Servo Motor  Ⅶ Servo Motors Control with an Arduino  7.1 Experiment 1 Ⅷ Control with  Raspberry Pi 8.1 PWM (Pulse Width Modulation) 8.2 Components Required 8.3 Circuit Diagram 8.4 Working and Programming Explanation 8.5 Code Ⅸ FAQ   Ⅰ What is a Servo Motor? A servo motor is a self-contained electrical device that rotates machine parts with high efficiency and precision. This motor's output shaft can be moved to a specific angle, position, and velocity that a standard motor cannot. The Servo Motor  combines a standard motor with a sensor to provide positional feedback. The most important component of the Servo Motor  designed and used specifically for this purpose is the controller  . Figure1:Servo Motor      Ⅱ Servo Motor Related Video:   How servo motor works   Servo Motor Video Description: This movie gives an overview of how RC servo motor works and how it's made.   Ⅲ Types of Servo Motors Servo motors are classified into two types based on their application: AC servo motors  and  DC  servo motors. There are three major factors to consider when evaluating servo motors. The first type of consideration is the current type –  AC  or  DC – and the second type of consideration is the type of commutation used, whether the motor uses brushes. The third type of consideration is the motor's rotating field, the rotor, and whether the rotation is synchronous or asynchronous.   3.1 AC or DC Let's start with the first servo consideration. The most fundamental classification of a motor is based on the type of current it will use. When it comes to performance, the primary distinction between  AC and DC motor  s is their inherent ability to control speed. Figure2:DC or AC Servo Motor  With a constant load, the speed of a DC motor  is directly proportional to the supply voltage. The frequency of the applied voltage and the number of magnetic poles determine the speed of an alternating current motor.   Figure3:DC or AC Servo Motor  While both AC and DC motor  s are used in servo systems, AC motors  can handle more current and are more commonly used in servo applications such as robots, in-line manufacturing, and other industrial applications requiring high repetitions and precision.   3.2 Brushed or Brushless The next step is to decide whether to use a brushed or brushless finish. A DC Servo Motor  can be commutated mechanically with brushes, electronically without brushes, or mechanically with a commutator. Brushed motors are less expensive and easier to operate in general, whereas brushless designs are more reliable, have higher efficiency, and are quieter.   Figure4:brushed or brushless Servo Motor  A commutator is a rotary electrical switch that reverses the current direction between the rotor and the drive circuit on a regular basis. It is made up of a cylinder made up of multiple metal contact segments on the rotor. Two or more electrical contacts known as "brushes" made of a soft conductive material such as carbon press against the commutator, making sliding contact with commutator segments as it rotates. Figure5:brushed or brushless Servo Motor  While the majority of servo motors are AC brushless designs, brushed permanent magnet motors are occasionally used as servo motors due to their simplicity and low cost. The permanent magnet DC motor  is the most common type of brushed DC motor  used in servo applications. Figure6:brushed or brushless Servo Motor  Brushless DC motors replace the physical brushes and commutator with an electronic commutation method, typically using Hall effect sensors or an encoder. Figure7:brushed or brushless Servo Motor  AC motors are generally brushless, though some designs do have brushes and are mechanically commutated, such as the universal motor, which can run on either AC or DC power. Figure8:brushed or brushless Servo Motor      3.3 Synchronous or Asynchronous While DC motor  s are generally classified as brushed or brushless, AC motors  are often distinguished by the rotational speed of their synchronous or asynchronous field. If we recall from the AC-DC discussion, the frequency of the supply voltage and the number of magnetic poles determine the speed of an AC motor. This speed is known as the synchronous speed. As a result, in a synchronous motor, the rotor rotates at the same rate as the rotating magnetic field of the stator. Figure9:synchronous or asynchronous Servo Motor  In an asynchronous motor, also known as an induction motor, the rotor rotates at a slower rate than the stator's rotating magnetic field. However, the speed of an asynchronous motor can be varied using a variety of control methods, including changing the number of poles and changing the frequency, to name a few. Figure10:synchronous or asynchronous Servo Motor      Ⅳ Servo Motor Working Principle A servo is made up of a motor (either DC or AC), a potentiometer, a gear assembly, and a control circuit. First and foremost, we use gear assembly to reduce RPM and increase motor torque. Assume that at the initial position of the servo motor shaft, the position of the potentiometer knob is such that no electrical signal is generated at the potentiometer's output port. An electrical signal is now applied to the error detector amplifier's other input terminal. The difference between these two signals, one from the potentiometer and one from other sources, will now be processed in a feedback mechanism and output will be provided in the form of an error signal. This error signal serves as the motor's input, and the motor begins to rotate. The motor shaft is now connected to the potentiometer, and as the motor rotates, so does the potentiometer, generating a signal. As a result, as the potentiometer's angular position changes, so does its output feedback signal. After a while, the position of the potentiometer reaches a point where the output of the potentiometer is the same as the external signal provided. There will be no output signal from the amplifier to the motor input because there is no difference between the externally applied signal and the signal generated at the potentiometer in this condition, and the motor will stop rotating. Figure11:synchronous or asynchronous Servo Motor    Ⅴ Applications of Servo Motors Servo Motors are used in a variety of applications, some of which are listed below:In robotics, the servo motor is used to activate movements, giving the arm its precise angle.The servo motor is used to start, move, and stop conveyor belts that transport the product through multiple stages. As an example, consider product labeling, bottling, and packaging.The servo motor is built into the camera to correct a lens and improve out-of-focus images.In a robotic vehicle, the servo motor is used to control the robot wheels, producing enough torque to move, start, and stop the vehicle as well as control its speed.In a solar tracking system, the servo motor is used to correct the angle of the panel so that each solar panel faces the sun.The servo motor is used in metal forming and cutting machines to provide milling machines with precise motion control.Textiles use servo motors to control spinning and weaving machines, knitting machines, and looms.The Servo motor is used in automatic door openers in public places such as supermarkets, hospitals, and theaters to control the door.   Ⅵ Difference Between Stepper Motor and Servo Motor  Comparison Chart Basis for ComparisonStepper MotorServo MotorBasicStepper motor operates in steps.It is continuous operating machine.System configurationOpen loopClosed loopPower requirementMoreComparatively lessDesignSimpleComplexAbility to responseHighComparatively lowCostInexpensiveExpensiveReliabilityMoreLessNoise and vibrationHighComparatively lessOperating speedSlowFastFeedback mechanismNot existExistHeat generationMoreComparatively lessNumber of polesGenerally 50 to 150Around 4 to 12Life spanMoreLessDamage due to overloadLess prone to get damaged.Comparatively more prone to get damaged.Torque producedHighLowEfficiencyLessMoreTolerance towards moment of inertiaHighLowApplicationsIn gaming, textile, welding machineries, medical and 3D printing equipments, etc.In robotics, antenna positioning systems, automatic doors, cameras, remote controlled equipments, etc. Ⅶ Servo Motors Control with an Arduino  You can connect small servo motors directly to an Arduino  to control the shaft position very precisely. Most servo motors have the following three connections: Black/Brown ground wire.Red power wire (around 5V).Yellow or White PWM wire. In this experiment, the power and ground pins will be connected directly to the Arduino  5V and GND pins. The PWM input will be connected to a digital output pin on the Arduino,  7.1 Experiment 1 Hardware Required1 x TowerPro SG90 servo motor1 x Arduino  Mega25603 x jumper wires   Wiring Diagram The best thing about servo motors is that they can be directly connected to an  Arduino ,  Connect the motor to the Arduino  in the manner shown in the table below: Servo red wire – 5V pin Arduino          Servo brown wire – Ground pin Arduino          Servo yellow wire – PWM(9) pin Arduino  Caution: Do not try to rotate the servo motor by hand, as you may damage the motor.     Figure12: Wiring Diagram Code When the program starts, the servo motor will slowly rotate from 0 to 180 degrees, one degree at a time. When the motor has rotated 180 degrees, it will start rotating in the opposite direction until it reaches the home position. #include //Servo library Servo servo_test; //initialize a servo object for the connected servo int angle = 0; void setup() { servo_test.attach(9); // attach the signal pin of servo to pin9 of arduino} void loop() { for(angle = 0; angle < 180; angle += 1) // command to move from 0 degrees to 180 degrees { servo_test.write(angle); //command to rotate the servo to the specified angle delay(15); } delay(1000); for(angle = 180; angle>=1; angle-=5) // command to move from 180 degrees to 0 degrees { servo_test.write(angle); //command to rotate the servo to the specified angle delay(5); } delay(1000);} Ⅷ Control with  Raspberry Pi In this tutorial, we will use the Raspberry Pi  to control a servo motor. Before we get to the servo, let's talk about PWM because it's the basis for controlling a servo motor.   8.1 PWM (Pulse Width Modulation) PWM is an abbreviation for 'Pulse Width Modulation.' PWM is a technique for obtaining variable voltage from a steady power supply. Consider the circuit below to better understand PWM.   Figure13:PWM   In the figure above, if the switch is closed continuously for a period of time, the LED will be 'ON' during that time. If the switch is closed for half a second and then opened for the next half a second, the LED will be turned on only for the first half a second. The percentage of time the LED is on over the total time is known as the  Duty Cycle , and it can be calculated as follows:   Duty Cycle =Turn ON time/ (Turn ON time + Turn OFF time) Duty Cycle = (0.5/ (0.5+0.5)) = 50% As a result, the average output voltage will be 50% of the battery voltage. When we increase the ON and OFF speed to a certain level, the LED will dim instead of being ON and OFF. This is because our eyes cannot clearly detect frequencies higher than 25Hz. Consider a 100ms cycle with an LED that is off for 30msec and on for 70msec. We will have 70% stable voltage at the output, so the LED will glow continuously at 70% intensity. The Duty Ratio ranges from 0 to 100. '0' denotes complete inactivity, while '100' denotes complete activation. This Duty Ratio is critical for Servo Motor,  This Duty Ratio determines the position of the Servo Motor,    8.2 Components Required We're running Raspbian Jessie on a Raspberry Pi  2 Model B. All of the basic hardware and software requirements have already been discussed, and you can find them in the Raspberry Pi  Introduction; however, we will need: Connecting pins 1000uF capacitor SG90  Servo Motor  Breadboard   8.3 Circuit Diagram Figure14:Circuit Diagram If A1000F is not connected across the +5V power rail, the  PI  may shut down unexpectedly while controlling the servo.   8.4 Working and Programming Explanation Once everything is connected according to the circuit diagram, we can power on the  PI and begin writing the program in PYHTON. We will go over a few commands that we will use in the PYHTON program. We will import a GPIO file from the library, and the function below will allow us to program the GPIO pins on the PI. We're also renaming "GPIO" to "IO," so in the program, whenever we refer to GPIO pins, we'll say "IO." import RPi.GPIO  as IO When the GPIO pins that we are attempting to use are performing other functions. In that case, we'll get warnings while running the program. The following command instructs the PI to disregard the warnings and continue with the program. IO.setwarnings(False) We can refer to the GPIO pins of the PI by either their pin number on the board or their function number. On the board, for example, 'PIN 29' is 'GPIO5'. So we specify whether we want to represent the pin here by '29' or '5'. IO.setmode (IO.BCM) PIN39 or GPIO19 is selected as the output pin. This pin will provide PWM output. IO.setup(19,IO.OUT) After we have set the output pin, we must configure it as a PWM output pin. p equals IO. Power-Wave Modulation (PWM) (output channel, frequency of PWM signal) The above command is for configuring the channel as well as the frequency of the channel." 'p' is a variable that could be anything. We'll use GPIO19 as the PWM "Output channel," and the "Frequency of PWM signal" will be 50, because the SG90's working frequency is 50Hz. The command below is used to initiate PWM signal generation. 'DUTY CYCLE' is used to specify the 'Turn On' ratio, as previously explained. p.start(DUTYCYCLE) The following command is used to create a forever loop, which means that the statements inside the loop will be executed indefinitely.   8.5 Code import RPi.GPIO  as IO        # calling for header file for GPIO’s of PI import time                           # calling for time to provide delays in program IO.setwarnings(False)          # do not show any warnings IO.setmode (IO.BCM)            # programming the GPIO by BCM pin numbers. (like PIN29 as‘GPIO5’) IO.setup(19,IO.OUT)             # initialize GPIO19 as an output p = IO.PWM  (19,50)              # GPIO19 as PWM output, with 50Hz frequency p.start(7.5)                             # generate PWM signal with 7.5% duty cycle while 1:                                                       # execute loop forever                                             p.ChangeDutyCycle(7.5)                   # change duty cycle for getting the servo position to 90º         time.sleep(1)                                      # sleep for 1 second         p.ChangeDutyCycle(12.5)                  # change duty cycle for getting the servo position to 180º         time.sleep(1)                                     # sleep for 1 second         p.ChangeDutyCycle(2.5)                  # change duty cycle for getting the servo position to 0º         time.sleep(1)                                     # sleep for 1 second   Ⅸ FAQ 1. Are servo motors AC or DC? AC servo motors depend on an AC power source whereas DC Servo motors depend on DC power source (like Batteries). AC servo motors performance is dependent upon voltage as well as frequency whereas DC servo motors performance mainly relies upon voltage alone. 2. Can servo motors rotate 360? The position of the servo motor is set by the length of a pulse. ... The end points of the servo can vary and many servos only turn through about 170 degrees. You can also buy 'continuous' servos that can rotate through the full 360 degrees. 3. Which motor is used in servo motor? While the majority of motors used in servo systems are AC brushless designs, brushed permanent magnet motors are sometimes employed as servo motors for their simplicity and low cost. The most common type of brushed DC motor used in servo applications is the permanent magnet DC motor.
kynix On 2022-01-08   2232

Kynix

Kynix was founded in 2008, specializing in the electronic components distribution business. We adhere to honesty and ethics as our business philosophy and have gradually established an excellent reputation and credibility in our international business. With the accurate quotation, excellent credit, reasonable price, reliable quality, fast delivery, and authentic service, we have won the praise of the majority of customers.

Follow us

Join our mailing list!

Be the first to know about new products, special offers, and more.

Kynix

  • How to purchase

  • Order
  • Search & Inquiry
  • Shipping & Tracking
  • Payment Methods
  • Contact Us

  • Tel: 00852-6915 1330
  • Email: info@kynix.com
  • Follow Us

authentication

Kynix

© 2008-2026 kynix.com all rights reserve.