2. PWM output of HCS12.
Solution:
1. The PWM module in HCS12 performs PWM output through hardware.
2. The comparison output module of ECT in HCS12 performs PWM output through comparison output.
Since the PWM module is a dedicated module for output PWM, PWM output can be achieved by setting the corresponding registers, which is simple, convenient and accurate. Therefore, the PWM module is selected for PWM output.
Description:
1. The steering angle of the servo is controlled by PWM. The servo interface generally has 3 wires, black ground wire and red power wire, generally using 4.8V and 6V standards. The other wire is the control signal line.
2. 16-bit PWM output is achieved through cascading.
3. The cycle is 18MS~20MS, that is, the output cycle is 56Hz~50Hz.
4. The alignment method is PWM left alignment.
5. The output polarity is the starting high level.
6. The pulse width varies from 1100us to 1900us, achieving a steering angle of -45° to 45°.
7. Achieve 16-bit PWM output through cascading. Channel PWM45 forms channel A.
8. Clock source selection.
9. PWM clock.
10. Duty cycle setting:
According to the formula:
[(PWMDTYx+1)/(PWMPERx+1)]*100%=pulse width/output period*100%
width=rotation angle*(400)/45+1500
PWMDTYx[28]={859,855,850,846,841,837,832,828,824,819,815,810,806,801,797,792,788,784,779,775,
770,766,761,757,752,748,744,740,735,731,726,722,717,713,708,704,700,695,691,686,
682,677,673,668,664,660,655,651,646,642,637}
The program to calculate the PWMDTYx value is as follows:
#include
void main()
{
long int i,X,y; } } CODE
: #include < hidef.h > #include <
MC9S12XS128.h > #pragma LINK_INFO DERIVATIVE " mc9s12xs128 " // =========================================================== // //16-bit PWM output controls the rotation of the servo motor //author: yangtze //time:2009/4/21/ //==============================================================// #define PWMPERx 0x270F; unsigned int PWMDTYxtable[]={
0x035b,0x0357,0x0352,0x034e,0x0349,0x0345,
0x0340,0x033c,0x0338,0x0333,0x032f,0x032a,
0x0326,0x0321,0x031d,0x0318,0x0314,0 x0310,
0x030b,0x0307,0x0302,0x02fe,0x02f9,0x02f5,
0x02f0, 0x02ec,0x02e8,0x02e4,0x02df,0x02db,
0x02d6,0x02d2,0x02cd,0x02c9,0x02c4,0x02c0,
0x02bc,0x02b7,0x02b3,0x02ae,0x02aa,0x02a5,
0x02a1,0x029c,0x0298,0x0294,0x028f,0x 028b,
0x0286,0x0282,0x027d};
void pllclk(void)// 24MHz
{
}
void PWMServoMotor_init(void) //PWM initialization settings
{
}
void PWM_Pulse(unsigned int PWMPERx,unsigned int PWMDTYx) //PWM output period and duty cycle setting
{
}
void main(void)
{
}
Previous article:C51 Programming Style
Next article:Freescale's Discrete Photoelectric Tube Path Identification
Recommended ReadingLatest update time:2024-11-16 14:59
- Popular Resources
- Popular amplifiers
- Practical Development of Automotive FlexRay Bus System (Written by Wu Baoxin, Guo Yonghong, Cao Yi, Zhao Dongyang, etc.)
- Automotive Electronics KEA Series Microcontrollers——Based on ARM Cortex-M0+ Core
- Automotive integrated circuits and their applications
- ADS2008 RF Circuit Design and Simulation Examples (Edited by Xu Xingfu)
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
- TE's latest trend report | "How does temperature monitoring affect the generator market"
- 【NXP Rapid IoT Review】+7. Understand what each icon means
- EEWORLD University Hall ---- Deep Learning Theory (National Taiwan University Li Hongyi, Chinese)
- MicroPython makes some objects const
- Monthly fixed dry goods, ADI March Chinese information
- GPIO Operation of TMS320C6748
- [nRF52840 DK Review] Playing with micropython
- Support the e-sports competition and get gifts for grabbing the building~~
- 【MicroPython】ESP32 starts to support hardware I2C method
- How to choose the power chip for DSP?