pulse-width modulation (PWM) is literally what it sounds like, the width of the pulse and how it is modulated. PWM allows the user to generate a square signal with a user determined frequency/period and duty cycle.
the PWM frequency is calculated with equation:
Fpwm = Ftpmck/(TPMMOD + 1)
the duty cycle is the ratio between TPMMOD + 1 and the TPMCxV values:
duty cycle = ((TPMMOD + 1)/TPMCxV) * 100
so for our case:
with a PWM we are able to focus our IR receiver on a specific IR frequency so that a lot of other lights such as sunlight and flashlights will not affect the the sensor. also, when coded with a timer, the PWM can save power by turning on for a short period of time and then going back to sleep. the timer would then wake it up again a certain period of time later and the PWM would then do its job and go back to sleep.
to sum it up, the PWM:
the following is a list of the code we are using and why its set to those values (please purchase a copy of 'HCS08 Unleashed' for full details):
TPMSC takes a hex value. this code is used to set the TPM clock equal to the BUSCLK. the hex code states that bit 3 is high and for the coding of the TPMSC, only bit 3 high sets the TPM clock equal to the BUSCLK.
TPMMOD takes a positive integer. this code is used to set the PWM frequency equal to 40kHz. Based on the equation above, the TPMSC/TPMMOD equals PWM frequency.
TPMCxSC takes a hex value. this code is used to set channel x to high-true PWM mode. the hex code states that bits 3 and 5 are high and for the coding of the TPMCxSC, only bits 3 and 5 high sets the channel to high-true PWM mode.
TPMCxV takes a positive integer. this code is used to determine the duty cycle. based on the equation above, (TPMMOD/TPMCxV) * 100 equals the duty cycle.
| LED | Radioshack IR det | TSOP32228 IR det | |
|---|---|---|---|
| res in series | 100 ohm | - | - |
| volt of res | .74V | - | - |
| Amperage | 7.4mA | .6mA | 5mA |
| Voltage | 3.3V | 3.3V | 5V |
| Power Usage | 24mW | 2mW | 25mW |
therefore:
The following battery comparison chart is from zbattery.com