controller Related Articles
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
- Sensors
- PCB
- transistor
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
CatalogIntroductionⅠ What is a Microcontroller(MCU)?Ⅱ The History of the Microcontroller (MCU)Ⅲ The Classification and Application of MCUⅣ China MCU Technology and Well-known ManufacturersⅤ The Basic Functions of MCUⅥ Learning Methods - Using MCUⅦ Six Main Dimensions of MCU Products for Future ImprovementⅧ Programming of MCUⅨ Summary of the MCU Programming EngineerⅩ How to Develop MCU Ⅺ 5 Tips to Solve the Questions About the MCU CrystalⅫ Summary of Chip OperationFAQIntroductionA microcontroller (MCU) is a small computer built on a single metal-oxide-semiconductor (MOS) integrated circuit (IC) chip. A microcontroller is made up of a CPU (processor core), memory, and programmable input/output peripherals. On chip, a small amount of RAM, as well as ferroelectric RAM, NOR flash, or OTP ROM , is commonly included. Microcontrollers , in contrast to microprocessors used in personal computers or other general-purpose applications, are designed for embedded applications and are made up of a number of discrete chips. This article will delve deeper into the MCU.Ⅰ What is a Microcontroller(MCU)? Microcontroller UnitThe microcontroller unit (MCU) appropriately reduces the frequency and specifications of the CPU and integrates peripheral interfaces such as memory, counter, USB, A/D conversion, UART, PLC, and DMA. At the same time, even the LCD driver circuit is integrated on a single chip to form a chip-level computer, which can be controlled in different combinations for different applications, such as mobile phones, PC peripherals, remote controls, automotive electronics, industrial stepping motors, machines The control of the arm, etc., can be seen in the MCU.Figure 1 MCU componentsⅡ The History of the Microcontroller (MCU)Microcontroller Unit has a short history, but it has evolved quickly. Its generation and development are roughly synchronized with that of microprocessors (CPUs). Since Intel Corporation of the United States first introduced 4-bit microprocessors in 1971, its evolution can be roughly divided into five stages. The following is an overview of the development of Intel's MCU.1971-1976 The initial stage of MCU developmentIn November 1971, Intel introduced the Intel 4004, a 4-bit microprocessor with an integration level of 2000 transistors/chips and equipped with RAM, ROM, and shift registers, which served as the first MCS-4 microprocessor. The Intel 8008 8-bit microprocessor was introduced, followed by other 8-bit microprocessors from various companies.1976-1980 Low-performance MCU stageThe MCS-48 series, introduced by Intel Corporation in 1976, has a monolithic structure that integrates an 8-bit CPU. an 8-bit parallel I/O interface, an 8-bit timer/counter, RAM, and ROM on a semiconductor chip. Its addressing range is limited (no more than 4 KB), there is no serial I/O, the RAM and ROM capacity is limited, and the interrupt system is simple, but its functions can meet the needs of general industrial control and intelligent instruments and meters.1980~1983 High-performance MCU stageHigh-performance 8-bit microcontrollers introduced at this stage typically include serial ports, multi-level interrupt processing systems, and multiple 16-bit timers/counters. The capacity of the on-chip RAM and ROM is increased, and the addressing range can reach 64 KB. A/D conversion interfaces are also available on individual chips. 1983~late 1980s 16-bit microcontroller stage.In 1983, Intel introduced a high-performance 16-bit microcontroller MCS-96 series. The chip integration level was as high as 120,000 transistors/chips due to the use of the most recent manufacturing process.1990sCPUs are developing to a higher level in all directions, such as integration, function, speed, reliability, and application fields. Ⅲ The Classification and Application of MCUMCUs are classified into two types based on their memory type: those with no on-chip ROM and those with on-chip ROM, The chip without on-chip ROM must be used externally with EPROM (typically 8031); the chip with on-chip ROM is classified as on-chip EPROM (typically 87C51), MASK on-chip mask ROM (typically 8051), on-chip Flash (typically 89C51), and other types.MCUs are classified into two types based on their intended use: general-purpose and special-purpose. It is classified into4, 8, 16, and 32-bit MCUs based on the width of the data bus and the number of data bytes that can be processed at the same time.Figure 2 MCU product category At present, the most widely used MCU market in China is in the consumer electronics field, followed by the industrial field and the automotive electronics market. Consumer electronics include home appliances, televisions, game consoles, and audio and video systems. Industrial fields include smart homes, automation, medical applications, and new energy generation and distribution. The automotive field includes automotive powertrains and safety control systems. Industrial MCU Industrial MCU products are primarily used for motor control operation, data acquisition control, and other functions in motor control, instrumentation, low-voltage power distribution, power tools, industrial robots, and other application scenarios.Figure 3 Electric-Vehicle-ChargerThe number of MCU devices is increasing as the complexity of industrial equipment increases. Consider industrial robots: at least ten MCU products are used in a single industrial robot.Home Appliance MCU MCU is widely used in household appliances, mainly used to realize system control, motor control, panel display control, and other functions.The home appliance market is mainly divided into small household appliances and everyone electricity, small household appliances including kitchen appliances (microwave oven, induction cooker, soybean milk machine, etc.), household appliances (vacuum cleaner, electric fan, electric heater, etc.), personal life small household appliances (electric toothbrush, hairdryer, etc.), everyone electricity mainly for air conditioning, refrigerator, washing machine, and other white appliances.Figure 4 Induction-heating-cooker-app-block-diagramAt the moment, 32-bit MCUs have become the market's mainstream due to their higher specifications and performance, as well as their constantly decreasing cost, and are widely used in automotive electronics. industrial control/medical, and other fields; however, there are still a large number of application scenarios requiring simple control, and low-value MCUs have cost advantages, so they continue to occupy a large market.BitApplication4Calculator, auto instrument, auto anti-theft device, pager, wireless phone, CD player, LCD dynamic controller, children's toys, scales, chargers, Tire gauge, thermometer, remote control, etc8Electrical appliances, ammeter, motor controller, electric toy machine, pager, fax machine, telephonograph, keyboard and USB, etc16Mobile phones, digital cameras and video recorders, etc32Smart home, IoT, motor and frequency conversion control, security monitoring, fingerprint identification, touch keys, Modem, GPS, STB, Workstation, ISDN telephone, laser printer and color fax machine, etc64Advanced workstation, multimedia interactive system, advanced TV game instrument, advanced terminal, etc.According to IC Insights, the global MCU market is about 16.4 billion dollars in 2019 and could reach about 20 billion dollars by 2023.The scale of China's MCU market was about 25.6 billion yuan in 2019, accounting for about 26% of the global market, with a compound growth rate of 9% from 2015 to 2019.In terms of the global market, the auto circuit accounts for 33% of the global MCU market. According to IC Insights data, the automotive MCU market space will reach $8.1 billion in 2023, the overall growth rate is considerable; At the moment, 32-bit MCUs have become the market's mainstream due to their higher specifications and performance, as well as their constantly decreasing cost, and are widely used in automotive electronics. industrial control/medical, and other fields; however, there are still a large number of application scenarios requiring simple control, and low-value MCUs have cost advantages, so they continue to occupy a large market.Figure 5 MCU Market StructureFrom the perspective of pattern, the top five global automotive MCU market shares in 2020 were Renesas, NXP, Infineon, Texas Instruments and Microchip, accounting for 87% in total.Ⅳ China MCU Technology and Well-known ManufacturersMCU market is still dominated by overseas leaders, and Chinese high-quality manufacturers are gradually making breakthroughs in the segmented fields, and their share is expected to increase rapidly under the background of accelerated localization in China.The global MCU market is expected to grow further, with the global MCU market size reaching $16.4 billion in 2019 and $20 billion in 2023.On the demand side, improvements in automotive electrification, accelerated IoT penetration, increased demand for intelligent frequency conversion in home appliances, rapid iteration of wearable devices, and steady growth in industrial control continue to drive the rapid growth of the MCU industry. (Using MCU as an example, the global market compound growth rate from 2020 to 2023 is 7.7 percent, and the market space is expected to be 8.1 billion dollars by 2023)On the supply side, the MCU industry is experiencing a continuous shortage due to the epidemic in 2020. Infineon, NXP. and ST , as well as other overseas MCU large factories, have appeared several times to dozens of times the price, with delivery times of more than 50 weeks; persistent shortages are expected to last at least through the end of 2021 and the first quarter of 2022.In terms of circuit barriers, the requirements of automobile circuits in the MCU downstream field are the highest, followed by industrial and home appliance circuits, and the relative requirements of consumer electronics are slightly lower, according to MCU product environmental temperature, yield, and service life, and other parameters.According to the industry competition pattern, Chinese MCU manufacturers have a low market share, benefit from accelerated replacement due to stock shortages in the short term, and have ample room for improvement in the long term:The global MCU market is more concentrated, with a microchip, ST MICROELECTRONICS, Renesas, TI, NXP , Infineon, and other manufacturers occupying more than 80% of the market share; China's MCU market is approximately 25 billion yuan, and the total market share of domestic MCU manufacturers is less than 12%, primarily concentrated in the consumer market, which has ample room for expansion.The shortage of goods leads to the acceleration of the pace of China's MCU manufacturers, in the automotive, industrial, and consumer circuit, the pace of China's MCU certification continues to accelerate. Renesas Electronics - the world's first automotive MCU manufacturer Renesas was founded in 2003 by the merger of Hitachi Semiconductor division and Mitsubishi Electric Semiconductor division. Its main business covers automotive, industrial, communications, and other fields. Renesas is the world's first automotive MCU manufacturer, accounting for 30% of the automotive MCU market in 2020.Renesas MCU has a complete product line covering EV/HEV, powertrain, electric vehicle, vehicle dashboard, vehicle network, chassis control, ADAS, and other application fields.Microchip technology -8 bit MCU main features, acquisition of Atmel to supplement the strength of 32 bit MCUMicrochip Technology Corporation (Microchip) was founded in 1989, Microchip technology is the world's leading supplier of single-chip and analog semiconductors. The company's main business is the microcontroller, memory products, analog interface, and mixed information products, technology licensing, and so on.The products are mainly used in embedded control systems and IoT-related industries, including data processing, Medical Internet + (IoT), smart city, Industry 4.0, intelligent healthcare, etc. Major customers include Intel, Dell, Lockheed Martin, HP, Boeing, etc. STST -ARM architecture MCU king ST was founded in 1987, its products are mainly used in automotive products, computer peripherals, communication systems, consumer products, industrial automation control systems, and other aspects. Its major customers include Apple, blackberry, Bosch, Cisco, Conti, HP, Nokia, Obata, Samsung, and Western Digital.MCU vehicle grade products accounted for 32.13% of the company's revenue. St holds 8.5% of the current MCU market and is the leader in the segmented 32bitMCU market.ST has been deeply engaged in the automotive semiconductor field for many years, and the company has a complete industrial chain, its products have a very high-cost performance ratio, and occupy a dominant position in the MCU of vehicle regulation level. Its customers include Nissan, Audi, SAIC, Tesla, and many other companies. NXP - the world's leading automotive MCU manufacturer NXP Semiconductor was founded in 2006. It was formerly the semiconductor division of Philips. NXP's main business is MCU, MPU, and other products, which can be widely used in automotive electronics , industrial control, smart city, smart home, and wearable products. Its MCU/MPU based on the S32 automotive platform has obvious advantages in safety and efficiency and has been adopted by mainstream OEMs around the world.The industry's first crossover MCU was independently developed by NXP: I. MX RT series. Such products have been recognized by many Internet platforms (such as Amazon) for their high integration, cost performance, and security.NXP's acquisition of Freescale (founded by MOTOROLA) in 2015 gives it a deeper presence in the automotive industry. In 2020, 47% of its revenue came from vehicle MCU. At present, the company accounts for 27.8% of the global automotive MCU industry, ranking second in the world. NXP provides complete semiconductor solutions for intelligent vehicles including automotive entertainment systems, Advanced Driver Assistance Systems (ADAS). Sino Wealth Electronics - China's largest home appliance MCU manufacturer Sino Wealth Electronic Ltd. is an MCU integrated circuit design company, the main products include 8-bit Flash MCU, 8-bit OTP/Mask MCU, 16-bit DSP , 4-bit OTP/Mask MCU, widely used in household appliances, automotive, industrial control, security, and other fields;In the field of small household appliances, the company's competitors are mainly ABOV from Korea and Holtek from Taiwan. In the field of white household appliances, the company's competitors are mainly from Europe and America, including Renesas, NEC, TI, STM, and so on. Ⅴ The Basic Functions of MCUInternal-function diagramFor most MCUs, the following functions are the most common and basic. The description methods for different MCUs may differ, but the essence is essentially the same.1. Timer: Although there are many different types of Timers, they can be divided into two categories. The first is a Timer with a fixed time interval, which means that its timing is set by the system and cannot be controlled by the user program. The system only provides a few different types of Timers. The user program is given a fixed time interval, such as 32Hz, 16Hz, 8Hz, and so on. Because Timers of this type are relatively common in 4-bit MCUs,they can be used to implement clock, timing, and other related functions.The other type is Programmable Timer. The timing of this type of Timer can be controlled by the user's program. The control methods include the selection of the clock source, the selection of the prescale number, and the setting of the preset number, etc. There are Most MCUs have all three at the same time, and some may have one or both of them. This kind of Timer application is very flexible, and the actual use is also ever-changing. One of the most common applications is to use it to achieve PWM output.Since the clock source can be freely selected, such Timers are generally combined with the Event Counter.2. IO port: Any MCU has a certain number of IO ports. Without IO ports, the MCU will lose the channel of communication with the outside world. According to the configurable situation of the IO port, it can be divided into the following types:Pure input or pure output : This type of IO port is determined by the MCU hardware design, and can only be input or output, and cannot be set in real-time by software.3. Directly read and write IO port: For example, the IO port of MCS-51 belongs to this type of IO port. When the read IO port command is executed, it is an input port; when the write IO port command is executed, it is automatically an output port.Program programming to set the direction of input and output: the input or output of this type of IO port is set by the program according to the actual needs, the application is more flexible, and can realize some bus-level applications, such as12C bus, various LCD, LED Driver control bus, etc.When using the IO port, this point must be kept in mind: for the input port, there must be a clear level signal to ensure that it cannot be floated (this can be achieved by adding a pull-up or pull-down resistor); and for the output port, the output state level must be Considering its external connection, it should be ensured that there is no source current or sink current in Standby or static state.External interrupts: External interrupts are a basic function of most MCUs. They are commonly used for real-time signal generation, data sampling, and state detection. Rising edge, falling edge, and level triggering are all interrupting methods. In most cases, the external interrupt is handled via the input port. If it is an IO port, the interrupt function will only be enabled when it is set as an input port; if it is set as an output port, the external interrupt function will be automatically closed (with some exceptions in ATMEL's ATiny series, where the output port can also trigger the interrupt function). The application of external interrupt is as follows:Detection of external trigger signals: One is based on real-time requirements, such as thyristor control, detection of sudden signals, and so on, while the other is based on power savings.Measurement of signal frequency:: To ensure that the signal is not missed, an external interrupt is the best option.Decoding data: To reduce design costs in the field of remote control applications, it is frequently necessary to use software to decode various encoded data, such as Manchester and PWM encoding.Button detection and system wake-up: In order for the MCU to enter the Sleep state, it must be woken up via an external interrupt. The most basic form is a button, and the level change is caused by the button's action.4. Communication interface: The communication interface provided by MCU generally includes SPI interface, UART. I2C interface, etc., which are described as follows:SPI interface: This type of interface is the most basic communication method provided by most MCUs. Its data transmission is controlled by a synchronous clock. The signals include SDI (serial data input), SDO (serial data output), SCLK (serial clock), and Ready signal; in some cases, there may be no Ready signal; this type of interface can work in Master mode or Slave mode, the popular saying is to see who provides the clock signal, the party providing the clock is the Master, and the opposite party It is Slaver.UART(Universal Asynchronous Receive Transmit):It belongs to the most basic asynchronous transmission interface. Its signal lines only have two Rx and Tx lines. The basic data format is: Start Bit + Data Bit(7-bits/8-bits) + Parity Bit(Even, Odd or None) + Stop Bit(1~2Bit). The time occupied by one bit of data is called Baud Rate .For most MCUs, the length of data bits, data check mode (odd check, even check or no check), Stop Bit length and Baud Rate can be flexibly set through program programming. Certainly. The most common way of this type of interface is to communicate with the serial port of the PC.I2C interface: I2C is a data transmission protocol developed by Philips. It also uses two signals to implement: SDAT (serial data input and output) and SCLK (serial clock). The biggest advantage is that multiple devices can be attached to this bus, and they can be identified and accessed through addresses; one of the biggest advantages of the I2C bus is that it is very convenient to use software to implement through the IO port, and the data rate of its transmission is completely controlled by SCLK. To control, it can be fast or slow, unlike the UART interface, which has strict rate requirements.5. Watchdog: Watchdoga basic configuration of most MCUs, can only allow the program to reset it but not close it (some are set when the program is burned in, such as Microchip PIC series MCUs), while some MCUs are It is determined by a specific method whether it is turned on or not. For example, in Samsung's KS57 series, as long as the program accesses the Watchdog register, it is automatically turned on and cannot be turned off again. Generally speaking, the reset time of the watchdog can be set by the program. The most basic application of Watchdog is to provide a self-recovery ability for the MCU to crash due to unexpected failure.Ⅵ Learning Methods - Using MCUThe basic principles and functions of any MCU are similar. The only difference is the configuration and quantity of its peripheral function modules and the instruction system.For the instruction system, although it seems to be different in form, it is only a difference in symbols, and the meanings it represents, the functions to be completed, and the addressing modes are similar.To learn about an MCU, the first thing you need to know is its ROM space, RAM space, number of IO ports, number of timers and timing methods, peripheral function modules (Peripheral Circuit) provided, interrupt sources, operating voltage, and power consumption, etc.After understanding these MCU Features, the next step is to compare the functions of the selected MCU with the required functions of the actual project development and clarify which resources are currently required and which are not used in this project.For the functions that need to be used in the project but are not provided by the selected MCU, it is necessary to carefully understand the relevant information of the MCU, to use an indirect method to achieve it. For example, the developed project needs to communicate with the COM port of the PC, and If the selected MCU does not provide a UART port, it can be implemented through external interrupts.For the resources needed for project development, you need to carefully understand and read the Manua*, while for the unneeded function modules, you can ignore or browse. For MCU learning, the application is the key and the main purpose.For beginners or designers who use this MCU for the first time, they may encounter a lot of ambiguous descriptions of the functions of the MCU. For this kind of problem, there are two ways to solve it, one is to write a special verification program to understand the functions described in the data; the other can be ignored for the time being. Leave it to modify and improve when debugging. The former method is suitable for projects with loose time and beginners, while the latter method is suitable for those who have some experience in single-chip development or when the project schedule is more urgent.Don't take the time to learn the command system in particular. The instruction system is simply a logical description symbol. During programming, you can only check the relevant instructions in accordance with the logic requirements of the program. As your programming skills improve, you will become more proficient in the instruction system.Ⅶ Six Main Dimensions of MCU Products for Future ImprovementStronger computing performance: MCU towards 500Mhz main frequency, MPU increase more processor cores;Additional wireless connection functions: More RF modules have been integrated.Low power consumption, high energy efficiency ratio: integrated analog chip, and low power analog peripheralsContinued support for hardware accelerators: high integration of algorithms and toolsSafety: improve anti-interference ability and safetyCost-effective: reduce costⅧ Programming of MCUThe programming of MCUs and PCs differ significantly. Although C-based MCU development tools are becoming more popular, assembly language remains the most concise and efficient programming language for designers who are efficient program code and like to use assembly.Circuit diagram to build your own microcontroller programmerThe basic framework for MCU programming is roughly the same, divided into the initialization part (the biggest difference between MCU programming and PC programming), the main program loop body, and the interrupt handler. as shown below:1.Initialization: The most basic and important step in the design of all MCU programs is an initialization, which generally includes the following:Mask all interrupts and set the stack pointer to In general, the initialization section does not want any interruptions to occur.Clearing the system's RAM and displaying the Memory: Although it is not always necessary, it is recommended to develop good programming habits for the sake of reliability and consistency, particularly to avoid accidental errors.IO port initialization: Set the input and output modes of the relevant IO port based on the project's application requirements. Set the pull-up or pull-down resistance for the input port, and the initial resistance for the output port.Interrupt setup: Enable and set interrupt trigger conditions for all interrupt sources required by the project, and close unnecessary interrupts that are not used.Initialization of other functional modules: For all peripheral functional modules of MCU that need to be used, corresponding Settings must be carried out according to the application requirements of the project. For example, Baud Rate, data length, verification mode and Stop Bit length should be set for communication of UART , and clock source should be set for Programmer Timer. Frequency and Reload Data, etc.Initialization of parameters: after completing the initialization of MCU hardware and resources, the following is the initialization of some variables and data used in the program. This part of initialization needs to be designed according to the specific project and the overall arrangement of the program. For some applications that use EEPROM to store the number of prefab items, it is recommended to copy the relevant data to THE RAM of MCU during initialization to improve the speed of data access and reduce the power consumption of the system (in principle, access to the external EEPROM will increase the power consumption of the power supply).2.Main program loop body: Most MCUs run continuously for a long time, so their main program bodies are basically designed in a looping manner. For applications with multiple working modes, there may be many Each loop body is converted between each other through state flags. For the main program body, the following modules are generally arranged:Calculation procedures: Calculation procedures are generally time-consuming, so it is strongly opposed to processing in any interrupt, especially multiplication and division operations.Processing programs with low or no real-time requirements;Display transfer program: mainly for applications with external LED and LCD Driver.3. Interrupt handler: The interrupt program is mainly used to handle tasks and events with high real-time requirements, such as detection of external sudden signals, detection, and processing of buttons, timing counting, LED display scanning, etc.Under normal circumstances, the interrupt program should keep the code as concise as possible. For functions that do not need to be processed in real-time, the trigger flag can be set in the interrupt, and then the main program executes the specific transaction - this is very important, especially for low-power, low-speed MCUs, is necessary to ensure timely responses to all interrupts.4. There are various MCU processing methods for various task bodies.For example, for low-speed, low-power MCU (Fosc=32768Hz) applications, considering that such projects are handheld devices and use ordinary LCD, the response to buttons and display response requires high real-time performance, so generally Timed interrupts are used to process button actions and data display; for high-speed MCUs, such as Fosc>1MHz applications, since the MCU has enough time to execute the main program loop body at this time, it can only be interrupted at the corresponding Various trigger flags are set in the program, and all tasks are executed in the main program body.5. In MCU programming, special attention should be paid to:Avoid situations where the same variable or data is accessed or set in both the interrupt and the main body. The effective prevention method is to arrange the processing of such data in a module, and decide whether to execute the relevant operation of the data by judging the trigger flag; In other bodies (mainly interrupts), only the trigger flag is set where the processing of the data is required. This ensures that data execution is predictable and unique.Ⅸ Summary of the MCU Programming EngineerTo develop a good habit of summarizing, summarizing is not only a summary of their learning, but also a review and deepening of the learning process, but also to avoid the second error.Before writing the program, we should have a solid understanding of the project so that we can start with a solid idea and a general framework. It is critical to consider the layout and what makes the most sense. To determine which module should be completed first, specific steps for the module, how to name each function, and the relationship with other modules. Take a piece of paper and scribble down significant progress.For C language modular programming, we should first divide each module, a module programming, determine a sequence, and then write the next module based on the success of the previous one. When it comes to header files, write the module's header file after you've finished writing the module.Do not ignore the fact that the program must be unreasonable to comprehend its origins and find a solution. When looking for a source, it should be pertinent; you can search for relevant data on the Internet or consult with others. For example, the primary function of another project was incorporated into this project. Some functions are named multiple times. Step by step analysis of the cause, also according to the experimental phenomenon. When defining the port, the incorrect interface was selected. When you can't solve a problem, it's sometimes good to take a break. Things can go wrong no matter how simple they seemThe problems of code utilization efficiency, anti-interference, and MCU reliability continue to plague MCU application development. Ⅹ How to Develop MCU 1How to reduce program bugsThe following are the over-arching management parameters that should be considered during system operation in order to reduce program bugs.Physical parameters: These are primarily system input parameters that include excitation parameters, acquisition and processing operating parameters, and result parameters at the end of processing.Resource parameters: These are primarily the resources of the system's circuits, devices, and functional units, such as memory capacity, storage unit length, and stacking depth.These application parameters are frequently expressed as the application conditions of some single-chip microcomputers and functional units. The term "process parameter" refers to a parameter that changes in an orderly manner during the system's operation.2How to improve the efficiency of C language programming codeIt is an inevitable trend of the development and application of MCU to use C language to design MCU. If you are programming in C, it is best to be familiar with the C compiler you are using to achieve maximum efficiency. First test the number of statement lines in the assembly language corresponding to each C language compilation, so that you can clearly know the efficiency. When programming in the future, use the statement with the highest compilation efficiency. Each C compiler will have certain differences, so the compilation efficiency will also be different. The code length and execution time of an excellent embedded system C compiler is only 5-20% longer than the same functional degree written in assembly language.C language can be used for complex and time-critical projects, but the premise is that you are very familiar with the C language and C compiler of the MCU system and that you pay special attention to the data types and algorithms that the C compiler system can support. Although C is the most commonly used high-level language, the C language compilation system varies due to MCU manufacturer differences, particularly in the operation of some special function modules. As a result, if you don't understand these features, you'll have a lot of trouble debugging, which will result in lower execution efficiency than assembly language.3 How to Solve the MCU Anti-Interference ProblemThe most effective way to prevent interference is to remove interference sources and cut off interference paths, but this is often difficult to do, so we can only conclude that MCU's anti-interference ability is insufficient. While improving the anti-interference capability of hardware systems, software anti-interference has received increasing attention due to its flexible design, ability to save hardware resources, and high reliability.As for the program run fly, in fact, can also use software trap and watchdog to pull the program back to reset state, so the MCU software anti-interference is the most important to deal with the reset state.In most cases, MCU will have some sign registers that can be used to determine the reason for the reset; alternatively, you can bury some tokens in RAM yourself. Different reset causes can be determined in each program reset by judging these signs. You can also use different flags to jump directly to the corresponding program. In this manner, the program will run indefinitely, and the user will be unaware that it has been reset.4How to test the reliability of the MCU systemWhen a MCU system design is completed, there will be different test items and methods for different MCU system products, but some must be tested:lTest the completeness of the software functions of the MCUlPower-on and power-off testlAging testlTests such as ESD and EFT Sometimes, we can also simulate the damage that may occur in human use. For example, the contact port of the MCU system is intentionally rubbed with the human body or clothing fabric, thereby testing the antistatic ability. Use a high-power electric drill to work close to the MCU system to test the anti-electromagnetic interference ability.To sum up, the MCU has become an important aspect of the development and application of the computer.Most of the functions that must be realized by analog circuits or digital circuits in the past can now be realized by software methods using a single-chip microcomputer. This control technology in which software replaces hardware is also called micro-control technology, which is a revolution of traditional control technology.In addition, in the process of development and application, we must master the skills and improve the efficiency, so as to facilitate its wider use.Ⅺ 5 Tips to Solve the Questions About the MCU CrystalCrystal oscillator for MCUCommon causes of the crystal can not vibratePCB wiring error;Microcontroller quality issues;Crystal vibration quality issues;The load capacitance or matching capacitance does not match the crystal oscillator or the capacitor quality is incorrect;PCB board damp, resulting in impedance mismatch and inability to vibrate;The crystal oscillator circuit is too long;There is a line between the feet of crystal;Influence of peripheral circuit.You are advised to rectify faults one by one as follows: 1Remove the possibility of circuit error so that you can compare the recommended circuit of the corresponding type of microcontroller.2 Rule out the possibility of poor peripheral components; because peripheral components are nothing more than resistance and capacitance.3Rule out the possibility of using a crystal oscillator as a stop oscillator because you will not be experimenting with just one or two crystal oscillators.4Try changing the capacitor at both ends of the crystal; perhaps the crystal oscillator will begin to vibrate; please refer to the crystal oscillator capacitor size instructions.5In PC B wiring, crystal oscillator circuit wiring should be as short as possible and as close to IC as possible, not between crystal oscillator feet. Ⅻ Summary of Chip OperationThe operation of the chip is mainly the operation of the registers in the chip. The registers in the chip have their unique address mapped on the memory, which is the operation of the corresponding address. To learn the chip, first look at the sequence diagram, then understand the corresponding registers, understand how to operate, define the required port (the program can recognize), write and read the operation program.Cross-sectional-views-of-chip-operationHow data is written to the chip, how it is read out, and through which port it is input or read.When connecting a chip through a bus, the first step is to understand the protocol of the bus. The chip connected to the I2c bus is controlled by the bus.1One 74HC595 lattice is used for column selection, and the other two are used for color selection. The lattice is equivalent to a set of diodes.The diode lights up only when one end is switched to a high level and the other to a low level. Just one end of the selection of different, bright different colors.Timer working mode selection: Set timer T1 in the high four digits and timer T0 in the low four digits. Then the last two characters of each mode set the working mode. When using interrupts, note that after entering the interrupt, the reset should be reset.2Serial port transceiver: Baud rate is generally set in mode 2 (automatic reloading initial value) because different devices have different data processing capabilities, the baud rate is set mainly to take care of low-speed devices and for communication between each other. The interrupt flag bit should be cleared by the software. When setting the serial port interrupt, either sending or receiving can enter the interrupt function, so pay attention to setting the interrupt function. (Self-sense generally sets a function, as the upper machine or lower machine).If you send interrupts, you have to figure out how to enter interrupts the first time, so you send them once and then you can enter interrupts. Only one byte can be sent at a time, and only after TI is set to one can the next byte be sent.3Pcf8591ad conversion, there are four channels of input, read PC F8591, which channel, read is that channel input voltage, after the conversion of data stored in the chip, then read. Read to write the address of the chip, the son writes device address (0 x40 | channel number) and then reads the data.4Da conversion is to write the device address into the chip first, then write the sub-address (0x40) and then write the digital quantity to be converted. Device address chip information is introduced.5For the liquid crystal display, write data display, he will always display, do not continue to refresh, to change, only re-input.6For THE DS1302 clock chip, reading data is read out of the first data at the falling edge of the eighth clock when writing data, and then prepare for the next output. Pay attention to the writing of the program, but also pay attention to the position of the return value.7In Ds1302, the register is specified first, and then data is written to it. The registers on the chip data indicate the address. 8Initialization is best to write, in case you forget later. When reading or writing, the first operation is the lowest or highest bid, which can be judged according to the sequence diagram.9For the infrared transceiver, receiving, he is according to the length of time between the two falling edges to determine the high level or low level, write a program, first with the timer to determine the length of time, save, and then into binary (the program written to see more, very good).10Stepper motor: mainly used as switches, stepper motor torque decreases with the increase of speed. It is mainly used for automatic feeding of parts processing on machine tools. It can also be used in high-precision control places.Stepper motor is an open-loop control element stepper motor that converts electric pulse signal into angular displacement or linear displacement. In the case of the overload, motor speed, stop position depends only on the pulse signal frequency and pulse number, and are not affected by load change, when the stepper driver receives a pulse signal, it is driving a stepper motor according to set the direction of a fixed Angle, known as the "step Angle", its rotation is based on the Angle of the fixed step by step. The angular displacement can be controlled by controlling the number of pulses to achieve accurate positioning. At the same time, the speed and acceleration of the motor can be controlled by controlling the pulse frequency, achieving the purpose of speed regulation.11Servo motor : Servo motor refers to the engine that controls the operation of mechanical components in a servo system. It is an indirect transmission device for auxiliary motors. Servo motors can control speed, position accuracy is very accurate, voltage signal can be converted into torque and speed to drive the control object. Servo motor rotor speed is controlled by the input signal, and can respond quickly, in the automatic control system, used as an executive element, and has the characteristics of mechanical and electrical time constant is small, high linearity, starting voltage, etc., can receive the electrical signal into the motor shaft angular displacement or angular velocity output. It is divided into DC and AC servo motors. Its main characteristic is that when the signal voltage is zero, there is no rotation phenomenon, and the speed decreases uniformly with the increase of torque.12Chinese Characters overview: To output Chinese characters on display or printer, Chinese characters are designed into a dot matrix graph according to graphic symbols, and corresponding dot matrix codes (glyphs) are obtained.The unified encoding for the representation of Chinese characters in the computer is called the internal code (such as national code), and the internal code is unique (equivalent to the id number of the character). The encoding of Chinese characters formed to facilitate the input of Chinese characters is the input code, which belongs to the external code of Chinese characters. The input code varies with the encoding mode and is diverse. The Chinese character code formed for displaying and printing Chinese characters is the character code, and the computer finds the character code in the character library through the character code and realizes its conversion.Machine code: According to the GB code, each Chinese character has a certain binary code, but this code will conflict with THE ASCII code when handled internally by the computer. To solve this problem, the first byte of each GB code is incremented by 1. Because ASCII code only uses 7 bits, the "1" on the first digit can be used as a symbol to identify Chinese character codes. When the computer processes the code with the first digit of "1", it will be interpreted as the information of Chinese characters, and when it processes the code with the first digit of "0", it will be interpreted as the ASCII code. After such processing, the national code (internal code) is the machine's internal code.If put this "mouth" word graphic "." With "0" instead, you can very vividly get the "mouth" glyphs :0000H 0004H 3FFAH 2004H2004H 2004H2004H 2004H2004H 2004H2004H 2004H 3FFAH 2004H 0000H 0000H. Computer to output "mouth", find shows that character first address, according to the "mouth" machine code after calculation, to find a "mouth" glyph code, and then according to the glyph code (to) in binary character generator, in turn, scan control on the screen, which is where the "0" of the binary empty, is a place where "1" swept out of the window, Then you get the character graph of the mouth.Chinese characters are arranged according to the order of national standard codes and stored in the memory in the form of binary files, which constitute the Chinese character font library, also known as the Chinese character font library, called the Chinese character library1312864 liquid crystal: Each display point corresponds to a binary number, with 1 indicating on and 0 indicating off. The RAM that stores this lattice information is called the display data memory. To display a graph or Chinese character is to write the corresponding lattice information into the corresponding storage unit.When the horizontal address = 0FH, it will be reset to 00H, but it will not automatically add one to the vertical address. Therefore, when writing multiple data in a row, the program needs to determine whether the vertical address needs to be reset14GDRAM: Drawing display RAM provides 128×8 bytes of memory space. When changing the drawing RAM, the horizontal and vertical coordinate values are successively written, and then two bytes of data are written to the drawing RAM. The address counter (AC) will automatically increment the horizontal address (X address) and reset to 00H when the horizontal address is 0XFH. Vertical addresses will not be carried automatically plus 1. The drawing display must be turned off during writing to the drawing RAM,For C, a defined variable is automatically allocated space and its address is the name of the variable. Through this name, the data can be recruited in memory, and the new data can be obtained through an operation. In assembly, the programmer needs to define the storage space and send the data to the accumulator for operation, and the programmer needs to operate every step. In C, this is done by the compiler.FAQ1. What is the main function of microcontroller?Microcontroller is a compressed micro computer manufactured to control the functions of embedded systems in office machines, robots, home appliances, motor vehicles, and a number of other gadgets. A microcontroller is comprises components like - memory, peripherals and most importantly a processor.2. What is an example of a microcontroller?The examples of 8-bit microcontrollers are Intel 8031/8051, PIC1x, and Motorola MC68HC11 families. The 16-bit microcontroller performs greater precision and performance as compared to the 8-bit.3. What are the elements of a microcontroller?Therefore, the microcontroller must also satisfy the five basic elements of input, calculation, storage, output, and control. These are called five elements of microcontrollers.4. Which is best microprocessor or microcontroller?If you need access to large amounts of really fast memory then a microprocessor is likely your best option. A microcontroller is already embedded with memory so the memory choices are fewer than with a microprocessor. The maximum amount of FLASH memory available with most microcontrollers is usually around 2MB.5. What is difference between BIOS and CMOS?The BIOS is the program that starts a computer up, and the CMOS is where the BIOS stores the date, time, and system configuration details it needs to start the computer. ... CMOS is a type of memory technology, but most people use the term to refer to the chip that stores variable data for startup.6. Is CMOS a RAM or ROM?RAM and ROM are the products, but Complimentary Metal Oxide Semiconductor (CMOS) is the process they are built in. CMOS uses two different types of transistors to achieve a lower overall power consumption.7. Whats an RTC battery?The Real Time Clock (RTC) battery provides power for the internal clock/calendar and for maintaining system configuration settings. This error can occur when a machine has been left turned-off for an extended period of time (approximately one to four months), and it is the result of a depleted RTC battery.
kynix On 2022-01-12
Introduction Do you use Raspberry Pi? or What are doing with it? Is it a microcontroller (MCU for microcontroller unit) or microcomputer? or SoC (system-on-chip)? As a beginner, is it better to buy a microcontroller or a Raspberry Pi? Look at the following content. Raspberry Pi Explained Catalog Introduction Ⅰ Basic Definition Ⅱ Raspberry Pi vs MCU Ⅲ What Can We Do with Raspberry Pi? Ⅳ Where do I start to Learn Raspberry Pi? Ⅴ FAQ Ⅰ Basic Definition Raspberry Pi is actually a tiny embedded computer. It uses ARM microcontroller chip, and linux operating system or windows. It can regard as a small desktop computer when connects with a monitor, keyboard, and network (network port or wifi). With the release of Windows 10 IoT, Raspberry Pi can also run Windows.The single-chip microcomputer refers to the central processing unit core with some peripheral interface circuits on it, which is also called the microcontroller unit (MCU), or SoC. 8051 chips, avr chips, arm chips, etc. are all called single-chip microcontrollers, while Intel’s 80x86 series are central processing unit (CPU) and cannot be called MCU.It uses very large-scale integrated circuit technology to integrate the central processing unit CPU with data processing capabilities, RAM, ROM, multiple I/O ports and interrupt systems, timers/counters and other functions (may also include display driving circuits, pulse width modulation circuits, analog multiplexers, A/D converters and other circuits) are integrated on a silicon chip to form a small and complete microcomputer system. It is widely used in the field of industrial control. Figure 1. Raspberry Pi Setting Ⅱ Raspberry Pi vs MCU Next, let's take a look at the difference between the Raspberry Pi and the MCU and introduce in detail what can we do with the Raspberry Pi?The single-chip microcomputer is an microcontroller, and the Raspberry Pi is a single-board computer with arm-architecture processor. Early MCUs were peripherals for ROM and IO with slow speed, and it could not run time-sharing operating systems such as Linux or Windows. But the Raspberry Pi can run an operating system like Linux, or deploy servers or cloud computing. That is, the Raspberry Pi can perform many operations that cannot be done by a single-chip microcomputer.The size of the single-chip microcomputer is relatively small, and the internal chip is used as a computer system. Its structure is simple, but the function is perfect, it is very convenient to use, and it can be modularized. The most important thing is that although the development cycle of the single-chip microcomputer is relatively short, it is basically based on a specific task and the code must be re-programmed every time, which is very troublesome.The Raspberry Pi is actually a computer motherboard. It can be programmed, compiled, and run directly locally. If you want to add or delete functions to the original program, or switch from the current task to a different new task, you do not need to burn programs like a single-chip microcomputer according to different tasks or updates. Use Raspberry Pi to control peripherals by operating GPIO basically through various libraries, and if you connect it to the Internet, you can operate it remotely. Figure 2. Raspberry Pi GPIO In general, each has its own advantages. The MCU is cheap and suitable for general consumer products. After all, the Raspberry Pi is a card-type computer with an embedded operating system running on it. That is, a low-power general-purpose computer. For electronic geeks, the back-end data processing and GUI for complex control systems are still very good for satisfying embedded learning. Ⅲ What Can We Do with Raspberry Pi? After reading the above, since Raspberry Pi has the features of a computer, this means you’re able to do most things a desktop computer can do such as document editing, playing HD video, playing games, coding and much more.Obviously it won’t have as much power as a desktop PC but since it is a lot cheaper they make for great little computers you can play around with.Here lists some items you can do:1) Wireless HotspotUsing the Internet cable and USB wireless network card, after configuration, it can be used as a wireless hotspot.2) Mechanical ProsthesesMIT Media Lab researchers use it as a controller for mechanical prostheses.3) Easy Homemade NotebookConnect the Raspberry Pi to the LCD panel, add the mouse, keyboard and power supply, and find a beautiful case and put it on, finally it becomes a simple homemade notebook.4) WiFi CarAn IBM engineer installed it on a model car, and then used WiFi signals to control the car’s actions.5) Send Dynamics RemotelyWeather enthusiasts tied it to a detection balloon and used it to send a tweet in the stratosphere.6) Control Door SwitchThere are also people who use the Raspberry Pi to control the garage door and combine it with Siri to remotely control the garage switch.7) Surveillance ShootingA camera is connected as a small shooting device, which is small in size and easy to hide.8) Back Up EmailsOne of the most important functions of my Raspberry Pi is to back up emails. Use a software called getmail to check every mail using POP or IMAP protocol, and check the mail of each account regularly. Then save the email to an mbox file, which can be copied to another computer at any time for long-term email archiving.9) Build a RSS ReaderMiniflux, a self-hosted web-based RSS client that can be installed on the Raspberry Pi. Like many people, when Google announced that it would close Google Reader on July 1st, I also started to migrate personal data. I used rss2email for a while and let it send every item of RSS to my mailbox. But in fact, I don't like this method very much, so I spent some time looking for alternatives to Google Reader and tried rss2email and found miniflux finally. Installing miniflux on the Raspberry Pi is very simple, you only need to install PHP and a web server software in advance, such as nginx or Apache.10) Build a WebsiteOne obvious use of Raspberry Pi is as a backend server for websites. Because it has enough capacity to handle static websites, some web frameworks are not a problem. I built a Flask framework on it, and I even heard that some people built a Wordpress directly on the Raspberry Pi.11) Home Network StorageOnly consumes very low power, Raspberry Pi can become a perfect NAS (Network Attached Storage). Before I connected a 500GB laptop hard drive to the Raspberry Pi and installed an operating system on it. I can store many files on it that need to be transferred between different computers. Then connect via SFTP, you can access it on any machine at home (even if you are not at home, it will not be a problem as long as the routing settings are correct). You can also install Samba on your Pi so that both Mac and PC can access it more easily.12) Site MonitoringUse Raspberry Pi is to detect websites that are important to me. I wrote a Python script and ran it regularly to make sure that these websites responded with a 200 status code (which means everything is normal). If the script determines that there is a problem with the website or cannot be accessed, it will email me the overall situation of the incident. The Python module I use is Requests, and the email module is smtplib.13) Event ReminderUse Raspberry Pi to email me important events that I need to remember. I used Google Calendar before, but I only use it for simple events. So I replaced it with a Raspberry Pi, and a Python script for timed tasks is enough. I set the date, time, and message to remember. These parameters will be passed to my Python script, and on that day it will send the message to my mailbox to remind me of the day’s events.14) Family AlbumMy Raspberry Pi also supports a private website that contains all my family photos. I set up verification information so only people I want them to see can enter the site. This is much more reliable than your Facebook photo album, because your account on Facebook may be deleted, and the photos will be seen by strangers by chance. Here is a method, just use PHP to get the photos in a folder on the Raspberry Pi.15) JukeboxI mentioned above that I use Pi as a network storage, so all my music is also on it. I connected a stereo speaker to my Pi and used mpg123 to play music on the command line of the Raspberry Pi. Although there are many other mp3 players and graphical interfaces, I still choose mpg123 because it is easy to install and use. Figure 3. Raspberry Pi Projects Ⅳ Where do I start to Learn Raspberry Pi? If you are really interested in it and want to get started. How, and what do you need? 1) A Raspberry Pi. So, obviously you’ll need he actual board. If you don’t have it, you cant really do what you want. So find a website or store and buy one. Depending on the type and model you get, they can range from as low as 10$ to 50$. Pretty affordable.2) A monitor. So, you don’t actually need a monitor. But it is going to be so much easier. You can actually buy displays the Pi company has made specifically made for the Pi. These however are a little more expensive.You could also use your TV as a monitor, providing both the TV and the Pi can be hooked up via HDMI. VGA to HDMI would work too. Many different solutions can be used when it comes to the cable you use for a monitor, or all around screen. Adapters come in all shapes, sizes and forms. 3) A power source. You’ll need to power the Pi to use it. Most of the time, you will get a little charger to use with the Pi. Using this specific charger will probably be the best, as it will always pull enough power from the wall into your Pi.4) A mouse, and keyboard. You will need a mouse and keyboard. This is pretty much mandatory. Well, only for the actual screen portion of the Pi. Models 3 B+ and up have built in Bluetooth, so you can have cordless mouse and keyboard if you would like. That’s pretty cool.5) Depending on the model, you will need an Ethernet cable to have internet. Models 3 B+ and up have a built in WiFi chip. So you can have a wireless internet connection if you so please.6) A microSD card with the image you want to use. When you buy the Pi, you will need to have an SD card. The newer models use microSD cards. Putting the SD card into the Pi without anything on it wont do anything though, you'll need an image. Images for the Pi can be found along the internet for downloads. The standard image used for the Pi right now is NOOBS Debian.7) Time, patience and dedication. These are very important when working with the Pi. Why? Because the Pi is powerful, yet it can be confusing at times, especially for a “noob”. Ⅴ FAQ 1. What is Raspberry Pi mainly used for?The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. 2. What are some good Raspberry Pi projects?Best Raspberry Pi Projects for BeginnersMusic Streaming.Security System.Weather Station.Arcade Machine.NAS.Digital Photo Frame.Retro Handheld Console.Robot. 3. Can a Raspberry Pi run Windows?The Raspberry Pi 4 can handle Microsoft Edge, the calculator app, and more, all via the power of Windows 11. It can even run Minecraft, albeit in an undesirable state. 4. Can Raspberry Pi go on Internet?If you want to connect your Raspberry Pi to the internet, you can plug an Ethernet cable into it (if you have a Raspberry Pi Zero, you'll need a USB-to-Ethernet adapter as well). If your model is a Raspberry Pi 4, Raspberry Pi 3, or Raspberry Pi Zero W, you can also connect to a wireless network. 5. How do I setup a Raspberry Pi network?Configuring the Raspberry Pi Ethernet Port With a Static IP.Step 1: Review Current Network Settings.Step 2: Backup the Current Network Configuration.Step 3: Modify the Network Settings. To edit the network setting you must edit the dhcpcd.Step 4: Restart the Raspberry Pi.Step 5: Test the New Network Setup. 6. How is Raspberry Pi different from microcontroller?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. 7. Is Raspberry Pi zero a microcontroller?A Raspberry Pi is not a microcontroller, it is a single board computer. Neither. The chip itself is an SOC or system on chip, so it has almost all the parts of a computer on a single die. 8. Is the Raspberry Pi a system on a chip?Raspberry Pi SBCs feature a Broadcom system on a chip (SoC) with an integrated ARM-compatible central processing unit (CPU) and on-chip graphics processing unit (GPU), while Raspberry Pi Pico has a RP2040 system on chip with an integrated ARM-compatible central processing unit (CPU). 9. Can you use a microcontroller with a Raspberry Pi?Meet the Raspberry Pi Pico, a tiny little microcontroller that lets you build hardware projects with some code running on the microcontroller. Unlike computers, microcontrollers don't run traditional operating systems. 10. Is Raspberry Pi 3b a microcontroller?The Raspberry Pi is a single board computer with Microprocessor whereas Arduino is considered as Microcontroller unit. The Raspberry Pi can run an OS (Linux Distribution) and also consumes more power. Since Arduino is microcontroller device it has no operating system and can only run a single program or sketch. 11. What is Raspberry Pi used for in IoT?How can IoT Applications use Raspberry Pi? With an in-built quadcore processor, Raspberry Pi can serve as the “Internet Gateway” for IoT devices. Powered by a cloud network, Pi acts as a web server for uploading and transiting sensor data on IoT platforms. 12. What is the difference between microprocessor and microcontroller?KEY DIFFERENCESMicroprocessor consists of only a Central Processing Unit, whereas Micro Controller contains a CPU, Memory, I/O all integrated into one chip. ... Microprocessor uses an external bus to interface to RAM, ROM, and other peripherals, on the other hand, Microcontroller uses an internal controlling bus. 13. What kind of computer is Raspberry Pi?The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. 14. Can I use a Raspberry Pi as my main computer?Aside from the hard drive crash, the Raspberry Pi was a perfectly serviceable desktop for web browsing, writing articles, and even some light image editing. ... 4 GB of ram is just enough for a desktop. My 13 Chromium tabs, including a Youtube video, are using just over half of the 4 GB of available memory. 15. Which OS is better for Raspberry Pi?Raspbian. Raspbian is a Debian-based engineered especially for the Raspberry Pi and it is the perfect general-purpose OS for Raspberry users.
kynix On 2021-12-30
IntroductionIn electronics, a pinout (sometimes written "pin-out") is a cross-reference between the contacts, or pins, of an electrical connector or electronic component. It describes the functions of transmitted signals and the circuit input/output (I/O) requirements. The number of pins is divided into 8-pin, 14-pin, 16-pin, etc. Every pin must be properly matched to a connector that has the same function. Pinout types include Universal Serial Bus (USB) pinout, PS/2 pinout, ATX power supply pinout, VGA pinout, and Digital Visual Interface (DVI).How to Read Pinouts?CatalogIntroductionⅠ Pinout Arrangement DescriptionⅡ Arduino Pinout and Raspberry Pi Pinout2.1 Arduino Nano Pinout and Arduino Uno Pinout2.2 Arduino Pinout Series2.3 Raspberry Pi Pinout and Diagram2.4 Difference between an Arduino and a Raspberry PiⅢ Example: AT89S52 PinoutsⅠ Pinout Arrangement DescriptionA pinout generally has descriptions in a diagram or table, which specifically indicates whether it is the back-side or front-side view, or if it is the mating face of the connector, or it stands for? Generally speaking, the more pins, the larger the size of the IC chip, the stronger the circuit function, and of course, the higher the price.What these pins stand for? Look at the following Common PIC Pin Descriptions:Pin NumberSymbolDescription1AUDIOAudio Signal Output2FM OUTFM Detection Output3IF AGCIF Signal Input4RF AGCRF AGC Voltage Output5IF INIF Signal Input6IF GNDIF Circuit Ground7IF VccIF Circuit Power Supply8FM FILTERFM Detector Filter Terminal9AFT OUTAFT Control Power Output10SDAI2C Bus Data Terminal11SCLI2C Bus Clock Terminal12ABLAutomatic Brightness Control13R INRed Character Input14G INGreen Character Input15B INBlue Character Input16BLACK INCharacter Blanking signal Input17RGB VccDecoding Circuit Power Supply18R OUTRed Primary Color Signal Output19G OUTGreen Primary Color Signal Output20B OUTBlue Primary Color Signal Output21IDWhite Balance Adjustment Signal Input22VER OUTField Sawtooth Wave Output23V RAMP ALCField Sawtooth Wave Formation24H/BUS VccLine Start Power25AFC FILTERLine AC Low-pass Filtering26HOR OUTLine Excitation Pulse Output27FBP INLine and Reverse Pulse Input28REFReference Current Formation29CLK OUT4MHz Clock Signal Output Pin NumberSymbolDescription301H DL VccBuilt-in Baseband Delay Line +5V Power Supply311H DL Vcc OUTBaseband Delay Line Boost Circuit Output Terminal321H DL GNDBaseband Delay Line Ground33SECAM INComponent Signal Input34C APC FILTERChroma Subcarrier Phasedetector (APC1) Low-pass Filter35SECAM INTERFACE4.43MHz CW Signal Output or SECAM Achromatic Signal Input36X TAL4.43MHz Crystal Terminal37SEL VIDEO OUTVideo Output38V/C/DEF GNDGround39EXT V IN/Y INAV Video or Y Signal Input Terminal40V/C/DEF VccVideo/Chroma/Scan Part Power41INT V IN/C INAV Video or C Signal Input Terminal42BLACK STECHFilter End of Black Level Extension Circuit43VIDEO OUTVideo Detector Output44VCO FILTERIF Lock Detection Filter45VCOExternal VCO Resonant Network46PIF APCIF APC Filter47EXT AUDIO INAV Audio Signal Input48SIF OUTAudio Accompanying Sound IF Output49SIF INAudio Accompanying Sound IF Input50SND APCAccompanying Sound Discrimination Filter Pin NumberSymbolDescription1BASSBass Control Output2MUTEMute (High Level) Control Output350/6050Hz/60Hz Identification Output4SECAMSECAM Recognition5VOLVolume Control6COMB.FDigital Filter on/off Control7POWERPower On/Standby Control8TUNEPWM Tuning Voltage Output9GNDGround10XTAL132kHz Crystal Connection Terminal11XTAL232kHz Crystal Connection Terminal12VDDPower Supply13KEY-IN1Key Scan Signal Input 114KEY-IN2Key Scan Signal Input 215AFT-INAFT Control Voltage Input16RESETReset Terminal17FILTERCharacter Oscillation Low Pass Filter18NCEmpty Pin19V-SYNCCharacter Vertical Positioning Pulse Input20H-SYNCCharacter Horizontal Positioning Pulse Input21OSD-BLKCharacter Blanking Pulse Output22SDAI2C Bus Data Terminal23SCLI2C Bus Clock End24SAFTYOverload Detection Terminal25CSProduction Debugging Chipselect Signal Input Terminal26REM INRemote Control Signal Input27SIFAudio IF Switching Control28TV/AV1AV/TV Switch29TV/AV2AV/TV Switch303.58/4.433.58/4.43 Control31UHFUHF Band Control32VHVHF-H Band Control33VLVHF-L Band ControlⅡ Arduino Pinout and Raspberry Pi Pinout2.1 Arduino Nano Pinout and Arduino Uno PinoutThe Arduino Nano is a small, complete, and breadboard-friendly board. It is based on the ATmega328 8-bit microcontroller by Atmel. It has a total of 36 pins. Out of these 8 are analog input pins and 14 digital input/output pins (of which 6 can be used as PWM outputs). Nano has a 16 MHz SMD crystal resonator, a mini USB-B port, an ICSP header, 3 RESET pins and, a RESET button. The Arduino digital pins can read/output only two states: when there is a voltage signal and when there is no signal.Figure 1. ATMEGA328 PinoutArduino UNO is based on the ATMEGA328 by Atmel. The Arduino UNO pinout consists of 14 digital pins, 6 analog inputs, a power jack, USB connection and ICSP header. The function of Analog pins is to read the value of the analog/digital input used in the connection.Figure 2. Arduino UNO Pinout2.2 Arduino Pinout SeriesDigital PinsPower: Mini USB VinICSP: MISO (Master In Slave Out) Vcc (Supply Voltage) SCK (Clock from Master to Slave) MOSI (Master Out Slave In) RST (Reset (Active Low) GND (Supply Ground)Serial Communication PinsPWM (Pulse Width Modulation) PinsExternal InterruptsSPI (Serial Peripheral Interface) pinsBlinking LED Analog PinsRESETI2C ProtocolAREF (Analog Reference) PinsPower2.3 Raspberry Pi Pinout and DiagramThe Raspberry Pi is a tiny and affordable computer that you can use to learn programming through fun, practical projects, which is the go-to microcomputer for all ages and abilities. You can plugs it into a computer monitor or TV, and uses a standard keyboard and mouse. Over the years the header has expanded from 26 pins to 40 pins while maintaining the original pinout. As you can see, the Pi not only gives you access to the bi-directional I/O pins, but also Serial (UART), I2C, SPI, and even some PWM ("analog output").Figure 3. Raspberry Pi GPIO PinoutRaspberry Pi is as small as the size of a credit card, and works as if a normal computer at a relatively low price. It is possible to work as a low-cost server to handle light internal or web traffic. What’s more, grouping a set of Raspberry Pi to work as a server is more cost-effective than a normal server. Although Raspberry Pi board has so many advantages, it also has the following disadvantages:1) Not able to run Windows Operating system2) Impractical as a Desktop Computer3) Graphics Processor Missing4) Missing eMMC Internal Storage2.4 Difference between an Arduino and a Raspberry PiThe 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. ... Raspberry Pi needs an Operating System to run. Arduino doesn't need any operating system.If you're coming to the Raspberry Pi as an Arduino user, you're probably used to referencing pins with a single, unique number. Programming the Pi's hardware works much the same, each pin has its own number...and then some.Ⅲ Example: AT89S52 PinoutsThe pin functions of AT89S52 are diverse. For example, the intermediate frequency signal can be demodulated from the pin to the internal FM circuit in an unbalanced manner. At the same time, it is also the control pin for AVTV conversion and PAL, NTSC, SECAM chroma system conversion in the block, and its input impedance is about 3.4K.Figure 4. AT89S52 Pinouts1) For Recognition OutputThe pin outputs image recognition signal in OC gate mode. When the video TV signal has been received, this pin presents high impedance to the outside, and a high level signal can be obtained through an external pull-up resistor; when no signal is received, this pin presents a low impedance and outputs a low level.2) As APC1 Filter TerminalThe chip generates a 38MHz switching signal in an oscillating manner to complete the demodulation of the image IF signal. Whether the generated switching signal is accurate depends on the automatic phase control circuit (APC) control. Among them, the filtering of the APC1 error signal is completed on this pin.3) As APC2 Filter TerminalThe filter terminal of the second-stage APC circuit4) An external pin for the quartz crystal oscillatorThe external quartz crystal and internal circuit will oscillate in the form of series resonance. The oscillation frequency is a quarter of the carrier frequency of the image intermediate frequency signal. The frequency of the quartz crystal required is different under different signal systems.5) For AFT Signal OutputThe image IF signal compare with the internal frequency, and then the pin outputs AFT error signal.6) Full TV Signal OutputThe signal in the image is demodulated, and finally the video signal and the accompany audio intermediate frequency signal are output from the pin, and the output signal level is 2V.7) Radio Frequency AGC Delay AdjustmentBy adjusting the external potentiometer, the AGC delay amount can be adjusted.8) For the Input of Internal and External Video SignalsThe signal input needs to be separated from the DC. The coupling capacitor capacity is 1uF. When the internal input level is the peak, the max value is 2V. And when the external input is the peak and the peak is 1V. The input impedance is about 50kΩ. Inside the integrated circuit, the blanking level is fixed at 4.5V.9) The Output of Contrast Control Voltage can also be used to control ACL.10) The pin is the standard level of the built-in filter and the switch of S-VHS. It needs a 1Uf capacitor to be grounded to set the standard level. When it is in the S-VHS mode, the pin voltage must be led by an external circuit is set below 2V. When it is in the normal AV state, the voltage level should be set above 2V.11) Input Pin for S-VHS Chroma Signal and DC ControlWhen inputting chroma signal, a 0.01Uf capacitor should be used to cut off the DC input. At PAL format, the chroma signal level should be 300mV peak-to-peak, and should be 286mV peak-to-peak under the NTSC system.12) As a Delayed Video Signal OutputIt can also achieve ABL control. The output video signal level is 2V peak-to-peak, and a current of 0.5mA or more is necessary.13) The Output of the Decolorization ControlAfter the internal decolorization circuit is activated, a low-level signal will be output from the pin.14) Address Input for Analog Bus Control15) Data Input of Analog Bus Control16) The Output of the Internal Field Scanning PulseThe external resistance value can set the sensitivity of the internal field synchronization separation. If you don't need the internal field pulse, you can also input other field pulse signals from the pin, and the internal field output is automatically cut off at this time. The pin can also be an automatic trigger mode release switch and a row AFC strobe release switch.17) To connect the oscillating quartz crystalThe crystal frequency should be 500Hz.18) Separate power supply pins for line oscillation and line pre-excitation circuits. A higher voltage provides a DC voltage to the pin through a resistor, which is stabilized to 7V by the internal voltage regulator circuit for use by the above circuits. The selection calculation of resistance is: R1=(+B1-7.0V)/13mA.19) The output of line pre-excitation pulse is output in push-pull mode.20) Line and Reverse Pulse InputThe line and reverse pulse signal is output from this pin after forming a sand castle pulse internally. As a unified working sequence of some circuits, this pin is also the output of the integrated circuit pulse in the SECAM system.21) Character Background Blanking Pulse InputThe standard control voltage is 1V, when the input voltage is higher than 1V, the image display stops, and the character is displayed at the current position. When the pin voltage is lower than 1V, the image is displayed at the current position.22) The input of the three-color signal of the on-screen character display (OSD). When using the analog character display mode, the DC input needs to be cut off. When using the digital character display mode, the high level needs to be set to a certain value.23) Negative brightness signal output, and at the same time the input of the de-trap signal.24) Color difference signal output, respectively output the R-Y, G-Y, B-Y of the TV image or the R, G, B three-color screen character display dot matrix after character display conversion.25) After the input of the ALC amplifier (CCD delay adjustment) is delayed and calculated by the integrated one-line delay line, the two color difference signals return to the LA7687 from these two lead pins.26) Output the Color Difference Signal to the Integrated Delay Line.In the PAL system, the two incompletely demodulated color difference signals are output from two pins to the delay line for further processing. When in the SECAM system, the color difference signal does not come from LA7687. Therefore, the two pins present a high impedance state under this system, and the output dc voltage is 3.6V.27) The subcarrier recovery circuit needs to be connected to 4.43MHz and 3.58/MHz quartz crystals.28) For the Color Demodulation Circuit APC FilterThe filter composed of the external resistance container can set the synchronization range of the subcarrier oscillation.29) The AGC Filter Pin of the First Stage Mid AmplifierThe AGC detection circuit separates the synchronization signal by detecting the peak value of the video signal, and filters it into the AGC voltage at the pin. The second stage AGC filter is hidden inside the integrated circuit.30) Image IF Signal InputThrough the surface acoustic filter to form a specific image IF signal, in a balanced way from two lead pins amplify the collector circuit. Inside the integrated circuit, there are a total of three amplifiers, and the total amplification gain is above 60dB.31) The output of the radio frequency AGC is output in an open-collector mode.32) Audio Signal OutputThe integrated circuit completes the demodulation of the FM signal, and the audio signal is output from the pin, and there should be a de-emphasis circuit composed of resistive components on the outside.33) Audio Filter PinIt is used to eliminate the DC feedback of the preamplifier, in addition, a 1uF capacitor is required to be connected externally. In addition, when this pin is set to high level, the image IF gets into the SECAM mode. Frequently Asked Questions about Electronic Pinout1. What does pinout mean?In electronics, a pinout (sometimes written "pin-out") is a cross-reference between the contacts, or pins, of an electrical connector or electronic component, and their functions. "Pinout" now supersedes the term "basing diagram" that was the standard terminology used by the manufacturers of vacuum tubes and the RMA. 2. What is pin configuration?Devices support both analog input and digital I/O line modes on several configurable pins. The following table provides typical parameters for the pin configuration commands (D0 - D9, P0 - P2). 3. What is a pinout cable?Pinout or pin-out is a term used in electronics to describe how an electrical cable is wired, or the function of each wire (pin) in a connector. An electrical connector typically consists of several electrical contacts or pins that can be used to carry electrical power or signals. 4. What are the pins on Arduino Uno?Arduino/Genuino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. 5. How many digital and analog pins are in Arduino Uno?Microcontrollers
kynix On 2021-04-07
Ⅰ IntroductionIn an analog world surrounded by digital devices, we exist in a fascinating intersection of two domains. In nature, everything we observe, feel, or measure is analog—such as light, temperature, speed, pressure, and sound. However, most electronic devices around us are digital, ranging from basic digital watches to sophisticated supercomputers and AI systems. Therefore, for microcontrollers, microprocessors, and modern computing systems to understand and process real-world phenomena, we need devices that can convert these analog parameters into digital values. This conversion is performed by an ADC (Analog-to-Digital Converter), and in this comprehensive guide, we will explore their functionality, types, and applications in modern electronics.Ⅱ Definition of ADC (Analog-to-Digital Converter)An Analog-to-Digital Converter (ADC) is a circuit that converts continuous voltage values (analog signals) into binary values (digital data) that can be interpreted and processed by digital computers and microcontrollers. These ADC circuits can be found as standalone integrated circuits (ICs) or embedded within microcontrollers, system-on-chip (SoC) designs, and digital signal processors (DSPs). The conversion process involves sampling the analog signal at discrete time intervals and quantizing the amplitude into digital codes.Modern ADCs are fundamental components in virtually all electronic systems that interface with the physical world, from smartphones and IoT devices to medical equipment and automotive sensors.Ⅲ The Reasons for Using ADCsToday's electronics ecosystem is predominantly digital; the era of analog computers has long passed. However, the physical world we inhabit remains inherently analog and continuous. Digital systems can only process discrete values—essentially ones and zeros—which creates a fundamental incompatibility with analog signals.For example, a temperature sensor such as the LM35 outputs a temperature-dependent voltage—specifically, 10 mV per degree Celsius. If we connect this directly to a digital input pin, the microcontroller will only register it as either HIGH or LOW based on threshold voltages (typically around 0.8V for LOW and 2V for HIGH in 5V systems), which provides no useful temperature information. Instead, we use an ADC to convert the analog voltage input into a multi-bit digital value that can be directly processed by the microprocessor's data bus, enabling precise calculations, data logging, and control decisions.Key reasons for using ADCs include:Enabling digital processing of real-world analog signalsFacilitating data storage and transmission in digital formatAllowing complex mathematical operations on sensor dataEnabling machine learning and AI applications with sensor inputsProviding noise immunity through digital signal processingⅣ Working Principles of ADCUnderstanding ADC operation is best approached by viewing it as a mathematical mapping function. The ADC maps continuous analog voltage values to discrete binary numbers within a defined range. This process involves three fundamental steps: sampling, quantization, and encoding.The ADC needs to bridge the gap between the analog voltage domain and the digital logic domain. Since digital registers can only accept discrete logic levels (HIGH/LOW), directly connecting an analog signal would produce unreliable results. The ADC acts as an intelligent interface that periodically samples the analog input and converts each sample into a binary representation.Figure 1: Analog to Digital Conversion ProcessHere are the essential characteristics of ADCs that determine their performance and suitability for different applications:4.1 Reference VoltageNo ADC operates in absolute terms; instead, it requires a reference voltage that defines the full-scale range. The reference voltage represents the maximum analog input that corresponds to the highest possible digital output value. For example, in a 10-bit converter with a 5V reference voltage, the binary value 1111111111 (1023 in decimal—the highest possible 10-bit number) corresponds to 5V, while 0000000000 (0 in decimal) corresponds to 0V.Since 10 bits provide 210 = 1024 possible values (0-1023), each binary step represents approximately 5V / 1024 ≈ 4.88 mV. This measure is called the resolution or LSB (Least Significant Bit) voltage of the ADC. The formula is:Resolution (V) = VREF / 2nwhere VREF is the reference voltage and n is the number of bitsIf the analog voltage changes by less than one LSB (4.88mV in this example), the ADC cannot detect the change—this creates a quantization error. To minimize this error and improve measurement precision, you can either use an ADC with higher resolution (more bits) or reduce the reference voltage to match your signal range more closely.Modern ADCs are available with resolutions ranging from 8 bits (256 levels) for simple applications to 32 bits (over 4 billion levels) for precision scientific instruments, though 12-bit and 16-bit converters are most common in embedded systems.4.2 Sample Rate (Sampling Speed)The sample rate, also called sampling frequency, refers to the number of analog-to-digital conversions the ADC performs per second, measured in samples per second (S/s or SPS). High-performance ADCs can achieve sample rates exceeding 1 GS/s (giga-samples per second, or one billion samples per second), while precision ADCs might operate at just a few samples per second.According to the Nyquist-Shannon sampling theorem, to accurately reconstruct a signal, the sampling rate must be at least twice the highest frequency component in the signal. For example, to digitize audio signals with frequencies up to 20 kHz, you need a sampling rate of at least 40 kHz (which is why CD audio uses 44.1 kHz).The sampling speed depends on the ADC architecture and the required accuracy. Generally, there's a trade-off between speed and resolution: high-speed ADCs (like flash ADCs) typically have lower resolution (8-10 bits), while high-resolution ADCs (like sigma-delta ADCs) operate at lower speeds. This is because achieving higher precision requires more time to accurately measure and convert the analog signal.4.3 Additional Key SpecificationsSignal-to-Noise Ratio (SNR): Measures the ratio of the desired signal power to background noise, typically expressed in decibels (dB). Higher SNR indicates better performance.Effective Number of Bits (ENOB): Accounts for real-world imperfections and indicates the actual resolution achieved in practice, which is typically less than the nominal bit count.Input Impedance: The electrical resistance presented by the ADC input, which affects how it loads the source circuit. High input impedance is generally desirable to minimize signal distortion.Ⅴ Types of ADCsVarious ADC architectures have been developed to optimize for different combinations of speed, resolution, power consumption, and cost. Here are the most common types:5.1 Flash ADCs (Parallel ADCs)Flash ADCs are the fastest type of analog-to-digital converter, capable of conversion rates exceeding 1 GS/s. They consist of a resistor ladder voltage divider and an array of comparators—one for each quantization level. For an n-bit flash ADC, 2n - 1 comparators are required.Figure 2: Flash ADC ArchitectureAll comparators operate simultaneously (in parallel), comparing the input voltage against their respective reference levels. The comparator outputs are then fed through a priority encoder that converts the thermometer code into binary format. The conversion speed is limited only by the propagation delays of the comparators and encoder, making flash ADCs ideal for high-speed applications like video processing and radar systems.Advantages: Extremely fast, simple operationDisadvantages: High power consumption, large chip area, limited resolution (typically 8-10 bits due to exponential growth in component count), expensive for high-resolution designs5.2 Successive Approximation Register (SAR) ADCsSAR ADCs are among the most popular and widely used converters, offering an excellent balance between speed, resolution, and power consumption. They consist of a sample-and-hold circuit, a comparator, a Digital-to-Analog Converter (DAC), and successive approximation logic.The conversion process uses a binary search algorithm. Starting with the most significant bit (MSB), the SAR sets each bit to '1' and compares the DAC output with the input voltage. If the DAC output exceeds the input, the bit is cleared to '0'; otherwise, it remains '1'. This process repeats for each bit from MSB to LSB, requiring n clock cycles for an n-bit conversion.SAR ADCs are ubiquitous in microcontrollers (including Arduino, STM32, ESP32, and most ARM Cortex-M devices) and can achieve resolutions from 8 to 18 bits with sampling rates from 100 kS/s to several MS/s.Advantages: Good resolution, moderate speed, low power consumption, cost-effectiveDisadvantages: Slower than flash ADCs, requires n clock cycles for n-bit conversion5.3 Sigma-Delta (ΣΔ) ADCsSigma-delta ADCs achieve very high resolution (16 to 32 bits) by using oversampling and noise-shaping techniques. They sample the input at a rate much higher than the Nyquist rate and use digital filtering to achieve high effective resolution at lower output data rates.These converters are ideal for precision measurement applications such as digital scales, industrial sensors, audio recording equipment, and medical instrumentation where accuracy is paramount and speed is less critical.Advantages: Excellent resolution and linearity, good noise rejection, simple analog circuitryDisadvantages: Slow conversion rate, complex digital filtering required, higher latency5.4 Dual-Slope (Integrating) ADCsDual-slope ADCs integrate the input signal for a fixed period, then integrate a reference voltage of opposite polarity until the integrator returns to zero. The time required for the second integration is proportional to the input voltage. A counter measures this time, providing the digital output.While slow, dual-slope ADCs offer excellent noise rejection (especially for 50/60 Hz line frequency noise) and are commonly used in digital multimeters and panel meters.Advantages: High accuracy, excellent noise rejection, low costDisadvantages: Very slow conversion speed, typically limited to a few conversions per second5.5 Pipeline ADCsPipeline ADCs divide the conversion into multiple stages, with each stage resolving a few bits. The residue from each stage is amplified and passed to the next stage. This architecture allows for high sampling rates (10-100 MS/s) with moderate resolution (8-16 bits), making them popular in video processing, communications, and imaging applications.Ⅵ Applications of ADCs6.1 Digital Oscilloscopes and MultimetersWhile analog oscilloscopes provide real-time display with minimal processing delay, they cannot store waveforms, perform automated measurements, or conduct advanced signal analysis. Digital oscilloscopes solve these limitations by employing high-speed, high-resolution ADCs (typically 8-12 bits at sampling rates up to several GS/s).Modern digital oscilloscopes can capture transient events, perform FFT analysis, decode serial protocols, and store thousands of waveforms for later analysis. Similarly, digital multimeters use precision ADCs (often dual-slope or sigma-delta types) to provide accurate voltage, current, and resistance measurements with 3½ to 8½ digit resolution.6.2 Microcontrollers and Embedded SystemsNearly all modern microcontrollers include integrated ADCs, making them essential for IoT devices, sensor interfaces, and embedded control systems. Common examples include:Arduino (ATmega328P): 10-bit SAR ADC, 6 channels, up to 15 kS/sSTM32 series: 12-bit SAR ADC, multiple channels, up to 5 MS/s (varies by model)ESP32: 12-bit SAR ADC, 18 channels, up to 2 MS/sRaspberry Pi Pico (RP2040): 12-bit SAR ADC, 4 channels, 500 kS/sNordic nRF52 series: 12-bit SAR ADC for low-power wireless applicationsThe Arduino IDE provides a convenient analogRead() function that reads an analog voltage on any analog input pin and returns a 10-bit integer value (0-1023), making ADC usage accessible even for beginners.6.3 Digital Power Supplies and Battery ManagementModern programmable power supplies and battery management systems rely heavily on ADCs to monitor output voltage, current, and temperature. These measurements enable precise regulation, protection features, and user interfaces displaying real-time parameters. High-resolution ADCs (16-24 bits) are often used in precision laboratory power supplies to achieve millivolt-level accuracy.6.4 Audio Recording and ProcessingProfessional audio equipment uses high-quality sigma-delta ADCs with 24-bit resolution and sampling rates of 44.1 kHz, 48 kHz, 96 kHz, or even 192 kHz. These converters enable digital recording, processing, and storage of audio signals with exceptional fidelity. Consumer devices like smartphones and laptops also incorporate audio ADCs for voice recording and communication.6.5 Medical InstrumentationMedical devices such as ECG monitors, pulse oximeters, blood glucose meters, and patient monitoring systems all depend on precision ADCs to convert physiological signals into digital data for analysis, display, and storage. These applications demand high accuracy, low noise, and often require specialized ADCs designed for biomedical signals.6.6 Automotive and Industrial SensorsModern vehicles contain hundreds of sensors monitoring engine parameters, emissions, tire pressure, temperature, acceleration, and more—all requiring ADCs for digital processing. Industrial automation similarly relies on ADCs for process control, quality monitoring, and predictive maintenance applications.Ⅶ How to Use External ADC ICsWhen the built-in ADC of a microcontroller doesn't meet your requirements—whether due to insufficient resolution, speed, or channel count—external ADC ICs provide a solution. Popular external ADC modules include the ADS1115, MCP3008, AD7606, and ADS1256, which can be interfaced with microcontrollers, Raspberry Pi, and other digital systems.Let's examine the Texas Instruments ADS1115, a popular 16-bit ADC with advanced features and excellent performance:Figure 3: ADS1115 16-bit ADC Module7.1 Key Features of Modern ADC ICsI²C/SPI Interface: The ADS1115 uses the I²C bus for communication, making it easy to interface with Arduino, Raspberry Pi, ESP32, and other platforms. Extensive libraries are available in multiple programming languages, simplifying implementation. The I²C interface also allows multiple ADCs to share the same bus using different addresses.Low Power Consumption: Modern ADC ICs are designed for efficiency, with the ADS1115 consuming only 150 µA in continuous conversion mode and less than 1 µA in power-down mode. The operating voltage range of 2.0V to 5.5V makes it compatible with both 3.3V and 5V systems.Programmable Gain Amplifier (PGA): The ADS1115 includes a built-in PGA with selectable gain settings (±6.144V, ±4.096V, ±2.048V, ±1.024V, ±0.512V, ±0.256V), allowing you to optimize the measurement range for your signal amplitude and maximize resolution.Flexible Input Configuration: The four analog inputs can be configured as four single-ended inputs or two differential pairs, providing versatility for different measurement scenarios. Differential inputs are particularly useful for rejecting common-mode noise.Programmable Comparator: An integrated comparator with programmable thresholds can generate interrupts when the input exceeds specified limits, enabling efficient event-driven programming without continuous polling.High Resolution: With 16-bit resolution, the ADS1115 provides 65,536 discrete levels, offering significantly better precision than typical 10-bit or 12-bit microcontroller ADCs. At the ±4.096V range, this translates to approximately 125 µV per step.Ⅷ Limitations and Considerations of ADCsWhile ADCs are essential components, they do have inherent limitations that designers must consider:Conversion Time: ADCs require finite time to perform conversions, ranging from nanoseconds (flash ADCs) to milliseconds (high-resolution sigma-delta ADCs). This introduces latency that may be problematic in real-time control systems.Quantization Error: The discrete nature of digital representation means that analog values between quantization levels cannot be precisely represented, introducing an inherent error of up to ±½ LSB.Aliasing: If the input signal contains frequency components above half the sampling rate (Nyquist frequency), aliasing occurs, causing high-frequency signals to appear as lower frequencies in the digital output. Anti-aliasing filters are required to prevent this.Noise and Interference: ADCs are sensitive to electrical noise, which can degrade measurement accuracy. Proper PCB layout, grounding, filtering, and shielding are essential for optimal performance.Input Impedance Effects: The ADC input impedance can load the source circuit, potentially affecting the signal being measured. Buffer amplifiers may be necessary for high-impedance sources.Cost and Complexity: High-performance ADCs (high resolution and high speed) are expensive and may require complex supporting circuitry, including precision voltage references, low-noise power supplies, and sophisticated digital signal processing.Power Consumption: High-speed ADCs can consume significant power, which may be problematic in battery-powered or energy-constrained applications.Ⅸ Frequently Asked Questions (FAQ)1. Why do we need an ADC converter?The physical world is inherently analog—sound waves, light, temperature, pressure, and other phenomena exist as continuous values. However, digital computers and microcontrollers can only process discrete binary numbers (ones and zeros). ADCs bridge this gap by sampling analog signals and converting them into digital representations that computers can store, process, and analyze. This enables applications ranging from digital audio recording and sensor data logging to medical diagnostics and industrial automation. Without ADCs, modern digital systems would be unable to interact with or measure real-world phenomena.2. What is the slowest type of ADC?Dual-slope (integrating) ADCs are among the slowest, typically performing only a few conversions per second. However, this slow speed is often intentional—these ADCs integrate the signal over a long period, which provides excellent noise rejection, particularly for 50/60 Hz power line interference. They're commonly used in digital multimeters where accuracy is more important than speed. Sigma-delta ADCs can also be quite slow when configured for maximum resolution, though they offer superior performance compared to dual-slope designs.3. What is the difference between 8-bit, 10-bit, and 12-bit ADCs?The bit count determines the resolution—how finely the ADC can divide the voltage range. An 8-bit ADC provides 256 discrete levels (2⁸), a 10-bit ADC provides 1,024 levels (2¹⁰), and a 12-bit ADC provides 4,096 levels (2¹²). With a 5V reference: an 8-bit ADC has ~19.5 mV per step, a 10-bit ADC has ~4.9 mV per step, and a 12-bit ADC has ~1.2 mV per step. Higher resolution allows detection of smaller voltage changes, making the measurement more precise. However, higher resolution often comes with trade-offs in speed, cost, and complexity. Choose the resolution based on your application's accuracy requirements.4. What is the difference between ADC and DAC?An ADC (Analog-to-Digital Converter) is an input device that converts continuous analog signals into discrete digital values for processing by digital systems. A DAC (Digital-to-Analog Converter) performs the opposite function—it's an output device that converts digital values into continuous analog signals. For example, when recording audio, an ADC converts sound waves (analog) into digital data; when playing back that audio, a DAC converts the digital data back into analog signals that drive speakers. Both are essential for digital systems to interact with the analog world.5. How does the ADC inside a microcontroller work?Most microcontrollers use SAR (Successive Approximation Register) ADCs due to their good balance of speed, resolution, and power efficiency. The process involves: (1) A sample-and-hold circuit captures and holds the input voltage stable during conversion; (2) The SAR logic performs a binary search, testing each bit from MSB to LSB by comparing the input against a DAC output; (3) After n clock cycles (for n bits), the final binary value is stored in a register where the CPU can read it. The entire process typically takes a few microseconds, and many microcontrollers can perform conversions automatically in the background using DMA (Direct Memory Access).6. How do you convert analog to digital?The conversion process involves three main steps: (1) Sampling: The continuous analog signal is measured at discrete time intervals determined by the sampling rate; (2) Quantization: Each sampled voltage value is mapped to the nearest discrete level based on the ADC's resolution; (3) Encoding: The quantized level is represented as a binary number. The sampling rate must be at least twice the highest frequency in the signal (Nyquist theorem) to avoid aliasing, and the resolution must be sufficient to capture the required detail in the amplitude.7. Why do we need to convert analog to digital?Digital representation offers numerous advantages: (1) Processing: Digital signals can be easily manipulated using algorithms, filters, and mathematical operations; (2) Storage: Digital data can be stored indefinitely without degradation; (3) Transmission: Digital signals are less susceptible to noise and interference during transmission; (4) Accuracy: Digital systems can perform precise calculations and measurements; (5) Integration: Digital data can be easily shared between different systems and processed by computers; (6) Advanced Features: Digital signals enable machine learning, pattern recognition, and sophisticated analysis impossible with analog systems.8. What are common applications of ADCs?ADCs are used in countless applications: digital oscilloscopes and multimeters for test equipment; microcontrollers and embedded systems for sensor interfaces; audio recording and playback equipment; medical devices (ECG, pulse oximeters, blood pressure monitors); automotive sensors (engine management, safety systems); industrial process control; telecommunications equipment; digital cameras and imaging systems; touchscreen interfaces; battery management systems; smart home devices and IoT sensors; scientific instrumentation; and data acquisition systems. Essentially, any application requiring a digital system to measure or respond to analog phenomena requires an ADC.9. What's the difference between analog and digital signals?Analog signals are continuous in both time and amplitude—they can take any value within a range and change smoothly over time. Examples include sound waves, temperature variations, and light intensity. Digital signals are discrete in both time and amplitude—they exist only at specific time intervals (samples) and can only take specific values (quantization levels). Digital signals are typically represented as binary numbers (sequences of 1s and 0s). While analog signals directly represent physical phenomena, digital signals are representations that approximate the analog world in a form that computers can process.10. What factors should I consider when choosing an ADC?Key selection criteria include: (1) Resolution: How many bits are needed for your accuracy requirements? (2) Sampling Rate: How fast must you sample to capture your signal's frequency content? (3) Input Range: Does it match your signal amplitude? (4) Number of Channels: How many signals need to be measured? (5) Interface: SPI, I²C, parallel, or integrated? (6) Power Consumption: Critical for battery-powered applications; (7) Cost: Balance performance with budget; (8) Package Size: PCB space constraints; (9) Input Type: Single-ended or differential? (10) Additional Features: Built-in PGA, reference, comparator, etc. Consider your application's priorities—speed, accuracy, power, or cost—and choose accordingly.Ⅹ ConclusionAnalog-to-Digital Converters are fundamental building blocks of modern electronics, serving as the essential bridge between our analog physical world and the digital systems that process information. From the simplest temperature sensor in a home thermostat to the sophisticated signal processing in medical imaging equipment, ADCs enable digital systems to perceive, measure, and respond to real-world phenomena.Understanding ADC specifications—resolution, sampling rate, input range, and architecture—is crucial for selecting the right converter for your application. Whether you're using the built-in ADC in a microcontroller for a hobby project or designing a precision measurement system with external high-resolution ADCs, the principles remain the same: sample the analog world accurately and convert it to digital form for processing.As technology advances, ADCs continue to improve in resolution, speed, and power efficiency while decreasing in cost and size. This ongoing evolution enables new applications in IoT, wearable devices, autonomous vehicles, and countless other fields where the digital and analog worlds intersect.Last Updated: November 2025
Kynix On 2021-01-19
In this article, you will learn what is AVR microcontroller, what are its features, how to choose a suitable AVR microcontroller, and how to program AVR microcontroller in software and so on. Catalog I. What is a AVR Microcontroller? II. AVR Microcontroller Features III. Selection of AVR Series Single-chip Microcomputer IV. AVR Microcontroller Application Field V. Introduction to the experimental tools and equipment used in AVR VI. AVR Microcontroller Programming Software FAQ I. What is AVR Microcontroller? AVR microcontroller is an enhanced 8-bit and built-in Flash RISC order set developed by ATMEL. Compared with CISC, RISC is not just to reduce the command simply, but make the structure of the computer more simple and reasonable to improve the speed of the operation. The design absorbs the advantages of the 8051 and PIC microcontroller and has the ability to execute one instruction in a single clock cycle. The speed can reach 1Mips/MHz. AVR microcontrollers are widely used in the outside devices of the computers, industrial real-time control, instrumentation, communication equipment, home appliances, and other fields. This vedio shows you how to build your own AVR development board and how to use it in your projects. The hardware structure of AVR adopts a compromise strategy of 8-bit and 16-bit computer, that is, the local register memory stack (32 register files) and the single high-speed input/output scheme (i.e. input capture register, the output compares matching registers and corresponding control logic) are adopted, improving the execution speed of instruction, overcoming the bottleneck phenomenon, and enhancing the function. At the same time, it reduces the cost of external equipment management, simplifies the hardware structure, and reduces the cost. Therefore, the AVR microcontroller is a high-performance-price single-chip microcomputer, which has achieved an optimized balance in hardware/software development, speed, performance, and cost. The introduction of the AVR microcontroller breaks this old design pattern completely, abolishes the machine cycle, and gives up the complex instruction computer (CISC) to pursue the instruction complete method; Reducing instruction set, taking words as the unit of instruction length, arranging the rich operands and opcodes in one word (the majority of single-cycle instructions in the order set are the same), and the reference period is short and the instruction can be prefetched, realizing flow operation, so you can execute instructions at high speed. Of course, high reliability must be required. II. AVR Microcontroller Features 1. High-quality embedded Flash program memory, can be repeatedly written and erased, supporting ISP and IAP, which is easy to have product debugging, development, production, update. Long service-life EEPROM, can save key data for a long time and avoid power loss. High-capacity RAM in chips supports the development of system programs in high-level languages. 2. High speed, low power consumption, with SLEEP (power saving when sleeping) function. Each instruction can be executed at 50ns/ 20MHz, while power consumption is between l~2.5mA (typical power consumption, when WDT turned off, is 100nA), AVR (with prefetching instruction function) based on Harvard structure concept. That is, there are different memories and buses for program storage and data, when an instruction is executed, the next instruction is pre-removed from the program memory. This allows instructions to be executed within each clock cycle. The AVR microcontroller can operate at a wide voltage (2.7V~5V), has the strong anti-jamming ability, and reduces the general 8-bit computer software anti-interference design and hardware usage. 3. All the I/O lines of the AVR single-chip computer have an adjustable pull-up resistor. The input and output characteristics of parallel I/O port are similar to those of PIC's HI/LOW output and three-state high impedance H1-Z input, also be set similar to the 8051 series of internal high resistance as input function. It can be set as an input/output or can be set as high resistance input initially. So that I/O resources are flexible, powerful, and fully utilized. AVR's I/ O can accurately reflect the input/output of I/O. 4. AVR microcontroller has a variety of independent clock dividers for URAT, IIC, SPI. The Prescaler with up to 10 bits when matching with the 8 / 16-bit timer, can set the frequency division coefficient through software to provide a variety of timing times. The timer/counter (single) in the AVR microcontroller can be counted bidirectionally to form a triangle wave, then matched with the output comparison matching register, the output PWM of pulse width modulation with variable duty cycle, variable frequency, and variable phase square wave is generated. 5. For industrial products, with high current (irrigation current) lO=20mA~40mA (single output), can directly drive SSR or the relay. The built-in watchdog timer (WDT) is used to avoid the faulty program and improve the anti-interference ability of the product. 6. Superfunctional streamlined instruction. There are 32 general working registers (equivalent to 32 accumulators in 8051 single-chip computers), which overcomes the data processing problems caused by the single accumulator. 7. AVR microcontroller has analog comparator, I/O port can be used for A/D conversion, can form cheap A/D converter. 8. Byte-oriented high-speed hardware serial interface TWI and SPI. TWI is compatible with the I2C interface, with ACK signal hardware transmission and recognition, address recognition, bus arbitration, and other functions, It can realize all four kinds of multi-machine communication from one to another. SPI has the same function. It also looks like the 8051, AVR has multiple fixed interrupt vector entry addresses, so it can respond to interrupts quickly, and it will interrupt like PIC at the same vector address. 9. AVR microcontroller has an automatic power-up reset circuit, an independent watchdog circuit, low voltage detection circuit BOD, multiple reset sources (automatic up and down reset, external reset, watchdog reset, BOD reset). It can set up a delay operation program after running the system, enhancing the reliability of the system. And meanwhile, the AVR microcomputer has many power-saving sleep modes, wide voltage operation(2.7V-5V), strong anti-interference ability. So it is used widely in the electrical industry due to its advantages. 10. Enhanced high-speed synchronous/asynchronous serial port has the functions of generating checking code based on hardware, hardware detecting and debugging, two-stage receiving buffering, baud rate automatically adjusting position (when receiving), shielding data frame, and so on. They improve the reliability of communication and help write the program easily. It also makes up the distributed network and to realize the complex application of multi-computer communication system. The function of the serial port is much more than the serial port of the MCS-51/96 microcontroller. In addition, the AVR single-chip microcomputer has a high-speed operation, and the interrupt service time is short, therefore, high baud rate communication can be realized. Serial asynchronous communication UART does not occupy timer and SPI transmission function, because of its high speed, it can work in a standard integer frequency, while baud rate can reach 576Ko11, with multi-channel 10-bit AID converter and real-time clock RTC. III. Selection of AVR Series Single-chip Microcomputer AVR microcontroller technology embodies a variety of devices (including FLASH program memory, watchdog, EEPROM, synchronous/asynchronous serial port, TWI/ SPI/ AID/ A/D converter, timer, counter, etc.) and various functions (enhanced reliability of reset system, reduced power-consumption and anti-interference sleep mode, various interrupt systems, timer/counter with input capture and match output, replaceable I/O port. It fully reflects the modern single-chip technology develops into the "on-chip" SoC system. AVR series microcontroller is complete, can be applied to different occasions. In order to make good use of it, it is necessary to know its classification based on different standards and functions. And here are introducing three grades and their models as examples. AVR microcontroller has three grades: Low-grade Tiny series: this type of microcontroller has Less memory, small in size, apt only for simpler applications, the applying model like Tiny11/12/13/15/26/28, etc.; Midrange-grade AT90S series: this microcontroller is used commercially for compound applications, it requires large program memory and also high speed, such as AT90S1200/2313/8515/8535, etc.; High-grade ATmega: this type of microcontroller is the most popular one which has a good amount of memory up to 256KB, higher built-in peripherals, and fit for modest to difficult applications, the applying model like the ATmega8/16/32/64/128 (storage capacity is 8/16/32/64/128KB) and ATmega8515/8535. AVR device pins range from 8 to 64, with a variety of packages available. IV. AVR Microcontroller Application Field Air conditioning control panel Printer control board(PRCB) Intelligent meter Intelligent flashlight LED control screen Medical equipment GPS V. Experimental tools and equipment used in AVR IC-CAVR6.31AC Language Compiler Integrated Development Environment(ATMEL AVR Studio) PonyProg2000 Download Software AVR Microcontroller Integrated Test Board AVR-JTAG Simulator Parallel Port Loader High Stability Power Supply Multifunctional TOP2004 USB Programmer PC VI. AVR Microcontroller Programming Software ICCAVR6.31AC Language Compiler ICCAVR6.31A is a C programming language compiler developed by ImageCraft for AVR MCU. It is a pure 32-bit with an integrated development environment, also consists of an editor and project manager. ICCAVR has been widely used because of its powerful function, simple operation, good technical support, and reasonable price. The following figure is the working interface of ICCAVR. AVRStudio Integrated Development Environment AVRStudio is an integrated development environment that integrates project management, program assembly, program debugging, program download, JTAG simulation, and so on. However, AVRStudio does not support the C programming language. Therefore, when we develop an AVR microcontroller with the C programming language, we should first compile the C programming language with ICCAVR, then open the compiled code file with AVRStudio to debug the program. The following figure is the workspace of SVRAStudio. PonyProg2000 software It is mainly used for AVR MCU and PIC MCU program download, can be used in Windows95/98/ME/NT/20001XP operating systems. The following figure is the working interface of PonyProg2000. Attention Write with PORTx, read with PINx During the experiment, try not to connect the pin directly to the GND/VCC. When it is not set properly, the I/O port will output/fill the high current of 80mA (Vcc=5V), resulting in device damage. As Input 1.The suspension (high resistance state) will be susceptible to interference if the internal pull-up resistor is usually allowed(generally, it seems that 51 has a strong anti-interference ability because 51 always has internal resistance to pull up). 2.Try not to let input suspended or analog input level close to VCC/2, because it will consume too much current, especially in low power applications of CMOS circuits. 3.The pin level provided by the reading software usually requires a clock cycle interval between the assignment instruction “out” and the read instruction “in”, such as the nop order. 4.The input of the functional module (interrupt, timer) can be triggered by a low level, also it can be the rising edge trigger or the falling edge trigger. 5.For high-resistance analog signal input, remember not to allow internal pull-up resistor to affect accuracy, such as ADC digital-analog converter input, analog comparator input, and so on. As Output Taking the necessary current limiting measures, for example, drive the LED to serialize the current-limiting resistor. Reset The internal pull-up resistor will be disabled when to reset. If strict level control is required in an application, such as motor control, it is necessary to use an external resistor to fix the level. Dormant As output, it is still in the same state Input is generally invalid, but the input function is valid if the second function is interrupted. For example, the wake-up function of an external interrupt FAQ 1. What is meant by AVR microcontroller? AVR is a family of microcontrollers developed since 1996 by Atmel, acquired by Microchip Technology in 2016. These are modified Harvard architecture 8-bit RISC single-chip microcontrollers. AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to one-time programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time. 2. How does AVR microcontroller work? AVR is an 8-bit microcontroller belonging to the family of Reduced Instruction Set Computer (RISC). In RISC architecture the instruction set of the computer are not only fewer in number but also simpler and faster in operation. ... The input/output registers available are of 8-bits. 3. What does AVR stand for in electronics? An automatic voltage regulator (AVR) is an electronic device that maintains a constant voltage level to electrical equipment on the same load. 4. What are the types of AVR? In general, there are two types of an Automatic Voltage Regulator. One is the Relay Type and the other is the Servo Motor type. A Relay type AVR makes use of electronic circuitry like relays and semi-conductors to regulate the voltage. 5. Is Arduino AVR or ARM? Arduino uses AVR- or ARM-based microcontrollers, depending on board. PIC is the oldest of the lot. There's no such thing as an “Arduino microcontroller”. 6. What is full form of AVR? The Full form of AVR is Aortic Valve Replacement. An AVR is a type of open heart surgery used to treat problems with the heart's aortic valve. 7. What happens if AVR fails? When AVR fails a protection called Field Failure protection will come into picture and trip the generator. ... If Failure of field is associated with under voltage which might happen due to severe fault near the generator and AVR might trip not able to maintain the voltage, the generator is tripped instantaneously. 8. What is AVR and ARM? ARM is a microprocessor or CPU architecture while AVR is a microcontroller. ARM can be used similar to a microcontroller when combined with ROM, RAM and other peripherals to a single chip like LPC2148. ... Microcontroller has build in RAM, ROM and other peripherals in a single chip. While microprocessor has only the CPU. 9. What are the applications of AVR and ARM? AVR and ARM comes under the family of micro-controller. But ARM can be used as both Microcontroller or as Microprocessor. ARM micro-controller and AVR micro-controller differs from each other in terms of different architecture and different sets of instruction, speed, cast, Memory, Power Consumption, Bus Width etc. 10. What is AVR microcontroller architecture? AVR is a 8-bit RISC architecture (Reduced Instruction Set Computing) microcontroller in market since 1996 which is having on-chip programmable flash memory, SRAM, IO data space & EEPROM. AVR is the first MCU in market which has on-chip flash storage. You May Also Like A Complete Guide to Solid State Drive (SSD) Brief introduction to the Application of some IC chips in Maxim Integrated Product Recommendation KY32-AT49BV162AT(T) KY32-K9T1G08U0M-YIBO KY32-CY7C131E-55NXI
kynix On 2018-12-07
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