Pulse Width Modulation (PWM) and MAXQ2000 Timer-Pulse

Abstract: This applicaTIon note shows how to use TImer Type 2 on a MAXQ2000 microcontroller to generate Pulse Width ModulaTIon (PWM) waveforms. It also discusses issues that should be considered when using TImer Type 2 for PWM generation.

IntroductionPulse Width Modulation (PWM) is a technique in which the duty cycle of the signal conveys meaning. Specifically, the amount of time the clock signal is logic-high vs. logic-low tells the signal's receiver to do something. PWM is often used to control fan speed and DC and servo motors. With fan-speed control, the longer the high time of the pulse, the faster the fan will run. Using PWM with some external circuitry, it is even possible to implement a simple digital-to -analog converter (DAC) by charging an RC circuit of known time constant for a specific length of time. Adding a comparator circuit could create a simple analog-to-digital converter (ADC). You could even recharge a battery, which would require different external circuitry and more advanced changes. This application note explains how to use the Timer Type 2 on the MAXQ200 microcontroller to generate and control PWM. MAXQ2000 and Timer Type 2 The MAXQ2000 is a low-power, high-performance RISC LCD microcontroller with a large variety of peripherals and features, including three 16-bit timers. These Type 2 timers provide many functions: 8 / 16-bit timer / counter, autoreload, counting external pulses, capture, and compare. The Type 2 timer also provides the MAXQ2000 with PWM capability. Please see the MAXQ Users Guide (PDF) and MAXQ2000 Users Guide Supplement (PDF) for more information about the MAXQ2000 and Timer Type 2. PWM Signal GenerationThe MAXQ2000's Timer Type 2 utilizes autoreload with compare to generate the PWM signal. Every time the timer overflows or has a compare value match, it toggles the logic state of the output pins T2P and T2PB. Figure 1 shows a basic PWM waveform in which the base period (1 / fB) corresponds to the timer's overflow. The timer and reload register should be set to a value that will overflow and reload every 1 / fB seconds. Use Equation 1 to determine this value:



Where T2R16 is the initial value of Timer Type 2 as well as the reload value. System Clk may be either the actual system clock, ie, 16MHz, or optionally the 32kHz clock. If the base frequency, fB, is significantly smaller than the system frequency, T2DIV can be used to divide the input clock down to a more reasonable level.

The high time of the PWM waveform, tH, corresponds to a match of the timer compare register. The compare register should be set to a value that will match tH after every reload. Use Equation 2 for this. It is important to remember that tH must be less than the base period. Note, also, that compare output toggle occurs on the next timer tick after a match, which explains the -1 in the following equation. If the high time and the base period were the same, the output waveform would only toggle one time on overflow, resulting in a half-speed wave that will cause problems.



In some applications tH may be described by a percentage or duty cycle (DC). In this case, use the following Equation 3, where a DC of 50% (half high, half low) is represented as 0.50.



Figure 1. PWM waveform.
Figure 1. PWM waveform. ConsiderationsSome PWM applications require changing either the base frequency of the waveform or modifing the high time. It is important to stop the timer using TR2 before making these changes. Otherwise, the PWM waveform can invert because the timer toggles the output an additional time. Stopping and restarting the timer guarantees a consistent waveform.

Some hardware is sensitive to the PWM glitch resulting from stopping and restarting the PWM waveform as described above. If glitch-free PWM is required, more care must be taken when updating timer registers. One scheme uses the overflow and compare flags as signals to update . When the compare flag / interrupt flag is set, update the reload register. When the overflow flag is set, update the compare register. This scheme allows changes to occur in a predictable manner. Note that problems can occur with this scheme near boundaries. Specifically, if timer input is an undivided system clock, attempting to update the compare register to one count more than the reload can cause unexpected behavior.

Because of the output's toggling behavior, it is important to consider the initial state of the pin. The initial state of the output is controlled by T2POL; if set to 0, it inverts the output signal. This behavior can be seen in the dual 8 -bit timer example in the Appendix below.

The MAXQ2000 and Timer Type 2 support many options required for specialized applications. It is possible to gate the PWM signal on the secondary output pin by using the primary output pin as a gating input. This effectively stops the timer tick and will stop the PWM signal . Other specialized modes include single-shot and gated single-shot.

Timer Type 2 also supports PWM signal generation in three 8-bit modes. These modes allow the timer to be used for multiple tasks when the greater precision of the 16-bit timer is not required. The dual 8-bit mode allows two unique PWM signals to be generated by the timer, while the other 8-bit modes only support PWM output on the secondary pin, T2PB. To configure the timers in the 8-bit modes, use Equations 1 and 2 for reload and compare values, except substitute 256 for 65536.

The system clock frequency affects the accuracy of the output waveform. A 16MHz clock, for example, divides by 8 much more evenly than a 14.7456MHhz clock. Many fast timer ticks allow better accuracy than two large slow ones. The 16-bit timer is More accurate than the 8-bit timer for this reason. Example CodeAppendix A contains code samples for setting up PWM on Timer 0 of a MAXQ2000 in both 16-bit and dual 8-bit modes.

Appendix A. Code Samples; 16 bit PWM example code; MAXQ2000 has 3 Type 2 Timer / Counters with 2 output pins each; System Clock is 16Mhz; We will use timer 0 $ include (maxQ2000.inc); Some basic initialization. Set Accumulator Controls to normal. Move APC, # 0; no accumulator-modulo behavior move AP, # 0; select accumulator 0 move T2CFG0, # 00000000b; Configure the Timer; T2CI = 0-Use System clock; TDIV = 000-Use divide by 1 ; T2MD = 0-16 bit; CCF = 00-Compare / Reload mode; C / T2 = 0-Timer mode move T2CNA0, # 01100000b; Set up Timer Control; ET2 = 0-No interrupts; T2OE0 = 1-Utilize Primary output pin; T2POL0 = 1-Initial output high; TR2L = 0-Don't care in 16 bit mode; TR2 = 0-Don't run yet; CPRL2 = 0-Don't care in compare mode; SS2 = 0-No Single Shot; G2EN = 0-No Clock Gating move T2V0, # 63936; Set initial timer count to generate; 10Khz base frequency PWM wave move T2R0, # 63936; Set Reload to same value; move T2C0, # 64735; 50% Duty; move T2C0 , # 64095; 10% Duty move T2C0, # 65135; 75% Duty move acc, T2CNA0 or # 00001000b; Start the Timer move T2CNA0, acc jump $ end; Dual 8-bit PWM example code; Timers will output inverse wave forms; MAXQ2000 has 3 Type 2 Timer / Counters with 2 output pins each; System Clock is 16Mhz; We will use timer 0 $ include (maxQ2000.inc);; Some basic initialization. Set Accumulator Controls to normal. Move APC, # 0; no accumulator-modulo behavior move AP, # 0; select accumulator 0 move T2CFG0, # 00111000b; Configure the Timer; T2CI = 0-Use System clock; TDIV = 011-Use divide by 8; T2MD = 1-8 bit; CCF = 00 -Compare / Reload mode; C / T2 = 0-Timer mode move T2CNA0, # 01000000b; Set up Timer Control; ET2 = 0-No interrupts; T2OE0 = 1-Utilize Primary output pin; T2POL0 = 0-Initial output low; TR2L = 0-Don't run lower yet; TR2 = 0-Don't run upper yet; CPRL2 = 0-Don't care in compare mode; SS2 = 0-No Single Shot; G2EN = 0-No Clock Gating move T2CNB0 , # 01100000b; Set u p Timer Control B; ETl2 = 0-No interrupts; T2OE1 = 1-Utilize Primary output pin; T2POL1 = 1-Initial output high; reserved; 3: 0-interrupt flags move T2V0, # 56; Set initial timers count to generate move T2H0, # 56; 10Khz base frequency PWM wave move T2R0, # 56; Set Reload to same value move T2RH0, # 56 move T2C0, # 95; Set high time for 20us move T2CH0, # 95 move acc, T2CNA0 or # 00011000b; Start the Timer move T2CNA0, acc jump $ end

Ac Controller

What is a wireless AC controller? What does it do?

Wireless AC controller is a kind of network device, such as the AC100/150 of Fengrunda, which can be used to centrally control and manage wireless aps. It is the core of a wireless network and is responsible for managing all wireless aps in the wireless network. AP management includes: delivering configuration, modifying related configuration parameters, RF intelligent management, and access security control.

Why use a wireless controller, and what exactly does it do?

In fact, the role of the wireless controller is to play a gateway function between the WLAN and the Internet (on the router), and the data from different access points are aggregated and accessed to the Internet. The role of an access point (AP) is to complete wireless access, and it can control user access through network flags.

The role of wireless controllers

1, Flexible networking mode and excellent scalability

The AP does not need to be directly connected to the AC, so that the AP can be deployed in any place that needs to be covered through the network, such as you deploy an AP in each employee's home, and then connect to the wireless controller inside the enterprise through the VPN, you can expand the wireless network of the enterprise to the family of each enterprise member.

2, intelligent RF management functions, automatic deployment and fault recovery

Through the dedicated RF management module, we can initially estimate the AP deployment according to the user's architectural design drawing, and can calculate the average bandwidth of the wireless terminal, the coverage between AP and AP in the actual debugging process.

3. Centralized network management

All the configuration of the wireless network can be completed by configuring the wireless controller. For example, enable, manage, and maintain all AP devices and mobile terminals, including all functions such as radio wave spectrum, wireless security, access authentication, mobile roaming, and access users.

4, powerful roaming function support

The wireless controller uses AP as the boundary combined with fast RF management system, which greatly reduces the connection time between wireless client and AP, and thus realizes the function of fast roaming.

5. Load balancing

AP and wireless controller systems can distribute wireless users or terminals to nearby aps within the coverage area of an AP, ensuring the number of each wireless terminal or the sum of AP bandwidth transmission or the upper limit of each wireless terminal bandwidth.

6, wireless terminal positioning, rapid fault location and intrusion detection

Wireless controllers can track and locate the location of wireless terminals, such as wirelessly connected computers, PDAs and Wi-Fi mobile phones.

7, powerful access and security policy control

At present, the wireless system supports authentication of 802.1, WEB authentication, MAC, SSID, VPN, etc., and supports various encryption modes such as WEP, WPA, WPA-PSK, WPA2, etc., and all configurations can be configured globally through the wireless controller.

8, Qos support

AP and wireless switching systems can limit the maximum bandwidth of a user's wireless connection within each user's privileges. For different IP services, the system can also define different QoS queues through the wireless switch module. For example, for wireless voice applications, SIP and RTP protocols can be set in the high queue, while common applications such as http and ftp can be set in the low queue.

The wireless controller AC is more advanced than the AP, plays the role of manager in the wireless network, and the wireless controller AC also acts as a client to complete a series of functions in the wired network (such as authentication, authentication, etc.). However, wireless controller AC is not a WLAN device specified in the 802.11 protocol family, but as a supplement to the protocol in specific applications, and its price far exceeds that of ordinary access point (AP) devices.

In small-scale wireless networks that use only a few aps, it is not economical to use expensive wireless controller AC equipment. However, if the number of wireless aps is large, more than 20 can be used AC controller.

Ac Controller,Gigabit Wlan Controller,Enterprise Ac Gateway,Wireless Ap Controller

Shenzhen MovingComm Technology Co., Ltd. , https://www.szmovingcomm.com