Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. In the last project the PWM modale was set up to drive the LED. Answer the fo

ID: 2266733 • Letter: 2

Question

2. In the last project the PWM modale was set up to drive the LED. Answer the following questions for setting up a PWM module. Show your work. (20 points) For this question the Bus Clock Frequency is 80 MHz PWM Clock Frequency is 20 MHz PWM Frequency is I kHz a What is the PWNf resolution? That is how many steps are there from o io l00% b. What is the proper scaling equation to use a 12 bit value to control the PWM module from 0 to 100% ? c. What type of math should the scaling equation use? d. What should the PWM frequency be for exactly 12 bit resolution? What 3. Name the signal wires for UART communications. (5 points)

Explanation / Answer

2. (a) PWM is using digital pulses to create some analog value other than just ‘high’ and ‘low’ signal levels. Most of the digital systems are powered by 5V power supply. So for example, if you filter a signal that has 50% duty cycle, you will get an average voltage of 2.5V. Other duty cycles produce any voltage in the range of 0-100% of the ‘high’ voltage is depending upon the PWM resolution. The duty cycle is defined as the percentage of digital ‘high’ to digital ‘low’ signals present during a PWM period. The PWM resolution is defined as the maximum number of pulses that you can pack into a PWM period. The PWM period is an arbitrarily time period in which PWM takes place. It is chosen to give the best results for your particular use.

While PWM can be used to generate digital waveforms, such as used for stepping a stepper motor or controlling other digital circuits, PWM output can also generate analog voltages, albeit at low power. For instance, if you connect a low-current LED (plus resistor of course) to a PWM output, you will find that the intensity increases as the duty cycle goes from 0% to 100%, assuming that you have a relatively fast period, say, 10 msec. As another example, you could use PWM output to control a DC motor. You first hook up the high-frequency PWM output to an H-bridge or some other type of motor driver that can take small input currents and can generate large output currents (there is not enough current from the HCS12 PWM pins to drive a motor). As you increase the duty cycle form the PWM, the motor speeds up in direct proportion to the duty cycle. You can even use PWM to generate audio signals if you use some low-pass filtering to get rid of the high-frequency harmonics present in the PWM waveforms.

2. (b) The sample source code below shows how to set the speed of a DC motor using PWM with PIC16F877A. First, we need to initialize the CCP1 module to operate in PWM mode. Next we need to use a formula to calculate PR2: PR2 = PWM period / (4xToscxTMR2 prescale). PWM period = 1/frequency. We set frequency = 4.88 kHz. So, the PR2 = 256.147, but the maximum could be reach is 255, so at the end, it will automatically go to 255 in decimal and FFh in hexadecimal. So the maximum speed that the motor can reach is 255 in CCPR1L. For example if CCPR1L = 0, that means the speed is 0% of the full speed, if CCPR1L = 255, that means the speed is 100% of the full speed.

2. (c)

Two of the functions listed above, freq and duty, are particularly useful for troubleshooting. They can be applied to the signals from frequency-output and PWM-output sensors in control systems to let you see what the control unit sees.

In this example, the top trace (channel A) is a variable-frequency square wave that you might see from a digital position sensor. The lower trace is a math channel with the equation freq(A)/1000. We have set the scaling and units to display the output directly in millimeters. You can see that the sensor is describing an alternating constant-speed displacement.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote