Arduino 定时器 [终极指南](原文)

news2024/11/11 5:47:23

Arduino Timers [Ultimate Guide]

by Khaled Magdy

In this tutorial, we’ll discuss Arduino Timers from the very basic concepts all the way to implementing Arduino timer-based systems. We’ll start off by discussing what is a timer, how they work, and what are different timer operating modes. You’ll learn all Arduino timer mechanics and how to properly set up timer-based systems.

We’ll create a couple of Arduino Timer Example Code Projects in this tutorial to practice what we’ll learn all the way through. And finally, we’ll draw some conclusions and discuss some advanced tips & tricks for Arduino timers that will definitely help you take some guided design decisions in your next projects. Without further ado, let’s get right into it!


Arduino Timers

Timer modules in Arduino provide precise timing functionality. They allow us to perform various tasks, such as generating accurate delays, creating periodic events, measuring time intervals, and meeting the time requirements of the target application.

Each Arduino board has its target microcontroller that has its own set of hardware timers. Therefore, we always need to refer to the respective datasheet of the target microcontroller to know more about its hardware capabilities and how to make the best use of it.

1. Arduino Hardware Timers

Arduino UNO (Atemga328p) has 3 hardware timers which are:

  • Timer0: 8-Bit timer
  • Timer1: 16-Bit timer
  • Timer2: 8-Bit timer

Those timer modules are used to generate PWM output signals and provide timing & delay functionalities to the Arduino core, and we can also use them to run in any mode to achieve the desired functionality as we’ll see later on in this tutorial.

Each hardware timer has a digital counter register at its core that counts up based on an input clock signal. If the clock signal is coming from a fixed-frequency internal source, then it’s said to be working in timer mode. But if the clock input is externally fed from an IO or any async source, it’s said to be working as a counter that counts incoming pulses.

2. Why Do We Use Timers?

It’s way more efficient to use hardware timers instead of software solutions, especially replacing things like delay() function, periodic event handling, PWM signal generation, and many other applications. Hardware timer modules can operate in one of many modes, each of which has its own applications and use cases as we’ll discuss hereafter in the next section.

Those are the most common use cases for hardware timers:

  • Generating time interval delay between events
  • Periodic events handling
  • Measuring the time between events
  • Counting external or internal events/pulses
  • Generating PWM output signals

By configuring a hardware timer, we can get it to achieve any of the applications mentioned above as we’ll see when we discuss the timer operating modes.

3. Arduino Timer Prescaler

A prescaler in a hardware timer module is a digital circuit that is used to divide the clock signal’s frequency by a configurable number to bring down the timer clock rate so it takes longer to reach the overflow (maximum count number).

This is really useful to control the maximum time interval that can be generated using the timer module, the PWM output frequency, or the range of time that can be measured using the timer module.

Running the timer module at the system frequency is good for resolution but will generate so many timer overflow interrupts that needs extra care in your code. Hence, using a prescaler can be useful to avoid this situation in the first place if needed.

In timer mode, the timer module will have the internal clock of the system as a clock source and it passes through the prescaler as shown below. You can programmatically control the division ratio of the prescaler to control the timer input clock frequency as you need.

STM32 Timers Explained Tutorial With Modes PWM Encoder

The timer prescaler divider values differ from one timer module to another and it’s clearly stated in the datasheet for each timer module (Timer0, 1, and 2).

4. Arduino Timer Interrupts

Arduino timers provide different interrupt signals for various events. Such as timer overflow, when a timer reaches its maximum count value (255 for 8-Bit, and 65535 for 16-Bit timers). It fires an overflow interrupt, rolls back to zero, and starts counting up again.

There is also two output compare registers in each timer (COMPA and COMPB). When the timer register’s counter value reaches COMPA value, it drives the OCnA pin HIGH or LOW depending on your configurations, and it also fires a COMPA interrupt (if enabled). And the same goes for COMPB.

This is an interactive simulation of how timer interrupt events are generated (Timer Overflow, COMPA, and COMPB).

Each timer interrupt signal can be enabled or disabled individually and has its own interrupt vector address.

5. Arduino Timers Comparison

This is a summarized table for Arduino UNO (Atmega328p) timers, differences between them, capabilities, operating modes, interrupts, and use cases.

Timer0Timer1Timer2
Resolution8 Bits16 Bits8 Bits
Used For PWM Output Pins#5, 69, 1011, 3
Used For Arduino Functionsdelay() millis() micros()Servo Functionstone()
Timer Mode
Counter Mode
Output Compare (PWM) Mode
Input Capture Unit Mode
Interrupts VectorsTIMER0_OVF_vect ,TIMER0_COMPA_vect, TIMER0_COMPB_vect`TIMER1_OVF_vect ,TIMER2_COMPA_vect, TIMER1_COMPB_vect, TIMER1_CAPT_vectTIMER2_OVF_vect, TIMER2_COMPA_vect, TIMER2_COMPB_vect`
Prescaler Options1:1, 1:8, 1:64, 1:256, 1:10241:1, 1:8, 1:64, 1:256, 1:10241:1, 1:8, 1:32, 1:64, 1:128, 1:256, 1:1024

❕ Note

Playing with any timer configurations can and will disrupt the PWM output channels associated with that module. Moreover, changing the configurations of timer0 will disrupt the Arduino’s built-in timing functions ( delay, millis, and micros). So keep this in mind to make better design decisions in case you’ll be using a hardware timer module for your project. Timer1 can be the best candidate so to speak.


Arduino Timers – Timer Mode

The timer module in timer mode is configured to have the internal system clock as the clock source with multiple prescaler options. It’s generally used to generate fixed time interval interrupts to insert time delays between events or to execute periodic events at fixed time intervals.
在这里插入图片描述
In time mode, the timer module will keep counting (0 to 255 or 65535 depending on resolution). At overflow, a timer overflow interrupt is fired and the timer rolls over back to zero and starts counting again.

Arduino Timer Equations

Timer modules in microcontrollers have a general equation which is as follows:
在这里插入图片描述

The desired output time interval (TOUT) is equal to the number of timer ticks multiplied by the single tick time. The timer’s tick time is determined by the input clock frequency and the prescaler ratio that you’ve selected. Therefore, the general timer equation can be expressed like this:
在这里插入图片描述

And that’s the equation we’ll be using to design timer-based applications (e.g. time interval delays, periodic tasks execution, and much more). You should note that the maximum TOUT is defined by the prescaler ratio configuration. Changing the prescaler will allow us to raise the maximum allowable TOUT time interval generation with the timer module before it overflows.

For example, Timer1 in Arduino UNO is clocked at 16MHz. With a prescaler of 1:1, the Maximum TOUT can be achieved by setting the TicksCount to its maximum value of 65536. This will give us TOUT(Max) = (1×65536)/16M = 4.01ms.

If you need to generate a larger TOUT time interval with that timer module @ 16MHz clock, you need to choose another option for the prescaler. Let’s say you’d like to generate a 500ms timer interrupt as a time-base for your system. This means, the TOUT(MAX) needs to be >500ms.

Therefore, setting the prescaler ratio to 1:256 will be the best option. Because it’ll allow a maximum TOUT(MAX) of = (256×65536)/16M = 1.049s. Which is more than the 500ms requirement so it becomes achievable by selecting this larger prescaler ratio. Let’s now discuss how to use the general timer equation and do the required calculations to be able to configure the timer module properly.

Arduino Timer Calculations

The best way to demonstrate timer module calculations is to consider a practical example use case and walk through the calculation process step by step. And that’s what we’re going to do in this section.

Let’s say you’d like to generate a periodic timer interrupt every 100ms and use it as a time base for your system. We’ll be using the Timer1 module which is clocked at 16MHz (in Arduino UNO boards).

Step 1) Select a suitable prescaler divider. The required TOUT is 100ms. The TOUT(MAX) should be > 100ms. Therefore, selecting a prescaler of 1:64 will be sufficient. Because at 1:64 prescaler, the TOUT(MAX) = (64×65536)/16M = 262ms. Which is definitely above the required 100ms time interval.

Step 2) Using the general timer equation, plug in the (TOUT value, Prescaler divider, and CLK frequency). Then solve the equation for the TicksCount value.

在这里插入图片描述

Step 3) TicksCount = 25,000 ticks. And that’s the output of the calculation that we’ll use thereafter to program the timer module to generate the desired 100ms timer interrupt event.

Arduino Timer Programming

After calculating the required timer TicksCount to achieve the desired TOUT time interval for timer interrupt events, we can go about programming the Arduino timer module in two different ways.

1- Timer Preloading

First method is to preload the timer register (TCNTx) with a value in such a way it reached overflow (65535) after only TicksCount ticks. For the previous 100ms example, the TicksCount turned out to be 25000 ticks. Therefore, the timer preload value = 65535-25000 = 40535.

By writing 40535 to the TCNTx register, we guarantee that it’s going to tick 25000 ticks to reach the overflow state. In the timer overflow interrupt ISR handler, we’ll also need to preload the TCNTx register with the same value and keep repeating over and over again.

Here is an Arduino code example for Timer Preloading.

/*
* LAB Name: Arduino Timer Preloading
* Author: Khaled Magdy
* For More Info Visit: www.DeepBlueMbedded.com
*/
 
ISR(TIMER1_OVF_vect)
{
  TCNT1 = 40535; // Timer Preloading
  // Handle The 100ms Timer Interrupt
  //...
}
 
void setup()
{
  TCCR1A = 0;           // Init Timer1
  TCCR1B = 0;           // Init Timer1
  TCCR1B |= B00000011;  // Prescalar = 64
  TCNT1 = 40535;        // Timer Preloading
  TIMSK1 |= B00000001;  // Enable Timer Overflow Interrupt
}
void loop()
{
  // Do Nothing
}

2- Timer Compare Registers

An easier way to achieve the same goal without disrupting the timer’s TCNTx register’s value would be to use the output compare match interrupt events. This is probably the best way to implement timer-based interrupt events. Because it gives you two (COMPA and COMPB) registers to generate two independent time interrupt events using the same timer module.

Considering the previous 100ms time interval interrupt example, we need the timer to tick 25000 ticks to get the 100ms periodic interrupt. So, we’ll use COMPA compare register, enable its interrupt, and set its value to 25000. When a compare match occurs (when TCNT1 = OCR1A), an interrupt is fired. And that’s the 100ms periodic interrupt we want.

To keep it running at the same 100ms rate, we need to update the COMPA value because the timer’s count has now reached 25000. Therefore, we need to add 25000 ticks to the COMPA value. Don’t worry about overflow, at 65535, the register will roll over back to zero exactly like the timer’s TCNTx register does. So it’s going to work flawlessly all the time.

And that’s it! Here is an Arduino code example for Timer Compare Match Interrupt.

/*
* LAB Name: Arduino Timer Compare Match Interrupt
* Author: Khaled Magdy
* For More Info Visit: www.DeepBlueMbedded.com
*/
 
ISR(TIMER1_COMPA_vect)
{
  OCR1A += 25000; // Advance The COMPA Register
  // Handle The 100ms Timer Interrupt
  //...
}
 
void setup()
{
  TCCR1A = 0;           // Init Timer1
  TCCR1B = 0;           // Init Timer1
  TCCR1B |= B00000011;  // Prescalar = 64
  OCR1A = 25000;        // Timer CompareA Register
  TIMSK1 |= B00000010;  // Enable Timer COMPA Interrupt
}
void loop()
{
  // Do Nothing
}

Arduino Timer Calculator & Code Generator Tool

To make things much easier & quicker for you, here is an Arduino Timer Interrupt Calculator & Code Generator Tool. This tool will take your desired time interval, the timer module’s number, and the type of interrupt signal you’d like to use. And it’ll give you a complete Arduino startup sketch ready for your project. You can either copy & paste it as is or just get the configurations, timer prescaler, and timer preload value.

Arduino-Timer-Calculator

Both methods shown in this section (Timer Preloading & Timer Compare Match), more in-depth demonstration, more code examples & testing, and how to use the Arduino timer calculator & code generator, all can be found in the dedicated tutorial linked below. This is the ultimate guide for Arduino Timer Interrupts that you definitely need to check out.

Also Read

Arduino Timer Interrupts,This tutorial will give you more in-depth information about Arduino Timer interrupts and how to set up timer interrupts for periodic events. You’ll also learn how to use our timer code generator for different interrupt types (COMPA, COMPB, and OVF) with multiple code example projects.


Arduino Timers – Counter Mode

The timer module in counter mode is configured to have an external pin as the clock source with multiple prescaler options. It’s generally used to count external input pulses or measure an input signal by counting its rising or falling edges over a fixed time interval.

There are so many applications and use cases for timer modules in counter mode as we’ll see later on. Here is the block diagram for the hardware timer in counter mode.

在这里插入图片描述

As you can see, the Tn pin is the input pin to the timer’s clock source. This is the major difference between a hardware timer working in Counter Mode vs Timer Mode. The Timer input pin (Tn) can be hooked up to a push button and we can use it to count the pulses generated when we click on the button.

The timer module in counter mode can be set to count up each RISING or FALLING edge on the Tn input pin.

在这里插入图片描述

You can refer to the Arduin UNO Pinout Guide to identify all timer input pins (Tn). Where T0 is the Timer0 input pin and T1 is the Timer1 input pin. In Arduino UNO (Atmega328p), the T0 & T1 pins are Arduino IO pins (4 & 5) respectively. Also note that: the Counter0 register (TCNT0) is 8 bits, while the Counter1 register (TCNT1) is 16 bits.

❕ Note

Timer2 doesn’t have an input pin so it doesn’t operate in counter mode.

Arduino Counter Timer Mode Programming

To set an Arduino Timer module to operate in counter mode, we’ll use the clock selection bits in the TCCRxB register. Here are the counter mode clock options for the least significant 3 bits in the TCCRxB register (as stated in the datasheet).

Arduino-Counter-Timer-Registers
Here is an example of an Arduino Counter Timer Code that sets Timer1 to operate in Counter Mode (counts up every RISING edge on the T1 pin). The counter register’s value is sent to the PC over the serial port 4 times per second.

/*
* LAB Name: Arduino Timer (Counter Mode)
* Author: Khaled Magdy
* For More Info Visit: www.DeepBlueMbedded.com
*/
 
void setup()
{
  TCCR1A = 0;           // Init Timer1A
  TCCR1B = 0;           // Init Timer1B
  TCCR1B |= B00000111;  // External Clock on T1 Pin (RISING)
  TCNT1 = 0;
  Serial.begin(9600);
}
 
void loop()
{
  Serial.print("Counter Ticks = ");
  Serial.println(TCNT1);
  delay(250);
}

Here is the result of running this example project on my Arduino UNO board and showing the result on the serial monitor.

在这里插入图片描述
For more examples and demonstrations of Arduino Timers (Counter Mode), it’s highly recommended to check out its dedicated tutorial linked below. It’ll give you more information, code examples, and applications for Arduino Timers in Counter Mode.

Also Read

Arduino Timer (Counter Mode) Tutorial

This tutorial will give you more in-depth information about Arduino Timers ( in Counter Mode). How to configure Arduino Timers to operate in Counter mode, and what are the use cases & applications for Counter Mode? As well as a couple of practical Arduino code example projects.

❕ Note

Note that Arduino Timers in Counter Mode depend on an external clock source which is the Tn input pin. This IO pin is obviously susceptible to all sorts of noise (like the Button Bouncing if you’re using a push button hooked to the Tn pin). Therefore, it’s your responsibility to clean up the signal on a hardware level. There is no way to debounce or filter the signal in the software.

And state change on the Tn pin will be considered as a clock cycle that will cause the counter register to count up even if it was just a glitch or noise. Software algorithms can’t fix this issue. However, a simple RC Filter on the Tn input pin will prevent this issue in the first place.


Arduino Timers – PWM (Output Compare)

The timer module in output compare mode (PWM) is configured to have an internal clock source with multiple prescaler options. It’s generally used to generate PWM output signals on the OCnx pins (OCnA & OCnB), where n is the timer module’s number.

Here is a screenshot for the block diagram of the output compare unit hardware within timer modules in Arduino (Atmega328p) microcontroller.

在这里插入图片描述

The timer module will be free running all the time, and its value (TCNTn) is continuously compared against the OCRnx register (which is double-buffered to eliminate PWM glitches). When the TCNTn matched the OCRnx register’s value, a compare match event is triggered which drives the OCnx output pin HIGH or LOW depending on your configuration.

At the overflow of the TCNTn counter register, the OCnx pin state is flipped. This gives us a PWM output signal on the OCnx pin whose duty cycle can be easily controlled by the OCRnx register. For each timer, there are two PWM output pins as stated earlier (OCnA & OCnB).

Arduino Output Compare (PWM Mode) Programming

There is a built-in Arduino function for PWM output control which is the analogWrite() function. That makes it much easier to generate PWM output signals with Arduino. Which is very useful in countless applications.

You can learn more in-depth information about Arduino PWM signal generation & create a couple of practice example projects by following the dedicated tutorial linked below. It’s the ultimate guide for Arduino PWM that you need to keep for your reference.

Also Read

Arduino PWM Tutorial

This tutorial will provide you with more in-depth information about Arduino PWM output. Starting from the basics of PWM signal, its frequency, duty cycle, and resolution, and will discuss in detail how it works and how to use it in various Arduino control projects.


Arduino Timers – Input Capture Unit

The timer module in input capture mode is configured to have an internal clock source with multiple prescaler options. It’s generally used to capture the timer counter value at certain events on the input capture pin (RISING or FALLING edges). The (Input Capture Unit) is also referred to as ICU for short.

The timer module will be free running all the time, and its value (TCNTx) is captured and saved into the input capture register (ICRx) immediately when the input capture pin state has changed. This is like taking a time stamp from the running timer at certain pin state change events (on the ICPn pin).

Input Capture Unit (ICU) Hardware

There are so many applications and use cases for timer modules in input capture mode as we’ll see later on. Here is the block diagram for the hardware timer input capture unit.

在这里插入图片描述
As you can see in the ICU hardware diagram, the timer counter register (TCNTx) is copied to the input capture register (ICRx) when an input capture edge is detected. It can either be coming from the ICPx external pin or from the internal analog comparator output (ACO).

The ICPx pin can trigger an input capture event on RISING or FALLING edges. When an input capture event is triggered, the current timer/counter register (TCNTx) value is copied to the input capture register (ICRx), and an interrupt is fired, if enabled. The Arduino input capture interrupt vector is TIMER1_CAPT_vect.

Input Capture Unit Frequency Measurement

As stated earlier, the ICU mode is typically used to get time stamps of a free running timer module at certain events on an external pin (ICPx). Which can be very useful for applications like frequency measurement. We can set up the ICU to trigger a capture event on every RISING edge on the ICPx pin to measure an external signal’s frequency.

Arduino-Input-Capture-Frequency-Counter
At the first edge, we’ll save the ICRx register reading into a variable (T1). At the second edge, we’ll save ICRx into (T2). And to get the signal’s period, we just subtract the time stamps as follows: ( T = T2 - T1). Just pay attention to timer overflow events because if T2 is smaller than T1, the resulting period (T) will be negative which is not correct. We need to add ( Number of TimerOVF * 65536) to T2 to get the correct absolute timestamp difference.

Duty Cycle (Pulse Width) Measurement With ICU

Measurement of an external signal’s duty cycle (pulse width) requires that the trigger edge is changed after each capture event. Changing the edge sensing must be done as early as possible after the ICRx register has been read. After a change of the edge, the input capture flag (ICFx) must be cleared by software (writing a logical one to the bit location).

在这里插入图片描述

You can refer to the Arduin UNO Pinout Guide to identify all timer input capture pins (ICPn).

❕ Note

In Arduino UNO (Atmega328p) microcontroller, Only Timer1 has an input capture unit (timer mode). Which has an input capture pin (ICP1) that corresponds to Arduino UNO IO pin8.

To learn more about Arduino Input Capture Unit and create a couple of practice projects, you need to check out the tutorial linked below. This is a very important topic in this Arduino Programming Tutorials Series and will be used in a lot of sensor interfacing tutorials & projects. So make sure to get the hang of it.

Also Read

Arduino Input Capture Unit Tutorial

This tutorial will give you more in-depth information about Arduino Timers (in input capture Mode). How to configure Arduino Timers to operate in ICU mode, and what are the use cases & applications for ICU? As well as a couple of practical Arduino code example projects.


Arduino Timers Libraries

There is a handful of community-contributed Arduino Timer libraries that eases the process of configuring the Arduino internal hardware timers and provide some useful APIs (functions) to do a lot of things. However, I’ll only discuss the most common two libraries that will satisfy most of your needs in most projects.

You need both of them actually, the decision of which to use in which project depends on your needs. The arduino-timer.h library excels in handling timing functions, concurrent tasks, and such. While the Arduino TimerOne.h library excels at giving you the flexibility to control the PWM outputs of Timer1 (only pins 9 & 10). You can use it to generate 20kHz PWM outputs at a very good resolution,

1- Arduino-Timer Library

The Arduino-Timer library is a community-contributed library that enables users to configure timer-based events (tasks) without the need to do register-level programming for the timer modules. It uses the built-in timer-based millis() and micros() functions, so it’s like a wrapper layer of useful APIs on top of the built-in timer-based functions.

You can follow the tutorial below for installation instructions and in-depth information & illustration for the library functions with a couple of project examples to test the library functionalities in practice.

Also Read

Arduino-Timer Library Tutorial

This tutorial will give you more in-depth information about arduino-timer.h library. How to install and use Arduino-Timer library. And will also create a couple of test projects to create & handle periodic tasks with arduino-timer library (in ms & μs resolutions).

2- Arduino TimerOne Library

The Arduino TimerOne library is a community-contributed library that enables users to configure and use the 16-Bit Timer1 for generating & handling periodic interrupts and also to generate PWM signals with controllable frequency and duty cycle.

You can follow the tutorial below for installation instructions and in-depth information & illustration for the library functions with a couple of project examples to test the library functionalities in practice.

Also Read

Arduino TimerOne Library Tutorial

This tutorial will give you more in-depth information about Arduino TimerOne.h Library. How to install and use Arduino TimerOne library. And will also create a couple of test projects to create & handle periodic timer interrupt events, and also generate 20kHz PWM output signals with Arduino.


Parts List

Here is the full components list for all parts that you’d need in order to perform the practical LABs mentioned here in this article and for the whole Arduino Programming series of tutorials found here on DeepBlueMbedded. Please, note that those are affiliate links and we’ll receive a small commission on your purchase at no additional cost to you, and it’d definitely support our work.

Arduino Course Kit List


Wrap Up

To conclude this tutorial, we’d like to highlight the fact that the Arduino Timers are very useful in so many applications (like timer interval interrupts generation, periodic tasks handling, measurement of signals, and more). Each timer mode has its unique set of features, working mechanics, and potential applications.

This tutorial is a fundamental part of our Arduino Series of Tutorials because we’ll build on top of it to interface various sensors and modules with Arduino in other tutorials & projects. So make sure you get the hang of it and refer to all the linked tutorials below to learn more about Arduino Timer Modes.

  • Arduino Timer Mode Tutorial
  • Arduino Counter Mode Tutorial
  • Arduino Output Compare (PWM) Tutorial
  • Arduino Input Capture Unit (ICU) Tutorial

If you’re just getting started with Arduino, you need to check out the Arduino Getting Started Ultimate Guide here.

Also Read

[Getting Started With Arduino Ultimate Guide]

This is the ultimate guide for getting started with Arduino for beginners. It’ll help you learn the Arduino fundamentals for Hardware & Software and understand the basics required to accelerate your learning journey with Arduino Programming.

Related

  • Arduino-Timer Library & Examples

  • Arduino Counter Timer Mode Tutorial & Code Examples

  • [Arduino TimerOne Library Code Examples Tutorial]

  • Arduino PCINT (Pin Change Interrupts)

  • Arduino Timer Interrupts Tutorial & Examples

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2070119.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

最近公共祖先(LCA),树上差分,树的直径总结

最近也是一不小心就学到了树论,这方面确实太不行了,也该开始学习一下了,那么话不多说,进入今日份的树论学习,直接开冲 最近公共祖先(LCA)——倍增思想(可以结合我之前写的ST表学习&…

Windows安装java8\java17并存切换版本操作

问题描述: 首先肯定一台电脑可以安装多个JDK,切换版本也是可实现的。 存在版本切换问题是企业项目用java8,个人研究技术用的17。希望两者并存,随时切换,记录一下操作步骤。 第一:先安装不同版本的jdk到系…

vue项目中,修改elementui一些复杂控件样式

1.前言 在vue项目中,我们为了快速开发,会用到elementui。但很多时候,elementui的样式不满足于我们项目的样式需求。这时候我们需要修改原生elementui的样式。 2.简单控件的样式修改 对于elementui中一些简单的控件,如按钮之类的…

Xshell链接本地20.04Ubuntu虚拟机

一、打开虚拟机设置选择自定义-net8 二、打开虚拟网络编辑器,点击更改设置 三、打开网络设置,如图操作 四。打开虚拟机,进入终端,输入ifconfig 五、su root进入root模式,配置静态网卡 # 备份配置文件 cd /etc/netpla…

Qt:玩转QPainter序列一

前言 最近想潜心研究一下QPainter这个类,最好把QPainter所有的函数都敲一遍,特地记录一下。 在说QPainter之前我们需要了解两个非常重要的东西 第一个坐标系 我用两张图来表示 代码实操的结果 更加详细的坐标系内容请看我的另一篇博客 第二个是有…

一款基于cesium的开源地图工具

Cesium是一个开源的、世界级的、展现3D全球地图的JavaScript类库,它毫无疑问已然成为WebGIS开发中三维地球框架的首选。本次给大家带来的是一个结合CesiumVue的前端地图开发框架,支持很多种地图渲染特效,同时还支持模型加载到地图上面。 开源地址&#…

Linux安装显卡驱动

本文详细阐述了在Linux系统中安装显卡驱动的步骤和注意事项。首先,文章介绍了显卡驱动的重要性,以及为什么需要安装或更新显卡驱动。接着,针对不同类型的显卡(如NVIDIA、AMD等),文章提供了具体的安装步骤和…

进程与程序的学习

1、进程与程序 程序:本地文件,编译后产生的文件.elf执行文件,存储在硬盘中的文件;进程:程序运行期间就是一个进程;(主要讨论两个进程的交互)程序是静态的,进程是动态的;程序执行后Linux内核自动完成虚拟内存(资源)分配,成进程; 将数据段、代码段这些运行时必要的…

ProxySQL 读写分离配置

ProxySQL 是一个高性能、高可用的 MySQL 代理软件,旨在提升 MySQL 数据库的可扩展性和性能。它可以在应用程序和 MySQL 服务器之间充当中间层,提供强大的路由、负载均衡和查询优化功能。 ProxySQL 的主要功能: 查询路由: ProxySQ…

王者站撸分析

王者站撸分析 问题背景 有这样两个角色 其中一个角色的被动是受到攻击会减少攻击者的攻速1%,该被动可以叠加40层 另一个角色的被动是攻击敌方会提升自己1%的免伤效果,该被动可以叠加20层。 在站撸情况下 哪方胜算更大? 为了解决这个问题,我…

基于Flask-REXTs创建一个项目接口并利用github上传部署

实习过程中需要自己单独编写一个项目使用到的api,并独立完成api的上传部署,这里记录一下全过程。 第一步 编写本地代码 IDE pycharm上创建一个项目名称,然后所有项目文件及结构如下: 其中app.py文件就是实现的接口,就…

ant design pro 如何实现动态菜单带上 icon 的

ant design pro 如何去保存颜色ant design pro v6 如何做好角色管理ant design 的 tree 如何作为角色中的权限选择之一ant design 的 tree 如何作为角色中的权限选择之二ant design pro access.ts 是如何控制多角色的权限的ant design pro 中用户的表单如何控制多个角色 如上图…

免费无损音乐、音效素材,马住着6个网站

如果你正在寻找免费的无损音乐和音效素材,这里有6个网站可以帮助你找到高质量的资源。无论是制作视频、播客还是其他创意项目,这些平台提供了丰富的选项,满足你的各种需求。 1、菜鸟图库 音效素材下载_mp3音效大全 - 菜鸟图库 菜鸟图库音…

Datawhale X 李宏毅苹果书 AI夏令营 学习笔记(三)

批量归一化(Batch Normalization,BN) 如果说自适应学习率是让训练适应loss,那归一化就是让loss适应训练。 我们抛掉使用自适应学习率的想法,重新看下面的图。可以看到w1固定时,w2的梯度是比较大的。w2固定时,w1的梯度…

GitHub开源的PDF管理工具Stirling-pdf

Stirling pdf 手动搭建docker搭建 官网:https://github.com/Stirling-Tools/Stirling-PDF 手动搭建 Ubuntu2404环境 安装所需软件包 apt install -y git automake autoconf libtool libleptonica-dev pkg-config zlib1g-dev make g openjdk-21-jdk python3…

【R语言】基于nls函数的非线性拟合

非线性拟合 1.写在前面2.实现代码 1.写在前面 以下代码记录了立地指数的计算过程,包括了优势树筛选、误差清理、非线性拟合以及结果成图。 优势树木确定以及数据清理过程: 相关导向函数: 2.实现代码 ##*******************************…

web测试之功能测试常用的方法有哪几种?有什么要点要注意?

1、前言 功能测试就是对产品的各功能进行验证,根据功能测试用例,逐项测试,检查产品是否达到用户要求的功能。 2、常用的测试方法如下: 1、页面链接检查: 每一个链接是否都有对应的页面,并且页面之间切换…

在Excel中“直接引用”字符串地址

indirect是Excel唯一可以拥有直接解析字符串引用地址参数能力的函数,是绝无仅有的宝贝疙瘩。 (笔记模板由python脚本于2024年08月21日 12:45:49创建,本篇笔记适合喜欢用Excel处理数据的coder翻阅) 【学习的细节是欢悦的历程】 Python 官网:ht…

Navicat中怎么查看数据库密码

一、版本问题 场景:在配置数据库连接后,忘记了数据库的密码,想要找回来。 其实有些版本(好像是低版本才有,具体哪个版本就没去研究了)在配置连接页面,是有个选项勾选是否显示密码的&#xff0…

Datawhale AI 夏令营(第五期) 李宏毅苹果书 Task 1 《深度学习详解(入门)》- 1.1 通过案例了解机器学习

预测本频道观看人数(上) - 机器学习基本概念简介_哔哩哔哩_bilibili 1 隐藏任务:找出本篇中形如回归(regression)加粗字体的术语,并用自己的话进行解释,列成表格 术语解释机器学习(…