The Kynix Blog
Stay Ahead with Expert Electronics Insights,
Industry Trends, and Innovative Tips
- Electronic Components
- News Room
- General electronic semiconductor
- Components Guide
- Sort by
- Robots
- Transmitters
- Capacitors
- IC Chips
- PCBs
- Connectors
- Amplifiers
- Memory
- LED
- Diodes
- Transistors
- Battery
- Oscillators
- Resistors
- Transceiver
- RFID
- FPGA
- Mosfets
- Sensor
- Motors, Solenoids, Driver Boards/Modules
- Relays
- Optoelectronics
- Power
- Transformer
- Fuse
- Thyristor
- potentiometer
- Development Boards
- RF/IF
- Semiconductor Information
- PCB
- transistor
IntroductionIn the era of smart phones, there are two ways to extend battery life, one is to directly use a large-capacity battery, and another is to use quick charge technology. Using large-capacity batteries is a easy way but with bulky piece of phones. Here let’s talk about the quick charge. How can you make the phone charge faster?How Does Fast Charging Work?CatalogIntroductionⅠ Quick Charge FactorsⅡ Battery Charging Basics2.1 Charging Heat2.2 Charging PowerⅢ Quick Charge Development3.1 USB Battery Charge 1.23.2 Qualcomm Quick Charge3.3 OPPO VOOC Charge3.4 Pump Express (PE)3.5 OnePlus Dash Charge3.6 Huawei SuperCharge3.7 Low Voltage Solution3.8 Quick Charge AgreementⅣ FAQ Ⅰ Quick Charge FactorsTo realize the quick charging function on the mobile phone, three elements need to be met: Charger, Battery, Charge IC. Adding a point, the charger needs to meet sufficient output current and voltage, because the wiring of the charger has a large parasitic resistance. If requiring a larger charging current, the on-load output voltage of the charger needs to be higher.Quick charge tech of smartphones is mainly divided into three categories: VOOC flash charge, Qualcomm Quick Charge 2.0, and MediaTek Pump Express Plus.At present, the mainstream modes of quick charge on the market include three modes: High voltage and constant currentLow voltage and high currentHigh voltage and high currentFigure 1. Fast ChargingⅡ Battery Charging Basics2.1 Charging HeatHow does the battery charge and solve the heat?Figure 2. Heating Up While ChargingThe basic condition for battery charging is that the charger voltage must be higher than the battery voltage to generate a charging current and complete the charge transfer process. At present, most of the batteries of mobile phones are composed of single lithium or multiple lithium. Generally, the working voltage of mobile phone batteries is about 3.3V~4.2V. During discharge, the voltage will drop, so the average voltage is about 3.7V-3.8V.When charging, the electric energy enters the mobile phone and is processed by the step-down circuit in the mobile phone, and then outputs a voltage of about 3.3~4.5V to charge the battery. And this voltage drop process is responsible for the charge management IC module in the mobile phone. It is responsible for converting the current output by the power supply into a current through the battery. In this process, there will be a certain loss, which will be transferred out of heat.2.2 Charging PowerIn the case of a certain battery level, power indicates the charging speed, the higher the power, the faster the charging speed.Power (P) = voltage (V) x current (I)In theory, increasing the current and voltage can higher the charging power of the battery, but lithium batteries are prone to battery damage or deflagration due to undervoltage or overvoltage. Thus mobile phones must be equipped with a complete power circuit. Among them, the charging control IC and the power control IC are the most important. Ⅲ Quick Charge DevelopmentAccording to theory, quick charge adjust the input value of the voltage and current, thereby shorten the charging time of the mobile phone. Next, let us take a look at the development history of it.The charging standard of mobile phones can be traced back to the era of feature phones, which can be started from the charging standard USB BC 1.2 (BC is the abbreviation of Battery Charge).3.1 USB Battery Charge 1.2The USB specification was first introduced in 1995. It was developed by USB Implement Forum (USB IF), including Intel, NEC Corporation, Compaq, DEC (American Digital Equipment Corporation), IBM (International Business Machines Corporation), Microsoft, and Northern Telecom.The USB BC1.2 standard was published by the USB IF in 2010. It refers to the ability to directly charge the battery of a portable device, and has become a key standard for establishing the correct way to charge the battery through the USB port. So BC1.2 is a set of official standards that can use USB interface to charge portable devices like mobile phones (including power-off charging). Here you may ask, what is the relationship between the USB specification protocol and fast charging?The emergence of USB BC 1.2 makes simultaneous charging and data transmission a reality. Although the USB interface was originally used by manufacturers to transfer data and connect devices such as keyboard or mouse instead of charging. Just think, wouldn't it be much more convenient if you can use the USB interface to charge these devices? So USB BC 1.2 came into being. Although the maximum voltage of the USB interface was still 5V at that time, and the maximum current of USB charging is 1.5A. Although it did not increase the voltage (mainly to adapt to other portable devices), but the USB interface can reach 7.5W with 1.5A current. At that time, the USB BC 1.2 is enough to cope with the charging of mobile phones.The emergence of USB BC 1.2 not only ended the chaotic scenes of USB charging specifications at that time, but it also has good support for hubs/distributors/HUB. So the USB interface data line has become the hot product of various manufacturers for a while. But there is also a data cable with a MicroUSB 2.0 interface (also known as the Android cable). It has only four wires inside, and its current carrying capacity is very limited (2A is the max).Although the USB BC 1.2 standard was able to meet the charging needs of mobile phones at the time, the development of mobile phones has not stopped. With the time goes by, mobile phones have more and more functions. In order to cope with daily use, the battery capacity has also become larger and larger, and the battery capacity has also exceeded 2000mAh, but with the extension of the charging time. When the cell phone battery capacity reaches 3000mAh or even 4000mAh, does it have to be charged overnight? So the charging speed again meets forward higher requirements.3.2 Qualcomm Quick ChargeIn 2013, it was the chip supplier Qualcomm who discovered this problem. Qualcomm first put forward the concept of "Fast Charge", and Quick Charge 1.0 was born. Improve the charging efficiency by increasing the input current, support 5V/2A, that is, the maximum charging power of 10W, breaking through the 1.5A current upper limit of the USB Battery Charge 1.2. In the same year, Huawei also introduced the "fast charge" concept to the first generation of Mate phones, which also supports 5V/2A input, and can fully charge a 4050mAh battery within 3.5 hours.In 2014, the situation was a little different. Qualcomm overturned the QC1.0 strategy and adopted a high-voltage quick charging solution.As mentioned above, P (power) = V (voltage) * I (current), because the data line of MicroUSB 2.0 can only support up to 2A current. Since it couldn’t to increase the current at that time, only adjust the voltage. For example, a fast charge with 18W power, if you want to use a 5V voltage, the current has exceeded 3A. A normal MicroUSB can never withstand such a high current. Using a voltage of 12V, the current only needs 1.5A, so the problems had be solved.The big advantage of this high-voltage fast charging tech is that the cost is relatively low (no need to buy different data cables), and the disadvantages are also obvious. The voltage of the charger is suddenly increased to twice as much, and the step-down heat is also extremely large for the mobile phone. So a major shortcoming of high-voltage quick charge is that the mobile phone generates serious heat during charging.This fast charging solution is the high-voltage QC2.0. It is the most popular and influential standard in the history of QC. For example, Samsung’s 2018 flagship Galaxy S9 still uses the QC2.0.Figure 3. Qualcomm Quick ChargeQC2.0 has improved the charging voltage from the conventional 5V that has been maintained for many years to 9V/12V/20V. It achieves 18W high-power power transmission at the same 2A current as QC1.0, and does not require special wires.QC2.0 has far-reaching influence because of its powerful compatibility. At that time, Micro USB was the standard configuration of smart phones, but it was restricted by the physical interface. Once the current exceeds 2A, it is prone to damage. The smart part of QC2.0 bypasses the restrictions of the Micro USB interface and the data cable, and only increases the charging speed by directly adjusting the input voltage. What’s more, QC2.0 quick charge tech has given peers a idea for reference.3.3 OPPO VOOC ChargeFor example, OPPO introduced VOOC (Voltage Open Loop Multi-step Constant-Current Charging). What OPPO uses here is another solution. There is a fact that normal MicroUSB data cable can't carry such a large current. Because the usual MicroUSB data cable has only five measuring points and four wires, so just increase their number. Therefore, the original VOOC charging head is extremely big because of integrates IC circuit.In addition, because the circuit is rebuilt, you can only use the official special data cable, and the ordinary MicroUSB data cable cannot achieve the fast charging effect. The shortcoming is obvious that the cost is high. But the biggest problem is that high-current charging has more damages. For example, it has been shortening the battery service life of many mobile phones because of VOOC quick charge a year later.Following the principle of "equivalent exchange", since such a heavy price has been paid, there will certainly be generous returns. The advantage of the first-generation VOOC fast charge is that with the 5V/5A 25W ultra-high power, OPPO mobile phones equipped with VOOC fast charge are extremely fast in charging speed. And it puts the heat source into the charger externally, and the heat generated by the mobile phone during charging is significantly less than that of the high-voltage fast charging solution. As a result, the high-voltage fast charging solution led by Qualcomm QC and the low-voltage and high-current fast charging solution led by OPPO VOOC have parted ways.VersionLaunch TimeVoltage/CurrentDescriptionVOOC 2.020155V/4ASame as the first versionVOOC 3.020195V/5ACharge the phone up to 55% in 30 minutesVOOC 4.0202010V/5A(50W)Charge the phone up to 67% in 30 minutesSuperVOOC20185V/6A (30W)Charge a two-cell battery in seriesSuperVOOC 2.0202010V/6.5A (65W)Successor of Super VOOC with GaN technologyThe key to fast charging of mobile phones is the small micro USB interface. At this time, USB type-C appears. Simply list its advantages, such as: support positive and negative plug compatibility, compatible with USB 3.1 standards, support 10Gbit/s transmission in maximum, support the USB Power Delivery charging protocol, support 5A current, the maximum can provide 100W of power. Therefore, the Type-C interface is inherently friendly to large currents.Qualcomm is a giant in mobile phone chips and communications patents, and by virtue of its dominant position, it can quickly popularize its fast charging standards to gain the standard license fee. However, various manufacturers have also begun to develop their own fast charging standards to share this big cake.3.4 Pump Express (PE)Also in 2014, MediaTek launched its own Pump Express (PE) quick charge tech, and Meizu's mCharge fast charging is based on this, and the later Pump Express Plus (PEP) fast charging. Huawei launched the Fast Charge Protocol (FSP) in the early days. As for Xiaomi and Nubia, many manufacturers that still use Qualcomm QC for their flagship mobile phones. They belong to high-voltage fast charging scheme.3.5 OnePlus Dash ChargeNext, let’s talk about OnePlus. Although OnePlus uses Qualcomm’s SoC, but chose a low-voltage and high-current charging solution, that is, Dash charge. It first debuted with the launch of OnePlus 3, where OnePlus promised 60% of full charge in just 30 minutes of charging.Seeing this, do you think that Qualcomm's high-voltage fast charging solution has won the victory, while the low-voltage solution can survive hardly?Of course not, the turning point is that more and more mobile phones are equipped with USB Type-C interface. By 2016, it has become popular. For example, Android flagship phones basically use this interface.3.6 Huawei SuperChargeIn the same year, Huawei improved its FastCharge (FCP) to SuperCharge (SCP). SCP can be said to be one of the fastest/good compatible fast charging representatives in the world, and is compatible with PD and Qualcomm QC protocols.3.7 Low Voltage SolutionMediaTek has also switched to a low-voltage solution. Pump Express technology has developed to 3.0. Pump Express 3.0 is the world's first fast charging solution that uses Type-C interface for direct charging. This solution can effectively prevent the phone from getting hot during charging. In a word, it is very safe.In 2017, Meizu released Super mCharge quick charge tech. It has a charging power of up to 55W at 11V/5A. Unfortunately, due to the inability to get mass production, this 55w super fast charge is still not applied to mobile phones, and replaced by MCharge4.0 fast charging technology. The earlier mCharge3.0 is a high-voltage fast charging solution (24W), and its charger output voltage can reach up to 12V; while mCharge4.0 (25W) belongs to low-voltage and high-current solution, with 5V output voltage and 5A current.Qualcomm began to discover the advantages of the low-voltage solution, so it uses the low voltage and high current solution in the QC4.0 fast charging protocol. Of course, it also supports high voltage fast charging at the same time.Although low-voltage and high-current solutions have basically ruled fast charging, the fast charging protocols of various companies are not compatible with each other. That is to say, although they all use Type-C, they must use the fast charging function of mobile phones corresponding to their own agreement. In other words, although they are all Type-C interfaces, the fast charge protocol is different.3.8 Quick Charge StandardFortunately, the USB IF has unified the fast charging standard. Mobile phones should employ fast charge according to the USB PD protocol. Adjust voltage and current. This standard is also supported by Google. However, various manufacturers make their own mobile phones, and use their own fast charging protocols. So the USB PD protocol has been put aside.The main reasons why mobile phone manufacturers have become more obsessed with constant voltage and high current over the years are: greater power and less charging heat. The USB PD3.0 has successfully incorporated Qualcomm's QC4 protocol. So far, USB PD3.0 has been the regular rule. In short, manufacturers who want to continue to develop their own charging technology, they only need to be based on the USB PD protocol. Moreover, the latest 100W fast charge has been successfully tested. Although large-scale commercial use is unlikely right now, the technical bottleneck will always be overcome.Every Fast Charging Standard Explained Ⅳ FAQ1. What is considered quick charge?For fast charging, you're looking at something that bumps the voltage up 5V, 9V, 12V, and beyond, or increases amperage to 3A and above. Keep in mind, your device will only take in as much power as its charging circuit is designed for.2. Does Quick Charge work with any cable?Do I need any specific equipment for fast charge? Fast charge requires 3 components – a compatible phone/tablet/laptop or other device, a charger that supports USB Fast charge, and a compatible cable. The cable will have USB-C at least on the charger end, and either USB-C or Apple Lightning on the device end.3. Is fast charging bad?The bottom line is, fast charging won't impact your battery life substantially. But the physics behind the technology means you shouldn't expect the battery to last longer than using a conventional “slow” charging brick.4. What phones use quick charge?Apple, Samsung, Google, OnePlus, LG, Sony, Motorola, Huawei, Xiaomi, OPPO, ViVo and Realme.5. What is the meaning of VOOC?The OPPO VOOC (Voltage Open Loop Multi-step Constant-Current Charging) Flash Charging system is a proprietary rapid-charge technology created by OPPO Electronics, which, at present, is able to charge certain OPPO devices from 0 to 75% in just 30 minutes.6. Which phones support VOOC?Realme Narzo 20 Pro (65W Dart Charging)Realme 7 (30W Dart Charging)Realme 7i (18W)Realme 6 (30W VOOC fast charging)Realme X2 (30W VOOC fast charging)7. What is difference between Dash and Warp Charge?The key difference in the two standards is the increase in wattage on the Warp Charge standard. ... In comparison, Dash Charge uses a 5V / 4A (20W) configuration, and both require dedicated Warp Charge / Dash Charge compatible cables to carry the energy.8. Can you use Dash charge with other phones?Dash charge won't harm the phone.. Yes it can. I don't think OnePlus' type C cables or charger are up to USB Type C specifications. I would advise to not do it and get the proper cables and charger for your other device.9. How fast is Huawei SuperCharge?46 mAh per minuteAn infographic put together by Hometop shows that Huawei Super Charge is the fastest at over 46 mAh per minute.10. What is MediaTek Pump Express?Pump Express 4.0 is the latest advance in MediaTek's family of charging innovations. This next-generation charging technology will change your (battery) life, cutting smartphone battery recharge times by over half, compared to a standard USB charger.11. What is MediaTek Pump Express 2.0?They use the MediaTek Pump Express 2.0 fast charging technology and reach a 35% (1,785mAh) in just 30 minutes giving several hours use. It can fully charge the huge battery via its USB-C connector from 0-100% to give 2 full days use in just 2.5 hrs.12. What is super flash charge?The company introduced its 65W SuperVOOC charging that can charge 4000mAh battery on the Reno Ace / Ace2 fully in about 30 minutes. ... The company's 125W fast charging is rumoured to charge the phone's battery from 0 to 100% in about 10 minutes.13. What is DART charge Realme?The Realme 30W Dart Charge Power Bank is an easy recommendation from our side for anyone who owns a compatible device. It comes with two-way fast charging and support for multiple quick charge protocol support. The power bank is also compatible with multiple smartphones apart from Realme.
kynix On 2021-11-23
IntroductionAs the most popular open-source hardware in the world, Arduino is not only an excellent hardware development platform, but also a trend in hardware development. Its simple development method makes developers pay more attention to creativity and realization, complete their own projects and get experiments faster, which greatly saves the cost of learning and shortens the development cycle. There are too many want to say, in short, arduino provides a lot of convenience for many electronics enthusiasts and creators, and also provides a platform for sharing their results. So what exactly is it? How does it work?CatalogIntroductionⅠ What is Arduino?Ⅱ Who Make the Arduino?Ⅲ Why Use Arduino?Ⅳ What Does Arduino Have?Ⅴ Arduino Programming LanguageⅥ Arduino Basic ArchitectureⅦ Copyright and PaymentⅧ Simple Arduino Projects8.1 Video Demonstration8.2 Examples and Programming CodesⅨ FAQⅠ What is Arduino?Arduino is a tool that can be used to sense and control the physical world more than your desktop computer. It consists of an open source-computer platform based on a simple single-chip microcomputer, and a development environment for writing programs for the Arduino board.Arduino can be used to develop interactive products. For example, it can read a large number of switches and sensor signals, and can control a variety of lights, motors, and other physical devices. The Arduino project can be a standalone project, or it can communicate with programs running on your computer (for example: Flash, Processing, MaxMSP) at runtime. You can choose to manually assemble the Arduino board yourself or buy a productthe, because open-source IDE can be downloaded for free.The Arduino programming language seems to be correspondingly connected to a physical computing platform, which is based on a programming environment that handles multimedia.Learn Arduino in 15 MinutesⅡ Who Make the Arduino?Massimo Banzi was a teacher at a high-tech design school in Ivrea, Italy. His students often complain about not being able to find cheap and easy-to-use microcontrollers. In the winter of 2005, Massimo Banzi discussed this problem with David Cuartielles. He is a Spanish chip engineer who was a visiting scholar in this school at the time. The two decided to design their own circuit boards and introduced David Mellis (Banzi student) to design a programming language for the circuit boards. Two days later, David Mellis wrote the code. After another three days, the circuit board was completed. Massimo Banzi likes to go to a bar called di Re Arduino, which was named after the Italian king Arduin 1,000 years ago. To commemorate this place, he named this circuit board Arduino.Figure 1. The Making Arduino Core Team Ⅲ Why Use Arduino?There are many single-chip microcomputers and their platforms that are suitable for the design of interactive systems. For example: Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard and others provide similar functions. With all these tools, you don't need to care about the cumbersome details of MCU programming. Arduino provides you a set of easy-to-use toolkits. Arduino also simplifies the process of working with a single-chip microcomputer, but compared with other systems, it has many advantages in many places. In fact, it is especially suitable for teachers, students and some amateurs:0️⃣Cheap1️⃣Cross-platform2️⃣Simple programming environment3️⃣The software is open-source and expandable.4️⃣Hardware is open-source and expandable. Ⅳ What Does Arduino Have?At the beginning of Arduino development, its application environment was clarified, and an open-source platform was designed to facilitate its secondary development. The main features of Arduino are as follows:1) Open-source circuit diagram design. The program development interface is free to download, or you can modify it according to your needs. Arduino carries low-priced microcontrollers (ATmega8 or ATmega128). It can be powered by a USB interface, no external power supply, and an external 9VDC input can also be used.2) Support ISP online programming, making the Bootloader firmware into the chip. The Arduino controller contains the Bootloader program, which is the first piece of code that runs after the system is powered on. It is like the program in the BIOS of the PC. It performs self-check after startup, configures the port, and so on. Of course, the microcontroller relies on programming the fuse. Set the startup from the boot area after power-on, and use this program to directly store the program sent from the serial port in the flash area. Therefore, when using the Arduino compilation environment to download the program, first reset the microcontroller and start the Boodoader program to guide the program sent from the serial port to be successfully written into the flash area. The flash can be programmed repeatedly, so it is very convenient to update the software. After having Bootloader, you can update the firmware through the serial port or USB to RS232 line.3) According to the official PCB and SCH circuit diagrams, the Arduino module can be simplified to complete independent micro-processing control.4) It can be easily connected with sensors and various electronic components, such as infrared, ultrasonic, thermistor, photoresistor, servo motor, etc.5) Support a variety of interactive programs, such as Flash, Max/MSP, VVVV, PurEDAta, C, Processin, etc.In terms of application, the use of Arduino can break through the interactive content of devices that can only use mouse, keyboard, CCD and other input devices in the past. For example, it can achieve single-player or multi-player game interaction more simply. The functional characteristics of Arduino make it more and more widely used. Ⅴ Arduino Programming LanguageUsually, the Arduino language we say refers to a collection of various application programming interfaces (APIs) provided by the Arduino core library files. Arduino uses C/C++ to write programs. Although C++ is compatible with C language, these are two languages. C language is a process-oriented programming language, and C++ is an object-oriented programming language. The early Arduino core library was written in C language, and later object-oriented ideas were introduced. At present, the latest Arduino core library is written in a mixture of C and C++.The Arduino language is a program framework that starts with setup() and loop() as the main body. setup() is used to initialize variables, pin modes, call library functions, etc. This function only runs once, and its function is similar to "main()" in C language. For the loop() function, the statements in the function are executed in a loop.Arduno language modularizes some parameter settings related to AVR microcontroller, including EEPROM, Ethernet, LED matrix, steering gear, stepping and TWI/I2C control library. It does not require the user to directly deal with the underlying system, which can improve the efficiency of application development. Ⅵ Arduino Basic ArchitectureThe Arduino system has also developed different versions based on different application environments. The "Arduino Duemilanove" version is used as an example to introduce the Arduino system. This version was developed in 2009 and is based on the atmega328 microcontroller board. During use, connect the computer with a USB cable or use a power adapter to power it.1) One 9V DC input provides external power output for the Arduino board, so that the Arduino control board has the ability to drive high-power external devices such as steering gear.2) One USB port used to connect the computer. The Arduino IDE uploads the control program written by the user to the control board, and at the same time, it can also supply power to the circuit board and drive low-power external devices through this port.3) 14 digital input/output terminals, among which ports 0 (RX) and 1 (TX) are respectively connected to the serial pins of the main control chip to receive and send TTL serial data. Among them, ports 2 and 3 can receive external signals to realize external interrupt function. Ports 3, 5, 6, 9, 10, 11 are used as PWM ports, which can be used for motor PWM speed regulation or music playback. Port 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK) can provide SPI communication mode with the support of SPI module library. Port 13 is connected with an LED indicator, which can open and close with the change of the level on pin 13.4) 6 analog input/output ports, of which port 4 (SDA) and port 5 (SCL) can realize I2C communication.5) One 5V DC output and one 3.3V DC output, which can provide 3.3V and 5V DC power supplies for other circuits.6) One reset interface.The Arduino system is developed based on a single-chip microcomputer, and a large number of common and standard electronic components are used on it. The entire design, including hardware and software, is released in an open source manner. Therefore, the cost of procurement is relatively low. In various electronic production competitions, Arduino is used as a development platform for creative design of electronic artwork.Figure 2. Arduino Board Terminals🔺Arduino Hardware✔️There are many motherboard, such as:Arduino UnoArduino NanoArduino LilyPadArduino Mega 2560Arduino EthernetArduino DueArduino LeonardoArduinoYún✔️There are many expansion boards for Arduino, such as:Arduino GSM ShieldArduino Ethernet ShieldArduino WiFi ShieldArduino Wireless SD ShieldArduino USB Host ShieldArduino Motor ShieldArduino Wireless Proto ShieldArduino Proto Shield Ⅶ Copyright and PaymentIn order to maintain the open-source concept of the design, Arduino decided to adopt the Creative Commons license, which is a license similar to GPL that appears to protect open copyright activities. Because copyright law can regulate open-source software, but it is difficult to use it on hardware. Having this license, anyone is allowed to produce copies of circuit boards, redesign, and even sell copies of the original design. You don't need to pay royalties, or even get permission from the Arduino team. However, if you republish the reference design, you must sign the original Arduino team. In addition, if you adjust or modify the circuit board, your latest design must use the same or similar license to ensure that the new version of the Arduino circuit board will be free and open. In other words, only the name Arduino is reserved, and it is a trademark now. If someone wants to sell a circuit board under this name, they must pay a small trademark fee to the Arduino core development members. Ⅷ Simple Arduino Projects8.1 Video DemonstrationBasic Projects with Arduino8.2 Examples and Programming Codes🔺Water Lamp ControlInsert 6 LED lights on the breadboard, among which the long pins are assigned to the 6, 7, 8, 9, 10, 11 ports of arduino respectively, the short pins are all connected to the blue wire of the breadboard, and then one port of the blue wire is connected to the GND port of the arduino. Figure 3. Water Lamps ConnectionCode:void setup(){ pinMode(6,output);pinMode(7,output);pinMode(8,output);pinMode(9,output);pinMode(10,output);pinMode(11,output);}void loop(){digitalWrite(6, LOW);digitalWrite(7,HIGHT);delay(200);digitalWrite(7, LOW);digitalWrite(8,HIGHT);delay(200);digitalWrite(8,LOW);digitalWrite(9,HIGHT);}🔺Using the Buzzer to Realize the AccordionThe buzzer is set according to different frequencies, so set the corresponding buzzer frequency based on the level of the switch interface.void setup(){pinMode(8,INPUT); //switch setdigitalWrite(8, HIGH);pinMode(9,INPUT);digitalWrite(9, HIGH); piMode(10,INPUT);digitalWrite(10, HIGH); pinMode(11,OUTPUT) //light setpinMode(12, OUTPUT)pinMode(13,OUTPUT)}void loop(){if(digitalRead(8)==LOW){tone(7,2093); //the buzzer frequency is set to 2093digitalWrite(11, HIGH);}else{notone(7);digitalWrite(11,LOW);}Repeat 2 switch values down;;; 🔺Breathing LightThe so-called breathing is relatively stable, so it cannot flicker and go off like a flashing LED. So analog output is used, and the current changes continuously.Figure 4. Breathing Light ConnectionCode:void setup(){pinMode(11,OUTPUT); }void loop(){for(int i=0;i<30;i++){analogWrite(11,i); //analog signal input, the range of i is [0,255];delay(10);}for(int j=29;j>0;j--){analogWrite(11,j);delay(10);}} Among them, the corresponding relationship between the analog signal voltage and the digital signal voltage:How is the analog signal realized to control the voltage within a range in a cycle?Figure 6. PWMAs shown in the figure, “on” belongs to 5V, and “off” belongs to 0V. In a time period, that is, when a pulse is sent, the duration of “on” in the previous figure is 25%, and the “off” is 75%. The voltage value calculated like this: v0=5*25%+0*75%=1.25(v). It can be simply understood like this. 🔺Breathing Water Lampvoid setup(){pinMode(3, OUTPUT);pinMode(5, OUTPUT);pinMode(6, OUTPUT);pinMode(9, OUTPUT);pinMode(10, OUTPUT);pinMode(11, OUTPUT);}int ports[6]=[3,5,6,9,10,11];int i=0,level=0; set loop(){ analogWrite(ports[i], level);delay(10);++level %=7;++i %=6; i is incremented first, and then modulo 6, that is, i is always in the range of 0~5;}🔺Vibrating LEDPhotoresistor, resistor, LED are required;Connect one end of the photoresistor to 5V, the other end to the resistor, and the resistor to GND. Pull out a wire between the two and connect to analogIn;Figure 7. Vibrating LED ConnectionCode:void setup(){Setrial.begin(9600);}void loop(){Setril.printIn(analogWrite(0)); //the middle wire is connected to port 0, which is the serial output port;delay(200);} 🔺Electric BellWhen energized, electromagnetic induction produces magnetic force, the switch (oscillator) is attracted and pulled down; When the power is cut off, the coil loses its magnetism, the switch is restored, and then energized. That is, repeat the cycle. This is also the principle of crystal oscillator.Figure 8. Electric Bell DiagramCode:void setup(){pinMode(9,OUTPUT);Setrail.begin(9600);}void loop(){Setrail.printIn(analogRead(0));analogWrite(9, map(analogRead(0), 400,700,0,255); //map(a1,b1,a2,b2), that is, the original range of values [a1,b1] is mapped to [a2,b2];delay(200);} Ⅸ FAQ1. What is an Arduino used for?Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online.2. Is Arduino illegal?The hardware designs of Arduino are open source; it is allowed to copy and further develop the designs. Note that in case a copy uses the Arduino name and/or logo on it, this board is no longer a copy but a counterfeit which is illegal to manufacture and sell.3. Can Arduino run C++?First, the Arduino compiler/IDE accepts C and C++ as-is. In fact many of the libraries are written in C++. Much of the underlying system is not object oriented, but it could be. Thus, "The arduino language" is C++ or C.4. Is Arduino easy to learn?Arduino is cost-effective and easily accessible. Arduino is easier to learn as a programming language as it is a simplified version of the C++ programming language. Arduino is cross-platform which makes it easy to run on any sort of device compared to other microcontrollers which can only run on windows.5. What is the difference between Arduino and Raspberry Pi?The main difference between them is: Arduino is microcontroller board, while Raspberry Pi is a microprocessor based mini computer (SBC). The Microcontroller on the Arduino board contains the CPU, RAM and ROM. All the additional hardware on Arduino Board is for power supply, programming and IO Connectivity.6. Why is Arduino so popular?So the Arduino hardware is easy, the Arduino IDE is simple, and the code itself is much easier to comprehend (than trying to program an off-the-shelf microcontroller). ... Another reason Arduino is so popular is because there are many people using it which means there's a lot of examples out there to work with.7. Can I sell my Arduino project?Yes, with the following conditions: Physically embedding an Arduino board inside a commercial product does not require you to disclose or open-source any information about its design. ... You may manufacture and sell the resulting product.8. Do you have to use the Arduino IDE?Can I program an Arduino board without the Arduino IDE? Yes, you can use Create web editor to program your board without the need of download the classic IDE.9. Can I use Python in Arduino?Arduino uses its own programming language, which is similar to C++. However, it's possible to use Arduino with Python or another high-level programming language. In fact, platforms like Arduino work well with Python, especially for applications that require integration with sensors and other physical devices.10. What language does Arduino code in?Arduino is programmed with a c/c++ 'dialect'. Most c/c++ will work but much of the standard libraries will not work.11. Which language is best for Arduino?Any language that has a compiler that generates Arduino compatible machine code will be perfect. As of this moment , a subset of C / C++ is the only language that is supported by the Arduino IDE.12. How do I program an Arduino?1) Use your Arduino Uno on the Arduino Web IDE.2) Use your Arduino Uno on the Arduino Desktop IDE. Install the board drivers. Open your first sketch. Select your board type and port. Upload the program. Learn more on the Desktop IDE.3) Tutorials.13. Can Arduino connect to WiFi?Connect your Arduino to the internet by adding ESP8266 WiFi Module ... Adding this module to your Arduino UNO will open you to more and exciting projects.14. Can an Arduino run Linux?Arduino have a couple of boards that support running a variant of Linux called Linino: The Arduino Yún is a microcontroller board based on the ATmega32u4 and the Atheros AR9331. The Atheros processor supports a Linux distribution based on OpenWrt named Linino OS.15. What should I learn before Arduino?Before learning Arduino you need to have knowledge of basic programming. You can choose any language like C, C++ or Java. And apart from that you need to have basic idea about electronic devices like which part it is?, How it works? etc.16. Where do I program Arduino?Arduino programs are written in the Arduino Integrated Development Environment (IDE). Arduino IDE is a special software running on your system that allows you to write sketches (synonym for program in Arduino language) for different Arduino boards.17. How many types of Arduino are there?Top 6 Different Types of ArduinoArduino UNO. The development of Arduino UNO board is considered as new compared to other Arduino boards.LilyPad ArduinoArduino MegaArduino LeonardoArduino Red BoardArduino Shields18. Is Arduino good for beginners?Arduino is easily accessible - even for those who don't know much about electronics. Arduino boards are simple a type of microcontroller. They are able to read inputs from the sensors and turn those inputs into output. Arduino is the best for beginners looking to get started with electronics for the first time.19. Which is more powerful Raspberry Pi or Arduino?Given those differences you might think a Raspberry Pi is so much more powerful and capable than Arduino, so you should use that. ... Raspberry Pi has 8. Individual I/O pins in Arduino can drive 40mA while Raspberry Pi GPIO pins can each drive a maximum of 16mA.
kynix On 2021-12-22
Ⅰ IntroductionA computer whether it is a laptop or a desktop has a Motherboard where a small amount of memory known as CMOS (complementary metal-oxide-semiconductor) stores the BIOS settings. Hardware settings, system time, and date are the parts of BIOS settings. BIOS protects the data each time the computer turns off. If CMOS loses its power the system clock resets.CatalogⅠ IntroductionⅡ CMOS Battery Related VideoⅢ Computer BIOS Ⅳ What is a CMOS Battery ?Ⅴ What is the Lifeline of CMOS Battery?Ⅵ How do I Know My CMOS Battery Failed? Ⅶ How to Replace A CMOS Battery?7.1 Step 1: Remove the Previous CMOS Battery7.2 Step 2:What To Do After Taking Out The Battery?Ⅷ FAQ Ⅱ CMOS Battery Related VideoHow to remove cmos battery in your pc? Cmos reset / hard reset on biosCMOS Battery Video Description:In this video I will teach you how to remove your cmos battery in your pc whether be in ATX or mATX or mini ITX motherboard . Removing the cmos battery for 5 minutes will give a hard reset on your motherboard and this will clear unnecessary issues like wrong overclock, no video signal and seeing the "reboot and select proper boot drive" in your display Ⅲ Computer BIOS To comprehend the significance of a CMOS battery , you must first comprehend what your computer 's BIOS is.BIOS is pre-programmed into the hardware of every computer, It is not the same as an operating system. Operating systems can be installed, uninstalled, and updated long after the computer has been purchased. BIOS is something that is built into the computer during the manufacturing process.BIOS is an abbreviation for "Basic Input/Output System." What exactly does it accomplish? Essentially, it manages your computer 's essential functions.All computer s operate based on inputs and outputs. Assume you're launching a software application:An input is when your CPU sends an instruction to your hard disk to retrieve the software program from storage.Your hard disk retrieves the data from the software program and sends it back to your CPU ; this is output.The program is executed by your CPU, It sends instructions to your graphics processor, instructing it on what image to create; an input.Your graphics processor then sends instructions to your monitor on how to arrange the pixels on the screen to create the image; this is output.Everything your computer does can be reduced to an input or an output. The BIOS is in charge of managing your computer's exchange of inputs and outputs, mostly when you boot it up. BIOS instructs your computer on how to boot up the operating system and also controls peripherals (such as the mouse and keyboard). To turn on your laptop , you press the power button, correct? So, how is your laptop supposed to process the power button when it is off? That is what the BIOS operated. While your computer is still waking up, it performs basic functions for it. The basic input is to press the power button. The basic output is that your operating system boots up. Next We will look at CMOS battery, Ⅳ What is a CMOS Battery ?On your motherboard. the motherboard battery, also known as the CMOS (Complementary Metal-Oxide Semiconductor), functions as an RTC (Real-Time-Clock). Inside your computer. the CMOS acts as a battery-powered semiconductor chip that stores important data. This information includes the system time, date, and system hardware settings, which are required for your computer to boot and load properly. All of this data is kept safe by a near-quarter-sized lithium battery located directly on the computer's motherboard, Figure1:CMOS battery Ⅴ What is the Lifeline of CMOS Battery?CMOS is also referred to as CMOS RAM, Non-Volatile RAM (NVRAM), or a real-time clock (RTC). The lifespan of a CMOS battery is nearly ten years. It will differ depending on the computer's usage and environment. CMOS is used in devices such as static RAM (SRAM), microcontrollers, digital logic circuits, and microprocessors.When the computer is unable to display the correct date and time, the CMOS battery has failed. The original button does not appear on all motherboard s. Some of the most basic types of customization features are expansion port speed configuration, boot device order, memory handling, and power control.As we all know from personal experience, batteries do not last forever. Batteries will cease to function after a certain time. This could happen anywhere between two and ten years after the device is manufactured. If your computer is turned on, its battery will last longer than if it is turned off. Unlike other types of batteries, these are not rechargeable, and doing so may result in an explosion. Ⅵ How do I Know My CMOS Battery Failed?The following are the symptoms of CMOS battery failure:The laptop is having trouble booting up.The motherboard emits a constant beeping noise.The date and time have been reset.Peripherals are not responsive or respond incorrectlyHardware drivers have vanishedYou are unable to connect to the internet.When your CMOS battery dies, your BIOS firmware will shut down and reset to factory setting. Problems with booting up and constant beepingAs previously stated, BIOS is primarily responsible for booting up your computer , Your laptop may have a difficult time booting up without the battery, or it may not boot up at all. You may also hear a constant beeping noise from the motherboard. which is another sign of a battery failure.Date and time from a long, long time agoIf your laptop boots, you may notice that the date and time have been reset. They've most likely reset to a date in the distant past. Even when your computer is turned off, BIOS keeps a real-time clock that keeps track of the date and time. That procedure is maintained by CMOS (which is sometimes referred to as a real-time clock in and of itself). If the date and time have mysteriously reset, it's a good indication that the CMOS battery has died.Keyboard performance is erratic.It's possible that your peripherals aren't responding; for example, you can't move your cursor or click on any icons, and the laptop isn't reading any of your keyboard inputs.Alternatively, your peripherals may be thrown out of whack; your cursor may be inaccurate, and your key inputs may result in strange responses from the operating system.Alternatively, your customized keyboard configuration has been reset to the default. Because BIOS is in charge of managing peripherals at startup, these are all indications of CMOS failure.Drivers vanishIf you've installed any drivers on your computer. such as those for your home printer, a CMOS failure may cause those drivers to vanish (you'll need to download and reinstall them).There is no internet connection.You may also be unable to connect to the internet if your battery dies. BIOS is in charge of keeping hardware and network drivers up to date.One thing you should be relieved about is that CMOS failure usually does not result in the loss of any personal files. Nothing in storage has been harmed. Once you've replaced the battery, you'll still have access to all of your photos, videos, and documents. Failure of ttery Ⅶ How to Replace A CMOS Battery?Ground yourself before you touch your patient. That means making sure that any static electricity (which can be generated in small charge s between your body and clothing but is weak enough not to hurt you) does not pass through the delicate computer parts, which may seem insignificant but can seriously damage some of the more delicate components inside your case.Important points include placing your computer case on a non-conductive (non-metallic) table or surface before opening it for treatment and standing on bare feet in contact with the floor. 7.1 Step 1: Remove the Previous CMOS BatteryTo do so, open your computer's case and locate the CMOS battery on the motherboard , If you're treating a laptop. you'll need to open the laptop 's back panel. Because it resembles a large silver coin sitting on your motherboard , the CMOS battery is easy to locate. Figure2:motherboard The battery in most systems and laptops is held in place by a small clip next to it. Simply slide the battery out from under the clip like a big round SIM card, and you'll have the troublesome little silver coin in your hand.Also, under no circumstances should the clip be bent.As a result, it will be unable to hold the new battery in place. You're treating your computer. and as the saying goes, "first not harm."Figure3:new battery And there is one more thing;In some laptops, the CMOS battery may be covered with non-conductive protection and attached to two wires that are connected to the laptop's motherboard via a connector similar to this:Figure4: laptop's motherboardAnd, you know, it's also possible that you can't find the CMOS battery on your laptop's back panel;Because some manufacturers do not allow battery replacements, and if you are still insistent on removing the battery;In any case, you can look online for a 'how to disassemble your laptop' tutorial video.Like on the YouTube;And this will help you understand how to disassemble your laptop because the CMOS battery may be attached to the other side of your laptop's motherboard, Here's a picture of the laptop without a CMOS battery in the back panel:Figure5: back panel So, whatever battery type your computer is using, simply disconnect or remove it.Even if the CMOS Battery is soldered to the motherboard in the following manner:Figure6:Battery is soldered 7.2 Step 2:What To Do After Taking Out The Battery?You have to now purchase the same CMOS battery for your laptop or computer that you recently removed from your laptop or computer, So, you'll need to go to a computer store or order the battery online. Whatever you do, make certain that you purchase the same type of battery. Ⅷ FAQ1. How do I get the CMOS out of the motherboard without damaging it?Use a flat head screwdriver, push the metal tab back away from the battery. It should not take much force, and the battery will just pop out.2. Is the CMOS battery the same battery found in Automotive Key Fobs?Excellent question, YES! The CR2032 can be found in many devices from calculators, wrist watches, medical devices, toys, and many more.3. Can a motherboard run without a battery?Technically, YES. Removing the CMOS battery will allow your computer to run however, you will lose the date and time settings, the computer will boot with default BIOS settings or you will have to choose the drive that the OS is installed every time you start your computer.4. Will removing the motherboard battery reset BIOS?This is an excellent question I get asked alot. The short answer is YES. If you remove the battery, wait approximately 5 minutes and then reconnect the battery.5. Can a CMOS battery cause a black screen?A faulty battery removes all of your boot settings. It is very possible to see nothing but a black screen when booting up a computer with a dead CMOS. For example if you have a secondary video adapter that your monitor is plugged into and your BIOS has reset to default settings, your onboard video would be the new display and not your primary video adapter.
kynix On 2021-12-21
The transformer is an essential part of electrical equipment. So it is necessary to know and master the basic knowledge of it. Is a necessary skill of every electric design. Catalog I. What is a Transformer? II. How does Transformer Works? III. What types of transformer are there? IV. What are the components of the transformer? V. What are the losses of transformers in operation? How to reduce them? VI. What is the nameplate of the transformer? What are the main technical data on the nameplate? VII. How to choose a transformer? VIII.Why transformer cannot run when overload? IX. What kinds of tests should be done for transformers in operation? FAQ I. What is a Transformer? The transformer is a device that uses the principle of electromagnetic induction to change the AC voltage. The main components are primary coil, secondary coil, and core (magnetic core). The main functions are voltage conversion, current conversion, impedance transformation, isolation, voltage stabilization (magnetic saturation transformer), and so on. It can be divided into a power transformer and special transformer (furnace transformer, rectifier transformer, power frequency test transformer, voltage regulator, mine transformer, audio transformer, intermediate frequency transformer, high-frequency transformer, impulse transformer, instrument transformer, electronic transformers, reactors, voltage, and current transformer, etc.) The role of the core is to strengthen the magnetic coupling between the two coils. In order to reduce the eddy current and hysteresis loss in the iron, the iron core is formed by the superposition of the painted silicon steel sheet; there is no electrical connection between the two coils, and the coils are wound by insulated copper wire (or aluminum wire). One coil connected to the AC power supply is called the primary coil (or the primary coil) and the other coil is the secondary coil connected to electrical appliances. The actual transformers are very complicated, so there may be problems that exist to concern, such as copper loss (coil resistance heating), iron loss (core heating), magnetic flux leakage (air-closed magnetic induction line), and so on. To simplify the discussion, an ideal transformer is introduced. An ideal transformer requires some necessary conditions: ignoring the flux leakage, ignoring the resistance of the primary and secondary coils, ignoring the loss of the iron core, and ignoring the no-load current (the current in the primary coil which supplies the secondary coil). For example, the power transformer is close to the ideal condition when it is running at full load (the output with a rated power of the secondary coil). The transformer is a static electrical appliance made by the principle of electromagnetic induction. When the primary coil of the transformer is connected to the AC power supply, the core produces an alternating flux, which is represented by φ. The φ in the primary and secondary coil is the same, and φ is also a simple harmonic function, and φ = φ msinωt. According to Faraday's law of electromagnetic induction, the induction electromotive force in the primary and secondary coils is e1=-N1d φ/dt, e2=-N2d φ /dt. N1, N2 is the number of turns of the secondary coil. From the diagram, we can see that U1=-e1, U2=e2(the primary coil physical quantity is represented by the subscript 1, the secondary coil physical quantity is indicated by the subscript 2), and the complex-effective value is U1=-E1=jN1 ω Φ, U2=E2=-jN2 ω Φ, and makes transformer ratio k=N 1 /N 2. From the upper formula, we can get U1 /U2=-N1 /N2=-k. that is, the voltage effective value of the transformer to that of two coils, which is equal to its coil-voltage ratio, and the phase difference of the voltage of two coils is π. Further More Based On Above Mentioned U1/U2=N1/N2 Under the condition that the no-load current can be neglected, there is I1 /I2=-N2 /N1, that is, the effective value of the coil's current is inversely proportional to the number of turns, and the phase difference is π. On the contrary, under the condition of no-load current, I1/ I2=N2/N1 The power of the ideal transformer is equal to that of the subsoils, that is P1=P2. It shows that the ideal transformer itself has no power loss. But there is always a loss in the actual transformer, and its efficiency is η= P2 /P1, for example, although power transformer efficiency is very high, can reach over 90%, still has a little loss. In an AC circuit, the equipment that increases or decreases the voltage is called a transformer. The transformer can transform any voltage into the value we need at the same frequency to meet the requirements of transmission and distribution. For example, the power generated by a power plant has a lower voltage level, which must be increased the voltage to transmit to a far distance, and the power area must reduce the voltage to a suitable voltage level for power equipment and daily use. II. How does Transformer Works? This video gives a detailed animated illustration on the working of electrical Transformers. Here the basic working principle and construction of transformer, step-up transformer, step-down transformer, transformer winding and core construction are well illustrated. Transformers are based on electromagnetic induction. It consists of an iron core made of silicon steel sheet (or silicon steel sheet) and two sets of coils around the core. The core and the coil are insulated from each other without any electrical connection. The coils connected to one side of the transformer and the power supply are called primary coils (or primary sides), and the coils that connect transformers and electrical equipment are called secondary coils (or secondary sides). When the primary coil of the transformer is connected to the AC power supply, the changing magnetic field line in the core appears. Because the secondary coil is wound on the same iron core, the magnetic field line cuts the secondary coil, and the inductive electromotive force must be generated on the secondary coil, finally, the voltage at both ends of the coil generated. Because the magnetic line is alternating, the voltage of the secondary coil is also alternating. And its frequency is exactly the same as the frequency of the power supply. It is proved by the theory that the voltage ratio between the primary coil and the secondary coil is related to the turns of coils. It can be expressed as follows: Primary coil voltage / secondary coil voltage = primary coil turns / secondary coil turns, the higher the number of turns, the higher the voltage. Therefore, it can be seen that the turns of the secondary coil are less than the primary coils, that is, a step-down transformer, otherwise, it is a step-up transformer. III. What types of transformer are there? According to the number of phases, there are single-phase and three-phase transformers; according to thefunction, there are power transformers, special power transformers, voltage regulating transformers, measuring transformers (voltage transformers, current transformers), small power transformers (for small power equipment), safety transformers; according to the structure, there are core type and shell type; according to the coil, there has double winding and multi-winding transformers, auto-transformer; according to the cooling mode, oil-immersed type and air-cooled type transformers. IV. What are the components of the transformer? Transformer components are mainly composed of iron core, coil, also have other parts, such as oil tank, oil pillow, insulating sleeve and splice, etc. What’s the function of transformer oil? The functions of transformer oil are: (1) insulation; (2) heat dissipation; (3) elimination of arc. What is autotransformer? The autotransformer has only one set of coils, and the secondary coils are tapped from the primary coils, and its electricity can transmitted. It not only has electromagnetic induction, but also the transmission of electricity. There are fewer silicon steel sheets and fewer copper wires in this kind of transformer than in ordinary transformers, often used to voltage regulator. How voltage regulator works? The voltage regulator is constructed the same as the autotransformer, but the iron core is made into a ring coil. The secondary coil tap uses a sliding brush contact to make the surface of the ring along the contact slip in a circular way to achieve voltage regulation smoothly. What is the current relationship between the primary coil and the secondary coil of the transformer? When the transformer operates with load, the current change of secondary coil will cause the corresponding change of primary coil current. According to the principle of magnetic potential balance, it is deduced that the current of the primary and secondary coil is inversely proportional to the number of turns of the coil, the current is small with more turns, and the current with less turns is large. The following formula can be expressed: primary coil current / secondary coil current = secondary coil turns / primary coil turns. What is the voltage change rate of a transformer? The voltage change rate of the voltage regulator is one of the main indexes of transformer performance. When the transformer supplies power to the load, the voltage at the load end of the transformer will inevitably decrease. Comparing the reduced voltage value with the rated voltage value, the percentage is the rate of voltage change. It can be expressed by the formula: voltage change rate = [(secondary rated voltage-load terminal voltage) / secondary rated voltage] ×100%. Generally, for the normal power transformer, when connected to the rated load, the voltage change rate is 4% to 6%. How to ensure that the transformer has a rated voltage output? Too high or too low voltage will affect the normal operation and service life of the transformer, so the voltage must be adjusted. The method of voltage regulation is to draw out several taps in the primary coil and connect them to the tap beginning, which changes the number of turns of the coil by turning the contact. In addition, the required rated voltage can be obtained by rotating the position of the tap switch. It also needs to note that voltage regulation usually occurs after the load of the transformer is cut off. What kind of small transformers are usually used? Where are they applied? Small transformers refer to single-phase transformers with a capacity below 1k VA, mostly used as power transformers for electrical equipment control, electronic equipment and safe lighting equipment. V. What are the losses of transformers in operation? How to reduce them? The loss of transformer in operation includes two parts. (1) One is caused by the iron core. When the coils are electrified, the magnetic field lines are alternating and cause eddy current and hysteresis loss in the core. (2) Another loss is caused by the resistance of the coil itself. When the primary and secondary coils of the transformer have current passing through, some electrical energy may lose. The sum of iron loss and copper loss is the transformer loss, which is related to transformer capacity, voltage, and equipment utilization. Therefore, in the selection of transformers, the capacity of the equipment and the actual usage should be as consistent as possible, in order to improve the utilization rate of the equipment, pay attention not to make the transformer lies in light load operation. VI. What is the nameplate of the transformer? The nameplate of the transformer should indicate the transformer's performance, technical specifications, and use occasions to meet the needs of the user. The main technical data usually selected are as follows: (1) The number of rated capacity. The output capacity of the transformer is rated. For example, the rated capacity of a single-phase transformer is Uline × I line, and the capacity of a three-phase transformer is also the U line × I line. (2) Rated voltage volts. Indicate the terminal voltage of the primary coil and the secondary coil (when the load is not attached). Note that the terminal voltage of the three-phase transformer refers to the line voltage U-line value. (3) Rated current amperes. It means LineI current value that allows long-term passage of primary and secondary coils at rated capacity and allowable temperature rise. (4) Voltage ratio. It is the ratio between primary coil rated voltage and secondary coil rated voltage. (5) Line connection mode. Single-phase transformers have only a set of coils of high and low voltage, only for single-phase use, and three-phase transformers have Y/△type. In addition to the above technical data, there are transformer rated frequency, phase number, temperature rise, impedance percentage of the transformer, etc. VII. How to choose a transformer? First of all, it is necessary to investigate the power supply voltage of the place where the electricity is used, the actual power load of the user, and the conditions of the place where it is located, and then select one by one according to the technical data indicated by the nameplate of the transformer, generally from the capacity and voltage of the transformer. Considering the current and environmental conditions, the capacity selection should be based on the capacity, nature, and service time of the user's power equipment to determine the required load, and then select the transformer capacity. In normal operation, the power load of the transformer should be about 75% ~ 90% of the rated capacity of the transformer. When the actual load of the transformer is less than 50%, the small capacity transformer should be used, and the large transformer should be replaced immediately if the rated capacity of the transformer is greater than that of the transformer. At the same time, when selecting the transformer to determine the primary coil voltage of the transformer according to the line power supply and the voltage value of the secondary coil according to the electrical equipment, it is best to select the low-voltage three-phase four-wire power supply system. This can provide a power supply for the entire operation. For the selection of current, attention should be paid to that the load can meet the requirements of the motor when it starts (because the starting current of the motor is 4 ~ 7 times larger than that of the sinking operation). VIII. Why transformer cannot run when overload? Overload operation refers to the transformer operating in excess of the currency specified on the nameplate. Overload is divided into normal overload and accident overload. The former refers to the increase of power consumption under the normal power supply, and it often makes transformer temperature rise, impels transformer insulation to age, and reduces service life. Therefore, transformer overload is not allowed. In special cases, the overloading of transformers in a short period of time should not exceed 30% of the rated load in winter, and not more than 15% in summer. For the latter, the accident overload and allowable time requirements are as follows: Multiple of Rated LoadReasonable Time of Overload Multiple of Rated Load Reasonable Time of Overload Indoors Outdoors 1.30 2 hours 1 hour 1.60 30 minutes 15 minutes 1.75 15 minutes 8 minutes 2.00 7.5 minutes 4 minutes IX. What kinds of tests should be done for transformers in operation? In order to ensure the normal operation of the transformer, the following tests should be carried out regularly. (1) Temperature test. Whether the transformer is running normally, the temperature is very important. The regulations stipulate that the upper oil temperature shall not exceed 85℃(that is, the temperature rise is 55℃). General transformers are equipped with special temperature measuring devices. (2) Load measurement. In order to improve the utilization rate of transformers and reduce the loss of electric energy, it is necessary to determine the real power supply capacity of transformers in the operation of transformers, the measurement is usually carried out during the current peak period and is measured directly with a clamp ammeter. The current value shall be 70%~ 80% of the rated current of the transformer. (3) Voltage measurement. The regulation requires that the voltage range should be within ±5% of the rated voltage. If beyond this range, taps should be used to adjust the voltage to reach the specified range. Voltmeters are generally used to measure the terminal voltage of the secondary coil and the terminal voltage of the user. (4) Insulation resistance measurement. In order to keep the transformer in normal condition, insulation resistance must be measured to prevent insulation aging and accidents. When measuring the transformer, the transformer should stop running and the insulation resistance of the transformer should be measured by using the tramegger. The resistance measured should not be less than 70 percent of the previously measured value. When using tramegger, the low-voltage coil may adopt a voltage grade of 500 volts. FAQ 1. What is the use of transformer? Transformers are employed for widely varying purposes; e.g., to reduce the voltage of conventional power circuits to operate low-voltage devices, such as doorbells and toy electric trains, and to raise the voltage from electric generators so that electric power can be transmitted over long distances. 2. What are the 3 types of transformers? There are three primary types of voltage transformers (VT): electromagnetic, capacitor, and optical. 3. What is the basic principle of transformer? A transformer consists of two electrically isolated coils and operates on Faraday's principal of “mutual induction”, in which an EMF is induced in the transformers secondary coil by the magnetic flux generated by the voltages and currents flowing in the primary coil winding. 4. Does a transformer convert AC to DC? A transformer is built to transfer the energy from one circuit into another circuit by way of magnetic coupling. ... An alternating current creates a magnetic flux in the core on its way through the first winding, inducing the voltage in the others. It can convert high and low voltages, it cannot convert AC to DC. 5. What are the main parts of transformer? There are three basic parts of a transformer: a. an iron core which serves as a magnetic conductor, b. a primary winding or coil of wire and. c. a secondary winding or coil of wire. 6. What are the classification of transformer? Depending upon the type of construction used, the transformers are classified into two categories viz.: (i) Core type, and (ii) Shell type. Depending upon the type of service, in the field of power system, they are classified as: (i) Power transformers, and (ii) Distribution transformers. 7. Can a transformer work on DC? As mentioned before, transformers do not allow DC input to flow through. This is known as DC isolation. This is because a change in current cannot be generated by DC; meaning that there is no changing magnetic field to induce a voltage across the secondary component. 8. How do you convert a transformer? This conversion is made by winding two separate conductors around a common iron core. Applying an alternating voltage to the primary conductor produces current which sets up a magnetic field around itself. This is known as mutual inductance. 9. What are two components of no load current in transformer? The no-load current of a transformer consists of two components: The Magnetization Current iM is the current required to produce the flux in the transformer core. The Core-loss Current ih+e is the current required to make up for hysteresis and eddy current losses. 10. Which type of transformer core is most efficient? SHELL CORE. The most popular and efficient transformer core is the SHELL CORE, as illustrated in figure (4). As shown, each layer of the core consists of E- and I-shaped sections of metal. These sections are butted together to form the laminations. 11. What is the power factor of transformer? The power factor of a distribution transformer is between (0.75 to 0.80) when secondary is connected to u.p.f loads. 12. Why do we need Transformers? Transformers help improve safety and efficiency of power systems by raising and lowering voltage levels as and when needed. They are used in a wide range of residential and industrial applications, primarily and perhaps most importantly in the distribution and regulation of power across long distances. 13. What is the difference between a step up transformer and a step down transformer? A transformer that increases the voltage from primary to secondary (more secondary winding turns than primary winding turns) is called a step-up transformer. Conversely, a transformer designed to do just the opposite is called a step-down transformer. 14. Are transformers dangerous? There is no established evidence that the exposure to magnetic fields from powerlines, substations, transformers or other electrical sources, regardless of the proximity, causes any health effects. 15. Why transformer rating is in kVA not in kW? Copper losses (I²R) depends on current which passing through transformer winding while Iron losses or core losses or Insulation losses depends on Voltage. ... That's why the transformer rating may be expressed in VA or kVA, not in W or kW.
kynix On 2018-12-12
ⅠIntroductionThyristors are high-speed solid-state devices that can control motors, heaters, and lighting. Before we get into Thyristor Circuits. We'll look at the basic construction and operation of the Silicon Controlled Rectifier, also known as a Thyristor. Next, we'll look at how we can use thyristors and thyristor switching circuits to control much larger loads like lamps, motors, or heaters, among other things. CatalogⅠIntroductionⅡ Thyristors Circuits Related VideoⅢ What Is Silicon Controlled Rectifier?Ⅳ Construction of Silicon Controlled RectifierⅤ What is a Thyristor?Ⅵ Thyristor Switching Circuits6.1 Thyristor Circuit in DC6.2 AC Thyristor CircuitⅦ How an SCR Circuit Works with Thyristor Circuits?7.1 DC Thyristor / SCR Circuit7.2 Basic AC Thyristor / SCR Circuit7.3 AC SCR Circuit with Gate Phase ControlⅧ FAQ Ⅱ Thyristors Circuits Related VideoSilicon Control Rectifier SCR Basic AC Circuit Thyristors Circuits Video Description: Silicon Control Rectifier SCR Basic AC Circuit Ⅲ What Is Silicon Controlled Rectifier?The Silicon Controlled Rectifier (SCR) is one of the most popular devices in the market. SCR can be found in a variety of applications such as rectification, power regulation, and inversion, among others. SCR, like a diode, is a unidirectional device that allows current in one direction but opposes it in the other gate. SCRs have the ability to turn ON or OFF, and their switching is controlled by biasing conditions and the gate input terminal.By varying the ON periods of the SCR, the average power delivered at the load can be varied. It is capable of handling tens of thousands of voltages and currents. Figure depicts the SCR symbol and its terminals.Figure1 :Silicon Controlled Rectifier Ⅳ Construction of Silicon Controlled RectifierAs shown in the figure, an SCR has three terminals: anode, cathode, and gate. SCRs have the ability to turn ON or OFF, and their switching is controlled by biasing conditions and the gate input terminal.By varying the ON periods of the SCR, the average power delivered at the load can be varied. It is capable of handling tens of thousands of voltages and currents. Figure depicts the SCR symbol and its terminals.Figure2:Construction The SCR is manufactured using three different types of constructions: planar, Mesa, and press pack. Planar construction, in which all junctions in an SCR are diffused, is used for low-power SCRs. In a mesa type construction, junction J2 is formed by diffusion and the outer layers are alloyed to it as a result. This design is primarily used in high-power Silicon Controlled Rectifiers. The SCR is braced with plates made of molybdenum or tungsten to provide high mechanical strength. One of these plates is soldered to a copper stud, which is threaded to connect to the heat sink. Ⅴ What is a Thyristor?A thyristor is a four-layer solid-state semiconductor device made of P and N materials. When a gate receives a triggering current, it begins to conduct until the voltage across the thyristor device is biased forward. In this case, it functions as a bistable switch. To control a large amount of current flowing through the two leads, we must create a three-lead thyristor by combining the small amount of current with that current. This is referred to as control lead. If the potential difference between the two leads is less than the breakdown voltage, a two-lead thyristor is used to turn the device on.Figure3:Thyristor Ⅵ Thyristor Switching CircuitsDC Thyristor CircuitAC Thyristor circuit 6.1 Thyristor Circuit in DCWhen connected to a DC supply, we use a thyristor to control larger DC loads and current. The main advantage of using a thyristor in a DC circuit as a switch is that it provides a high current gain. Because a small gate current can control a large anode current, the thyristor is classified as a current-operated device.Figure4:Thyristor Circuit in DC 6.2 AC Thyristor CircuitWhen connected to an alternating current supply, the thyristor behaves differently because it is not the same as a DC-connected circuit. A thyristor is used as an AC circuit during one half of a cycle, causing it to turn off automatically due to its reverse biased condition. Figure6:AC Thyristor Circuit Ⅶ How an SCR Circuit Works with Thyristor Circuits?7.1 DC Thyristor / SCR CircuitMany applications call for an SCR circuit to control the operation of a DC load. This can be used for switching DC motors, lamps, or any other load.The basic SCR circuit shown below can control power to a load by using a small switch to initiate power application to the load.Figure7:Basic DC thyristor / SCR circuit With S1 closed and S2 open, no current will flow at first. The SCR circuit will turn on and the current will flow in the load only when S2 is closed and it triggers the gate by causing the gate current to flow.Until the anode circuit is broken, the current will continue to flow. S1 can be used for this. Another method is to place the switch S1 across the SCR and briefly close it, causing the voltage across the SCR to disappear and the SCR to stop conducting.Because of their functions in this SCR circuit, S1 and S2 may be referred to as the Off switch and the ON switch, respectively. In this configuration, S1 must be able to carry the full load current, while S2 must only carry the gate current. Once the SCR is turned on, the switch can be released and remain open because the SCR's action maintains the current flow through the device and thus the load.R1 connects the gate to the power supply via the switch. When S2 is closed, current flows through the resistor enters the gate and activates the SCR. The resistor R1 must be calculated to provide enough gate current to turn on the SCR circuit.R2 is included to reduce the SCR's sensitivity so that it does not fire on any noise that is detected. 7.2 Basic AC Thyristor / SCR CircuitWhen using a thyristor circuit with AC, a few changes must be made, as shown below.This is because alternating current reverses polarity throughout the cycle. This means that the SCR will become reverse-biased, effectively lowering the anode voltage to zero and causing it to turn OFF for one-half of each cycle. As a result, there is no need for an off switch because this is accomplished as part of the use of an alternating current supply.When using a thyristor circuit with AC, a few changes must be made, as shown below.This is because alternating current reverses polarity throughout the cycle. This means that the SCR will become reverse-biased, effectively lowering the anode voltage to zero and causing it to turn OFF for one-half of each cycle. As a result, there is no need for an off switch because this is accomplished as part of the use of an alternating current supply.\Figure8: AC thyristor / SCR circuitThe circuit operates in a slightly different manner than the DC SCR circuit. When the switch is turned on, the circuit must wait for sufficient anode voltage to be available as the AC waveform progresses along its path. In addition, the SCR circuit will have to wait until the voltage within the gate section of the circuit is high enough to trigger the SCR. The switch must be in a closed position for this to work.Once triggered, the SCR will remain to conduct for the duration of the positive half of the cycle. As the voltage falls, the anode-cathode voltage will become insufficient to support conduction. At this point, the SCR will come to a halt.The SCR will then not operate during the negative half of the cycle. The process will only be repeated when the next positive half of the cycle returns. As a result, this circuit will only operate when the gate switch is closed.One disadvantage of using this type of SCR circuit is that it cannot supply more than 50% power to the load because it does not conduct during the negative half of the AC cycle because the SCR is reverse biased. 7.3 AC SCR Circuit with Gate Phase ControlBy varying the proportion of the half-cycle over which the SCR conducts, the amount of power reaching the load can be controlled. This can be accomplished by using an SCR circuit with phase control of the input gate signal.Figure9:AC thyristor circuit waveformsThe SCR gate signal is derived from an RC circuit consisting of R1, VR1, and C1 before the diode D1 when using the SCR circuit with phase control.Because the SCR is forward biased, only the positive half cycle of the waveform is of interest, as with the basic AC SCR circuit. During this half-cycle, the capacitor, C1, charges up from the AC supply voltage via the resistor network of R1 and VR1. The waveform at the positive end of C1 is seen to lag behind the input waveform, and the Gate is only triggered when the voltage at the capacitor's high end has risen sufficiently to trigger the SCR via D1. As a result, the SCR's turn-on time is delayed compared to what it would be if the RC network was not present. The VR1 value changes the delay and thus the proportion of the cycle over which the SCR operates. The power into the load can thus be adjusted in this manner. Figure10: AC thyristor circuit with gate phase control R1 is a series resistor that has been included to limit the minimum value for the resistor network to a value that will provide an acceptable gate current level for the SCR. The phase angle of the gate waveform must typically vary between 0° and 180° to provide complete control of the 50% of the cycle available for conduction with an SCR. These circuits demonstrate some of the fundamental concepts underlying the design of SCR thyristor circuits. They show how they work and how they can be used in their most basic form. One of the most important considerations when designing thyristor circuits is power dissipation. Because these circuits frequently handle high voltages and high power levels, power dissipation can be a significant factor in circuit design and operation. Ⅷ FAQ1. What does a thyristor do in a circuit?The primary function of a thyristor is to control electric power and current by acting as a switch. For such a small and lightweight component, it offers adequate protection to circuits with large voltages and currents (up to 6000 V, 4500 A).2. How thyristor acts as a switch?When connected to a direct current DC supply, the thyristor can be used as a DC switch to control larger DC currents and loads. When using the Thyristor as a switch it behaves like an electronic latch because once activated it remains in the “ON” state until manually reset3. What is difference between SCR and thyristor?Thyristor is a four semiconductor layer or three PN junction device. It is also known as “SCR” (Silicon Control Rectifier). The term “Thyristor” is derived from the words of thyratron (a gas fluid tube which works as SCR) and Transistor. Thyristors are also known as PN PN Devices.4. Is thyristor convert AC to DC?A single-phase thyristor rectifier converts an AC voltage to a DC voltage at the output. The power flow is bidirectional between the AC and the DC side.5. What are the advantages of thyristor?Advantages of Thyristor :It is easy to turn on. It is able to control AC power. It can switch high voltage, a high current device. It cost is very low.
kynix On 2021-12-14
Keypads are input devices that are being widely used in many embedded system projects. It can be found in appliances, door locks, and industrial machines. Keypads are used to take input from the user in the form of numbers or characters which can further be used for processing such as password, menu selection and navigating among different options. One of the most common and low-cost keypads is the matrix keypad with 4×4 or 3×3 buttons. In this article we will discuss how a low cost 4×4 matrix keypad can be used in STM32. Before proceeding further, we will need to know few things.Materials14×4 matrix keypad2STM32 F401How a 4×4 keypad works? 4×4 keypadIn microcontrollers usually a pin is used to take input from the user. This input can be either 1 or 0. Multiple 1’s and 0’s can be combined to store more information. For this purpose, multiple input pins will be required. However, this becomes impractical when the input pins required exceed certain number such as 16 or 9 as the microcontrollers do not have this many pins available.The 4×4 matrix keypad solves this problem and reduced the required number of pins to 8 or 6. It is made of a thin and flexible membrane. The 16 keys of the 4 x 4 keypad module are arranged in a matrix of rows and columns. A copper trace connects each of these switches to the others. The rows and column are not connected to each other in normal condition. When we push a key, a column and a row come into contact with each other. In matrix keypads the buttons are divided among rows and columns. Four buttons lie on each row and each column. Thus, columns are connected to external input pins of microcontroller while the rows are connected to output pins of microcontroller. The output pins are high all the time. When a button is pressed the corresponding column goes high and the microcontroller detects it. Finding which column has been activated is easy as each column is connected to a separate pin, however, finding a row is difficult. Once both row and column are identified then the corresponding button can be identified. A clever method to identify the pressed key is to switch off all output pins except one, and then check which input pins is high. Doing this for all the output pins will identify the row. Once the row number is found out, the button can easily be traced out.matrix keypad in STM32STM32 F401 implementationSTM32 F401In CubeMX the relative microcontroller of our choice is selected which in our case is STM32 F401CDU6. The GPIOs that need to be selected as output or external interrupt input are given in the figure above. In the NVIC tab the interrupt should be enabled. Other necessary settings are given below.RCC → Crystal/Ceramic ResonatorSYS → Debug → Serial WireClock Configuration → HCLK → 84 MHzClock Configuration → PLL Source Mux → HSE Once the CubeMX code is generated the following code should be added to the /* USER CODE BEGIN PV */ section./* USER CODE BEGIN PV */ GPIO_InitTypeDef GPIO_InitStructPrivate = {0}; uint32_t previousM = 0; uint32_t currentM = 0; uint8_t key = 0; uint8_t InputData[5] = {0}; int i = 0;/* USER CODE END PV */This code section defines the necessary variables that will come handy later.In the main.c section in /* USER CODE BEGIN 2 */ the output configured pins should be set to 1. /* USER CODE BEGIN 2 */ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 1); /* USER CODE END 2 */ While the interrupt callback function void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) should be added to /* USER CODE BEGIN 4 */ section.void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){ currentM = HAL_GetTick(); if (currentM - previousM > 10) { /*Configure GPIO pins : PB6 PB7 PB8 PB9 to GPIO_INPUT*/ GPIO_InitStructPrivate.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStructPrivate.Mode = GPIO_MODE_INPUT; GPIO_InitStructPrivate.Pull = GPIO_NOPULL; GPIO_InitStructPrivate.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStructPrivate); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 0); if(GPIO_Pin == GPIO_PIN_6 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) { key = 68; //ASCII value of D } else if(GPIO_Pin == GPIO_PIN_7 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) { key = 67; //ASCII value of C } else if(GPIO_Pin == GPIO_PIN_8 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) { key = 66; //ASCII value of B } else if(GPIO_Pin == GPIO_PIN_9 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9)) { key = 65; //ASCII value of A } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 0); if(GPIO_Pin == GPIO_PIN_6 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) { key = 35; //ASCII value of # } else if(GPIO_Pin == GPIO_PIN_7 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) { key = 57; //ASCII value of 9 if (i == 4) { //Send Data } else { InputData[i] = 9; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_8 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) { key = 54; //ASCII value of 6 if (i == 4) { //Send Data } else { InputData[i] = 6; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_9 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9)) { key = 51; //ASCII value of 3 if (i == 4) { //Send Data } else { InputData[i] = 3; } if(i <= 4) { i = i + 1; } else { i = 0; } } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 0); if(GPIO_Pin == GPIO_PIN_6 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) { key = 48; //ASCII value of 0 if (i == 4) { //Send Data } else { InputData[i] = 0; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_7 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) { key = 56; //ASCII value of 8 if (i == 4) { //Send Data } else { InputData[i] = 8; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_8 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) { key = 53; //ASCII value of 5 if (i == 4) { //Send Data } else { InputData[i] = 5; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_9 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9)) { key = 50; //ASCII value of 2 if (i == 4) { //Send Data } else { InputData[i] = 2; } if(i <= 4) { i = i + 1; } else { i = 0; } } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 1); if(GPIO_Pin == GPIO_PIN_6 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) { key = 42; //ASCII value of * } else if(GPIO_Pin == GPIO_PIN_7 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) { key = 55; //ASCII value of 7 if (i == 4) { //Send Data } else { InputData[i] = 7; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_8 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) { key = 52; //ASCII value of 4 if (i == 4) { //Send Data } else { InputData[i] = 4; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_9 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9)) { key = 49; //ASCII value of 1 if (i == 4) { //Send Data } else { InputData[i] = 1; } if(i <= 4) { i = i + 1; } else { i = 0; } } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 1); /*Configure GPIO pins : PB6 PB7 PB8 PB9 back to EXTI*/ GPIO_InitStructPrivate.Mode = GPIO_MODE_IT_RISING; GPIO_InitStructPrivate.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOB, &GPIO_InitStructPrivate); previousM = currentM; }} In the callback function the two linescurrentM = HAL_GetTick(); if (currentM - previousM > 10)takes care of the debouncing of the buttons. In keypad it is a common problem that a but hits once is recorded twice or thrice. So, take of that, a little delay is added at the beginning of callback function.The complete code is given below.#include "main.h" /* USER CODE BEGIN PV */ GPIO_InitTypeDef GPIO_InitStructPrivate = {0}; uint32_t previousM = 0; uint32_t currentM = 0; uint8_t key = 0; uint8_t InputData[5] = {0}; int i = 0;/* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/void SystemClock_Config(void);static void MX_GPIO_Init(void);/* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*//* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */int main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); /* USER CODE BEGIN 2 */ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 1); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */} /* USER CODE BEGIN 4 */void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){ currentM = HAL_GetTick(); if (currentM - previousM > 10) { /*Configure GPIO pins : PB6 PB7 PB8 PB9 to GPIO_INPUT*/ GPIO_InitStructPrivate.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStructPrivate.Mode = GPIO_MODE_INPUT; GPIO_InitStructPrivate.Pull = GPIO_NOPULL; GPIO_InitStructPrivate.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStructPrivate); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 0); if(GPIO_Pin == GPIO_PIN_6 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) { key = 68; //ASCII value of D } else if(GPIO_Pin == GPIO_PIN_7 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) { key = 67; //ASCII value of C } else if(GPIO_Pin == GPIO_PIN_8 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) { key = 66; //ASCII value of B } else if(GPIO_Pin == GPIO_PIN_9 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9)) { key = 65; //ASCII value of A } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 0); if(GPIO_Pin == GPIO_PIN_6 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) { key = 35; //ASCII value of # } else if(GPIO_Pin == GPIO_PIN_7 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) { key = 57; //ASCII value of 9 if (i == 4) { //Send Data } else { InputData[i] = 9; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_8 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) { key = 54; //ASCII value of 6 if (i == 4) { //Send Data } else { InputData[i] = 6; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_9 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9)) { key = 51; //ASCII value of 3 if (i == 4) { //Send Data } else { InputData[i] = 3; } if(i <= 4) { i = i + 1; } else { i = 0; } } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 0); if(GPIO_Pin == GPIO_PIN_6 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) { key = 48; //ASCII value of 0 if (i == 4) { //Send Data } else { InputData[i] = 0; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_7 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) { key = 56; //ASCII value of 8 if (i == 4) { //Send Data } else { InputData[i] = 8; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_8 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) { key = 53; //ASCII value of 5 if (i == 4) { //Send Data } else { InputData[i] = 5; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_9 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9)) { key = 50; //ASCII value of 2 if (i == 4) { //Send Data } else { InputData[i] = 2; } if(i <= 4) { i = i + 1; } else { i = 0; } } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 0); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 1); if(GPIO_Pin == GPIO_PIN_6 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) { key = 42; //ASCII value of * } else if(GPIO_Pin == GPIO_PIN_7 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) { key = 55; //ASCII value of 7 if (i == 4) { //Send Data } else { InputData[i] = 7; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_8 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) { key = 52; //ASCII value of 4 if (i == 4) { //Send Data } else { InputData[i] = 4; } if(i <= 4) { i = i + 1; } else { i = 0; } } else if(GPIO_Pin == GPIO_PIN_9 && HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9)) { key = 49; //ASCII value of 1 if (i == 4) { //Send Data } else { InputData[i] = 1; } if(i <= 4) { i = i + 1; } else { i = 0; } } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, 1); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, 1); /*Configure GPIO pins : PB6 PB7 PB8 PB9 back to EXTI*/ GPIO_InitStructPrivate.Mode = GPIO_MODE_IT_RISING; GPIO_InitStructPrivate.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOB, &GPIO_InitStructPrivate); previousM = currentM; }}
Allen On 2022-10-17
Join our mailing list!
Be the first to know about new products, special offers, and more.
Feature Posts
How Resistors Work: From Basic Principles to Advanced Applications2025-07-30
DC Switching Regulators: Principles, Selection, and Applications2025-05-30
FPGA vs CPLD: In-depth Analysis of Architecture, Performance and Application2025-05-07
MOSFET Technology: Essential Guide to Working Principles & Applications2025-05-04
SMD Resistor: Types, Applications, and Selection Guide2025-04-30