I wrote a blog post about PWM a year ago, the link is as follows:
http://hi.baidu.com/do_sermon/item/ff523b0a8b9d3d173b53ee74
An oscilloscope is used in this paper to display waveforms with different duty cycles.
In fact, LED can also be used to show the changes in PWM parameters through brightness. The actual test shows a very good effect. However, when using PROTEUS for simulation experiments, we can only see severe flickering and basically no change in brightness.
Recently, it has been discovered that adding a large capacitor can reduce the flicker of the LED and make the brightness more stable. In this way, the brightness changes can be directly observed using PROTEUS software.
The circuit is shown in the figure below. The capacity of the large capacitor (C6) in the figure is 4700uF, which can be adjusted at will, and the actual circuit does not need it.
The duty cycle parameter in the figure is 10, and the LED (D1) is displayed in the "half-bright" state.
The C program was published last year, and can be found in the link above. It has been slightly modified as follows:
#include
unsigned char a, b;
sbit K1 = P3^2; //Define two keys to adjust the duty cycle
sbit K2 = P3^3;
//------------------------------------------------
void delay(unsigned int i)
{
unsigned char j;
while(i--) for(j = 0; j < 60; j++);
}
//------------------------------------------------
void main()
{
TMOD = 0x01; //T0 timing mode 1
TH0 = (65536 - 500) / 256; //500us@12MHz
TL0 = (65536 - 500) % 256;
TR0 = 1;
ET0 = 1;
EA = 1;
a = 0;
b = 10;
while(1) {
if(!K1) {delay(20); if(!K1) {b++; if(b > 19) b = 19; while(!K1);}}
if(!K2) {delay(20); if(!K2) {b--; if(b < 1) b = 1; while(!K2);}}
//The above two lines are to check the key, delay debounce, modify the duty cycle, and wait for the key to be released, b = 1~19
P0 = ((b / 10) << 4) + b % 10; //Display duty cycle level
}
}
//------------------------------------------------
void time0() interrupt 1
{
TL0 = (65536 - 493) % 256; //Compensation interrupt entry time
TH0 = (65536 - 493) / 256; //500us@12MHz
a--; //a = 1~20
if(a == 0) {a = 20; P2 = 0;} //Period = 20*500us
if(a <= b) P2 = 255; //output to oscilloscope
P1 = ~P2; //Output to LED, low level light
}
//------------------------------------------------
In this program, the PWM cycle is shorter than last year's. Last year, it was designed to be 1s in response to the requests of netizens, which was a bit long and not very practical.
This time, we don't need external interrupts to input keystrokes, but use the key query method instead.
When the duty cycle is adjusted using the buttons, the LED can display different brightness. Several screenshots are as follows:
When the PWM parameters are slightly smaller, the brightness is somewhat insufficient, which can be compensated by appropriately reducing the resistance of some current limiting resistors.
The LED used to display PWM has intermittent current, so its current limiting resistor can be smaller than usual, around 100 ohms, which is an empirical data.
When making a physical circuit, you don't need a large capacitor, so you don't have to spend money to buy it, haha
Previous article:PWM - breathing light
Next article:595 output drives the digital tube to flash
Recommended ReadingLatest update time:2024-11-16 14:41
- Popular Resources
- Popular amplifiers
- Siemens PLC Project Tutorial
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Intelligent Control Technology of Permanent Magnet Synchronous Motor (Written by Wang Jun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- EEWORLD University ---- Industrial Motor Driver - Introduction to Texas Instruments System Solutions
- Updated PYBCN_V2 and PYBNANO_V2 firmware
- IIR filter software implementation (Matlab+C++)
- Design of ultrasonic distance measuring sensor system
- Crowdfunding of micro:bit robot PLEN:bit
- AD19 only shows wireframe after copper is laid, which does not look like laid copper
- Application of MSP430F5xxx in the highway toll collection system (ETC)
- Is it useful for people who work with microcontrollers to read "Introduction to Algorithms" and "Data Structures"?
- Design of electronic piano based on LPC2000 series ARM chip
- How do analog switches ensure bandwidth without distortion?