The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

Tips Tricks Tips Tricks Introduction. Capture Tips Tricks #1


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



PICmicro® ECCP Tips Tricks
Tips Tricks
Tips Tricks Introduction. Capture Tips Tricks
#10: #11: #12: #13: #14: #15: #16: #17: #18: #19: Measuring Period Square Wave Measuring Period Square Wave with Averaging Measuring Pulse Width Measuring Duty Cycle Measuring using Encoder. Measuring Period Analog Signal Periodic Interrupts Modulation Formats. Generating Time Tick RTOS. 16-Bit Resolution Sequential Reader Repetitive Phase Shifted Sampling Deciding Frequency. Unidirectional Brushed Motor Control Using CCP. Bidirectional Brushed Motor Control Using ECCP Generating Analog Output. Boost Power Supply Varying Intensity. Generating X-10® Carrier Frequency
Compare Tips Tricks
Tips Tricks
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Combination Capture Compare Tips
#20: #21: RS-232 Autobaud Dual-Slope Analog-to-Digital Converter
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks TIPS TRICKS INTRODUCTION
Microchip continues provide innovative products that smaller, faster, easier-to-use more reliable. PICmicro® microcontrollers (MCUs) used wide range everyday products, from washing machines, garage door openers, television remotes industrial, automotive, medical products. Capture, Compare, (CCP) modules that found many Microchip's microcontrollers used primarily measurement control time-based pulse signals. Enhanced (ECCP), available some Microchip's devices, differs from regular module that provides enhanced functionality namely, full-bridge halfbridge support, programmable dead-band delay, enhanced auto-shutdown. ECCP modules capable performing wide variety tasks. This document will describe some basic guidelines follow when using these modules each mode, well give suggestions practical applications.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
ECCP/CCP Register Listing
Capture Mode CCPxCON Select mode Compare Mode Select mode Mode Select mode, duty cycle duty cycle
CCPRxL
Timer1 capture (LSB) Timer1 capture (MSB) CCPx input Timer1 prescaler Timer1 interrupt enable Timer1 interrupt flag global/ peripheral interrupt enable
Timer1 compare (LSB) Timer1 compare (MSB) CCPx output Timer1 prescaler Timer1 interrupt enable Timer1 interrupt flag global/ peripheral interrupt enable
CCPRxH
TRISx T1CON T2CON PIE1
CCPx pin(s) output(s) Timer2 prescaler Timer2 period Timer2 interrupt enable Timer2 interrupt flag global/ peripheral interrupt enable dead band, auto-restart control auto-shutdown control
PIR1 INTCON
PWM1CON(1)
ECCPAS(1) Note
Only ECCP module.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks CAPTURE TIPS TRICKS
Capture mode, 16-bit value Timer1 captured CCPRxH:CCPRxL when event occurs CCPx. event defined following configured CCPxCON<3:0>: Every falling edge Every rising edge Every rising edge Every 16th rising edge "When Would Capture Mode?" Capture mode used measure length time elapsed between events. event, general, either rising falling edge signal (see Figure "Defining Events"). example application where Capture mode useful reading accelerometer. Accelerometers typically vary duty cycle square wave proportion acceleration acting system. configuring module Capture mode, PIC® microcontroller measure duty cycle accelerometer with little intervention part microcontroller firmware. goes into more detail about measuring duty cycle configuring module Capture mode.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
FIGURE DEFINING EVENTS
Volts
Event: Falling Edge
Event: Rising Edge
Time
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
FIGURE 1-1:
Measuring Period Square Wave
PERIOD
Configure control bits CCPxM3:CCPxM0 (CCPxCON<3:0>) capture every rising edge waveform. Configure Timer1 prescaler Timer1 with TMAX(1) without overflowing. Enable interrupt (CCPxIE bit). When interrupt occurs: Subtract saved captured time (t1) from captured time (t2) store (use Timer1 interrupt flag overflow indicator). Save captured time (t2). Clear Timer1 flag set. result obtained period (T). Note TMAX maximum pulse period that will occur.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
FIGURE 2-1:
Measuring Period Square Wave with Averaging
PERIOD MEASUREMENT
Configure control bits CCPxM3:CCPxM0 (CCPxCON<3:0>) capture every 16th rising edge waveform. Configure Timer1 prescaler Timer1 will TMAX(1) without overflowing. Enable interrupt (CCPxIE bit). When interrupt occurs: Subtract saved captured time (t1) from captured time (t2) store (use Timer1 interrupt flag overflow indicator). Save captured time (t2). Clear Timer1 flag set. Shift value obtained Step right four times divide this result period (T). Note TMAX maximum pulse period that will occur.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
following advantages this method opposed measuring periods individually. Fewer interrupts disrupt program flow Averaging provides excellent noise immunity
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
FIGURE 3-1:
Measuring Pulse Width
PULSE WIDTH
Configure control bits CCPxM3:CCPxM0 (CCPxCON<3:0>) capture every rising edge waveform. Configure Timer1 prescaler that Timer1 will WMAX without overflowing. Enable interrupt (CCPxIE bit). When interrupt occurs, save captured timer value (t1) reconfigure control bits capture every falling edge. When interrupt occurs again, subtract saved value (t1) from current captured value (t2) this result pulse width (W). Reconfigure control bits capture next rising edge start process over again (repeat steps through
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
FIGURE 4-1:
Measuring Duty Cycle
DUTY CYCLE
duty cycle waveform ratio between width pulse period (T). Acceleration sensors, example, vary duty cycle their outputs based acceleration acting system. module, configured Capture mode, used measure duty cycle these types sensors. Here's how: Configure control bits CCPxM3:CCPxM0 (CCPxCON<3:0>) capture every rising edge waveform. Configure Timer1 prescaler that Timer1 will TMAX(1) without overflowing. Enable interrupt (CCPxIE bit). When interrupt occurs, save captured timer value (t1) reconfigure control bits capture every falling edge. Note TMAX maximum pulse period that will occur.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
When interrupt occurs again, subtract saved value (t1) from current captured value (t2) this result pulse width (W). Reconfigure control bits capture next rising edge. When interrupts occurs, subtract saved value (t1) from current captured value (t3) this period waveform. Divide this result Duty Cycle. Repeat steps through
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks Measuring using Encoder
Revolutions Minute (RPM), fast something turns, sensed variety ways. most common sensors used determine optical encoders hall effect sensors. Optical encoders detect presence light shining through slotted wheel mounted turning shaft (see Figure 5-1.) shaft turns, slots wheel pass optical encoder. Typically, infrared source other side wheel emits light that seen optical encoder through slots wheel. Hall effect sensors work sensing position magnets electric motor, sensing permanent magnet mounted rotating object (see Figure 5-2). These sensors output more pulses revolution (depending sensor).
FIGURE 5-1: OPTICAL ENCODER
slotted wheel
sensor
Front View
Side View
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
FIGURE 5-2: magnet HALL EFFECT SENSOR wheel magnet hall effect sensor
Front View
Side View
Figure Figure 5-4, waveform high when light passing through slot encoder wheel shining optical sensor. case hall effect sensor, high corresponds time that magnet front sensor. These figures show difference waveforms varying RPMs. Notice that increases, period pulse width becomes smaller. Both period pulse width proportional RPM. However, since period greater intervals, good practice measure period that reading from sensor will have best resolution. measuring period. technique measuring period with averaging described useful measuring high RPMs.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
FIGURE 5-3:
FIGURE 5-4:
HIGH
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Measuring Period Analog Signal
Microcontrollers with on-board Analog Comparator module(s), addition ECCP) module, easily configured measure period analog signal. Figure shows example circuit using peripherals PIC16F684.
FIGURE 6-1: CIRCUIT VSENSE VREF VTHR Comparator (on-board PIC16F684) VOUT CCP1 PIC16F684
Analog Input
threshold voltage comparator. When analog input reaches threshold voltage, VOUT will toggle from high. provide hysteresis insure that small changes analog input won't cause jitter circuit. Figure demonstrates effect hysteresis input. Look specifically what VSENSE does when analog input reaches threshold voltage.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
FIGURE 6-2: SIGNAL COMPARISON
Analog Input VTHR
time VSENSE VTHR
time VOUT
time
module, configured Capture mode, time length between rising edges comparator output (VOUT.) This period analog input, provided analog signal reaches VTHR during every period.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks COMPARE TIPS TRICKS
Compare mode, 16-bit CCPRx register value constantly compared against TMR1 register pair values. When match occurs, CCPx Driven high Driven Remains unchanged, Toggles based module's configuration
action determined control bits CCPxM3:CCPxM0 (CCPxCON<3:0>). interrupt generated when match occurs. Special Event Trigger Timer1 normally cleared during interrupt when module configured Compare mode. only exception this when module configured Special Event Trigger mode. this mode, when Timer1 CCPRx equal, CCPx interrupt generated, Timer1 cleared, conversion started module enabled.)
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
"Why Would Compare Mode?" Compare mode works much like timer function stopwatch. case stopwatch, predetermined time loaded into watch counts down from that time until zero reached. Compare works same with exception counts from zero predetermined time. This mode useful generating specific actions precise intervals. timer could used perform same functionality, however, would mean preloading timer each time. Compare mode also added benefit automatically altering state CCPx based module
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Periodic Interrupts
Generating interrupts periodic intervals useful technique implemented many applications. This technique allows main loop code continuously, then, periodic intervals, jump interrupt service routine execute specific tasks (i.e., read ADC). Normally, timer overflow interrupt adequate generating periodic interrupt. However, sometimes necessary interrupt intervals that achieved with timer overflow interrupt. configured Compare mode makes this possible shortening full 16-bit time period. Example Problem: PIC16F684 running internal oscillator needs configured that updates exactly times every second. Step Determine Timer1 prescaler that allows overflow greater than seconds Timer1 overflows Tosc*4*65536* prescaler prescaler 1:1, Timer1 overflows 32.8 prescaler will cause overflow time greater than seconds. 32.8 0.25s
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Step Calculate CCPR1 (CCPR1L CCPR1H) shorten time-out exactly seconds CCPR1 Interval Time/(Tosc*4*prescaler) 0.2/(125 ns*4*8) 5000 0xC350 Therefore, CCPR1L 0x50, CCPR1H 0xC3
Step Configuring CCP1CON module should configured Trigger Special Event mode. This mode generates interrupt when Timer1 equals value specified CCPR1L Timer1 automatically cleared(1). this mode, CCP1CON `b00001011'.
Note Trigger Special Event mode also starts conversion module enabled. this functionality desired, module should configured "generate software interrupt-on-match only" mode (i.e., CCP1CON b'00001010'.) Timer must also cleared manually during interrupt.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Modulation Formats
module, configured Compare mode, used generate variety modulation formats. following figures show four commonly used modulation formats:
FIGURE 8-1: PULSE WIDTH MODULATION
Logic
Logic
FIGURE 8-2: MANCHESTER
Logic
Logic
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
FIGURE 8-3: PULSE POSITION MODULATION
Logic
Logic
FIGURE 8-4: VARIABLE PULSE WIDTH MODULATION
Logic
Logic
Transition High Transition High
figures show what logic logic looks like each modulation format. transmission typically resembles asynchronous serial transmission consisting Start bit, followed data bits, Stop bit.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
basic timing element each modulation format will vary based desired baud rate. Trigger Special Event mode used generate (the basic timing element). When CCPx interrupt generated, code routine would implement desired modulation format (additional modulation formats also possible).
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks Generating Time Tick RTOS
Real Time Operating Systems (RTOS) require periodic interrupt operate. This periodic interrupt, "tick rate", basis scheduling system that RTOS's employ. instance, tick used, RTOS will schedule tasks executed multiples RTOS also assigns priority each task, ensuring that most critical tasks executed first. Table shows example list tasks, priority each task, time interval that tasks need executed.
TABLE 9-1: TASKS
Task
Read input Read input Update Update array Read Switch Dump Data Serial Port
Interval
Priority
techniques described used generate periodic interrupt using module configured Compare mode. more information RTOSs their use, Application Note AN777 "Multitasking PIC16F877 with SalvoRTOS".
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks 16-Bit Resolution
FIGURE 10-1: 16-BIT RESOLUTION CCPx Interrupt: Clear CCPx Timer1 Interrupt: CCPx
Configure CCPx clear output (CCPx pin) match Compare mode (CCPxCON <CCPSM3:CCPxM0>). Enable Timer1 interrupt. period waveform Timer1 prescaler (T1CON <5:4>). duty cycle waveform using CCPRxL CCPRxH. CCPx when servicing Timer1 overflow interrupt(1). Note hundred percent duty cycle achievable with this implementation interrupt latency servicing Timer1. period affected because interrupt latency will same from period period long Timer1 interrupt serviced first ISR.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Timer1 four configurable prescaler values. These 1:1, 1:2, 1:4, 1:8. frequency possibilities described above determined Equation 10-1.
EQUATION 10-1:
FPWM FOSC/(65536*4*prescaler) microcontroller running oscillator (FOSC) this equates frequencies 76.3 38.1 19.1 increasing prescaler values.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Sequential Reader
FIGURE 11-1: TIMELINE Read Read Read Read
Time
Trigger Special Event mode sub-mode Compare mode) generates periodic interrupt addition automatically starting conversion when Timer1 matches CCPRxL CCPRxH. following example problem demonstrates sequentially read channels periodic interval. Example Given PIC16F684 running internal oscillator, configure microcontroller sequentially read analog pins AN0, intervals. Step Determine Timer1 prescaler Timer1 overflows TOSC*4*65536* prescaler. prescaler 1:1, Timer1 overflow occurs 32.8 This greater than prescaler adequate.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Step Calculate CCPR1 (CCPR1L CCPR1H) CCPR1 Interval Time/(TOSC*4*prescaler) 0.030/(125 ns*4*1) 6000 0xEA60 Therefore, CCPR1L 0x60, CCPR1H 0xEA
Step Configuring CCP1CON ECCP module should configured Trigger Special Event mode. This mode generates interrupt when Timer1 equals value specified CCPR1. Timer1 automatically cleared ADCON0 automatically set. this mode, CCP1CON `b00001011'. Step Interrupt Service Routine logic When ECCP interrupt generated, select next reading altering ADCON0 register.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Repetitive Phase Shifted Sampling
Repetitive phase shifted sampling technique artificially increase sampling rate converter when sampling waveforms that both periodic constant from period period. technique works capturing regularly spaced samples waveform from start finish waveform's period. Sampling next waveform then performed same manner, except that start sample sequence delayed percentage sampling period. Subsequent waveforms also sampled, with each sample sequence slightly delayed from last, until delayed start sample sequence equal sample period. Interleaving sample sets then produces sample waveform higher sample rate. Figure 12-1 shows example high frequency waveform.
FIGURE 12-1: HIGH FREQUENCY PERIODIC WAVEFORM
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
indicated key, finely dotted lines show where readings taken during first period waveform. medium sized dashed lines show when readings taken during second period, Figure 12-2 shows these readings transposed onto period.
FIGURE 12-2: TRANSPOSED WAVEFORM KEY: First Pass Second Pass Third Pass Fourth Pass
volts
time
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
module configured Compare Special Event Trigger mode accomplish this task. phase shift implemented picking values CCPRxL CCPRxH that synchronous with period sampling waveform. instance, period waveform then sampling rate once every will give following sample times over periods (all values µs).
10th 11th
When these numbers placed sequential order, they reveal virtual sampling interval (IV) from although actual sampling interval (IA)
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks TIPS TRICKS
ECCP modules produce 10-bit resolution Pulse Width Modulated (PWM) waveform CCPx pin. ECCP module capable transmitting signal four pins, designated through P1D. modes available ECCP module are: Single output (P1A only) Half-bridge output (P1A only) Full-bridge output forward Full-bridge output reverse
following configurations must chosen when using ECCP module Full-bridge mode: P1A, active-high; P1B, active-high P1A, active-high; P1B, active-low P1A, active-low; P1B, active-high P1A, active-low; P1B, active-low
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
"Why Would Mode?" next Tips Tricks demonstrate, Pulse Width Modulation (PWM) used accomplish variety tasks from dimming LEDs controlling speed brushed electric motor. these applications based basic principle signals duty cycle signal increases, average voltage power provided increases. only does increase with duty cycle, increases linearly. following figure illustrates this point more clearly. Notice that maximum voltage functions duty cycle (DC) following Figure 12-3.
FIGURE 12-3: DUTY CYCLE RELATION VRMS
VMAX
VRMS VRMS
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Equation 12:1 shows relation between VRMS VMAX.
EQUATION 12-1:
VRMS DCxVMAX
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Deciding Frequency
general, frequency application dependent although general rules-of-thumb hold regarding frequency applications. They are: frequency increases, does current requirement switching losses. Capacitance inductance load tend limit frequency response circuit. low-power applications, good idea minimum frequency possible accomplish task order limit switching losses. circuits where capacitance and/or inductance factor, frequency should chosen based analysis circuit.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Motor Control used extensively motor control efficiency switched drive systems opposed linear drives. important consideration when choosing frequency motor control application responsiveness motor changes duty cycle. motor will have faster response changes duty cycle higher frequencies. Another important consideration sound generated motor. Brushed motors will make annoying whine when driven frequencies within audible frequency range kHz.) order eliminate this whine, drive brushed motors frequencies greater than kHz. (Humans hear frequencies upwards kHz, however, mechanics motor winding will typically attenuate motor whine above kHz). Light Bulbs also used light dimmer applications. Flicker noticable with rates below Therefore, generally good rule pulse width modulate LEDs light bulbs higher.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Unidirectional Brushed Motor Control Using
FIGURE 14-1: BRUSHED (BDC) MOTOR CONTROL CIRCUIT Place motor
Motor PIC16F628
EMI/RFI Suppression
CCP1
Figure 14-1 shows unidirectional speed controller circuit brushed motor. Motor speed proportional duty cycle output CCP1 pin. following steps show configure PIC16F628 generate with duty cycle. microcontroller running crystal.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Step Choose Timer2 prescaler FPWM FOSC/((PR2+1)*4*prescaler) 19531 prescaler This frequency lower than kHz, therefore prescaler adequate.
Step Calculate FOSC/(FPWM*4*prescaler) Step Determine CCPR1L CCP1CON<5:4> CCPR1L:CCP1CON<5:4> DutyCycle*0x3FF 0x1FF CCPR1L 0x1FF 0x7F, CCP1CON<5:4>
Step Configure CCP1CON module configured mode with Least Significant bits duty cycle set, therefore, CCP1CON `b001111000'.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Bidirectional Brushed Motor Control Using ECCP
FIGURE 15-1: FULL-BRIDGE DRIVE CIRCUIT
TC428
TC428
Motor
TC428
TC428
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
ECCP module brushed motor control options built into Figure 15-1 shows fullbridge drive circuit connected motor. connections P1A, P1B, ECCP outputs when module configured "Full-bridge Output Forward" "Full-bridge Output Reverse" modes (CCP1CON<7:6>). circuit shown Figure 15-1, ECCP module should configured mode: P1A, active high; P1B, active high (CCP1CON<3:1>). reason this MOSFET drivers (TC428) configured high input will turn respective MOSFET. following table shows relation between states operation, states ECCP pins, ECCP Configuration register.
State
Forward Reverse Coast Brake Legend:
tristate tristate tristate
tristate tristate
tristate tristate
CCP1CON
tristate tristate tristate `b01xx1100' `b11xx1100'
high, low, modulated, tristate configured input
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Generating Analog Output
FIGURE 16-1: LOW-PASS FILTER PIC16F684 CCP1 Analog
Pulse width modulated signals used create Digital-to-Analog (D/A) converters with only external components. Conversion waveforms analog signals involves analog low-pass filter. order eliminate unwanted harmonics caused signal greatest degree possible, frequency signal (FPWM) should significantly higher than bandwidth (FBW) desired analog signal. Equation 16-1 shows this relation.
EQUATION 16-1:
FPWM K*FBW Where harmonics decrease increases
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
chosen based following equation:
EQUATION 16-2:
1/(2FBW) Pick value arbitrarily then calculate attenuation frequency given filter
EQUATION 16-3:
Att(dB 10*log[1+(2FPWMRC)2] attenuation calculated Equation 16-3 sufficient, then must increased Equation 16-1. Application Note AN538 "Using Generate Analog Output PIC17C42" more details using generate analog output.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Boost Power Supply
FIGURE 17-1: BOOST POWER SUPPLY CIRCUIT PIC16F684 Feedback VOUT
CCP1
Hardware Pulse width modulation plays role boost power supply design. Figure 17-1 shows typical boost circuit. circuit works grounding inductor (L1) during high phase signal generated CCP1. This causes increasing current flow through while applied. During phase signal, energy stored flows through storage capacitor (C2) load. VOUT related Equation 17-1. Note: Technical Brief TB053 "Generating High Voltage Using PIC16C781/782" provides details boost power supply design.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
first parameter determine duty cycle based upon input output voltages. Equation 17-1.
EQUATION 17-1:
VOUT
Next, value inductor chosen based maximum current required load, switching frequency, duty cycle. function inductance terms load current given Equation 17-2, where period, duty cycle, IOUT maximum load current.
EQUATION 17-2:
IOUT
value chosen arbitrarily satisfy this equation given IOUT, maximum duty cycle frequency range.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
Using value chosen ripple current calculated using Equation 17-3.
EQUATION 17-3:
IRIPPLE
IRIPPLE exceed saturation current inductor. value does produce ripple current greater than ISAT, bigger inductor needed. Note: equations above assume discontinuous current mode.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Firmware duty cycle varied microcontroller order maintain stable output voltage over fluctuating load conditions. firmware implemented control loop used regulate duty cycle. Feedback from boost power supply circuit provides input control. Note: Application Note AN258 "Low Cost Microcontroller Programmer" provides details firmware based control.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Varying Intensity
intensity varied pulse width modulating voltage across LED. microcontroller typically drives with circuit shown Figure 18-1. purpose limit current that runs specified current voltage range, typically around volts Modulating drive microcontroller will vary average current seen thus intensity. mentioned #13, LEDs other light sources should modulated less than order prevent noticable flicker.
FIGURE 18-1: DRIVE
PIC16F684 CCP1
module, configured mode, ideal varying intensity LED. Adjustments intensity made simply varying duty cycle signal driving LED. This accomplished varying CCPRxL register between 0xFF.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks Generating X-10® Carrier Frequency
X-10® uses piggybacked square wave duty cycle) transmit information over power lines. module, running mode, accurately create square wave, referred carrier frequency. Figure 19-1 shows carrier frequency piggybacked onto sinusoidal power waveform.
FIGURE 19-1: PIC16F87XA OSC2 7.680 RC3/CCP1 OSC1
High-Pass Filter Rated
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
X-10 specifies carrier frequency kHz). system oscillator Figure 18-1 chosen 7.680 MHz, that module generate precisely kHz. X-10 requires that carrier frequency turned different points power waveform. This accomplished configuring TRIS register CCP1 either input (carrier frequency off) output (carrier frequency on.) Refer Application Note AN236 "X-10 Home Automation Using PIC16F877A" more details X-10 source code setting module appropriately.
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks COMBINATION CAPTURE COMPARE TIPS
ECCP modules configured fly. Therefore, these modules perform different functions same application provided these functions operate exclusively (not same time.) This section will provide examples using module different modes same application.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks RS-232 Autobaud
RS-232 serial communication variety baud rates choose from. Multiple transmission rates require software which detects transmission rate adjusts receive transmit routines accordingly. Autobaud used applications where multiple transmission rates occur. module configured Capture mode detect baud rate then configured Compare mode generate receive RS-232 transmissions. order autobaud work, known calibration character must transmitted initially from device another. possible calibration character show Figure 19-1. Timing this known character provides device with baud rate subsequent communications.
FIGURE 20-1: RS-232 CALIBRATION CHARACTER Start Stop
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Autobaud routine implementation: Configure module capture falling edge (beginning Start bit). When falling edge detected, store CCPR1 value. Configure module capture rising edge. Once rising edge detected, store CCPR1 value. Subtract value stored step from value step This time bits. Shift value calculated step right times divide This result period (TB). Shift value calculated step right This result half period bit. following code segments show process transmitting receiving data normal program flow. This same functionality accomplished using module configuring module Compare mode generating interrupt every period. When this method used, either sent received when interrupt occurs.
Note: Refer Application Note AN712 "RS-232 Autobaud PIC16C5X Devices" more details autobaud.
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
EXAMPLE 20-1: TRANSMIT ROUTINE
TxRountine MOVLW MOVWF counter TxLine
;preload counter ;with ;line initially high, ;toggle START ;bit
TxLoop CALL
DelayTb ;wait (bit period) RxByte,f ;rotate first into ;the Carry flag BTFSS STATUS,C line state equals ;state Carry flag TxLine BTFSC STATUS,C TxLine DECFSZ Counter,f ;Repeat times GOTO TxLoop CALL Delay ;Dleay before ;sending STOP TxLine ;send STOP
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
FIGURE 20-2: RECEIVE ROUTINE
RxRoutine BTFSC RxLine GOTO RxRoutine MOVLW
;wait receive ;line ;initialize ;counter
MOVWF Counter CALL Delay1HalfTb ;delay here ;plus RxLoop order sample right time RxLoop CALL DelayTb ;wait (bit ;period) BTFSS RxLine ;Carry flag state ;equals line ;state STATUS,C BTFSC RxLine STATUS,C BTFSC RxLine STATUS,C RxByte,f ;Rotate first ;into receive type DECFSZ Counter,f ;Repeat times GOTO RxLoop
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks Dual-Slope Analog-to-Digital Converter
circuit performing dual-slope conversion utilizing module shown Figure 21-1.
FIGURE 21-1: DUAL-SLOPE ANALOG-TO-DIGITAL CONVERTER Integrator -VREF PIC16F684 CCP1 Comparator (on-board PIC16F684)
DS41214A-page
2003 Microchip Technology Inc.
Tips Tricks
Dual-slope conversion works integrating input signal (VIN) fixed time (T1). input then switched negative reference (-VREF) integrated until integrator output zero (T2). function VREF ratio
FIGURE 21-2: TIME Integrator output with input Integrator output with VREF input
Time
2003 Microchip Technology Inc.
DS41214A-page
Tips Tricks
components this conversion type fixed time timing falling edge. module accomplish both these components Compare mode Capture mode respectively. Here's how: Configure module Compare mode, Special Event Trigger. Switch analog input into integrator from VREF VIN. module wait chosen based capacitor value). When interrupt occurs, switch analog input into regulator from VREF reconfigure module Capture mode; wait falling edge. When next interrupt occurs, time captured module Calculate using Equation 21-1.
EQUATION 21-1:
VREF
DS41214A-page
2003 Microchip Technology Inc.
Information contained this publication regarding device applications like intended through suggestion only superseded updates. your responsibility ensure that your application meets with your specifications. representation warranty given liability assumed Microchip Technology Incorporated with respect accuracy such information, infringement patents other intellectual property rights arising from such otherwise. Microchip's products critical components life support systems authorized except with express written approval Microchip. licenses conveyed, implicitly otherwise, under intellectual property rights. graphics this document illustration only. Microchip reserves right modify contents development systems. Trademarks Microchip name logo, Microchip logo, Accuron, dsPIC, KEELOQ, MPLAB, PIC, PICmicro, PICSTART, MATE PowerSmart registered trademarks Microchip Technology Incorporated U.S.A. other countries. AmpLab, FilterLab, microID, MXDEV, MXLAB, PICMASTER, SEEVAL, SmartShunt Embedded Control Solutions Company registered trademarks Microchip Technology Incorporated U.S.A. Application Maestro, dsPICDEM, dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, microPort, Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM, PICDEM.net, PICtail, PowerCal, PowerInfo, PowerMate, PowerTool, rfLAB, rfPIC, Select Mode, SmartSensor, SmartTel Total Endurance trademarks Microchip Technology Incorporated U.S.A. other countries. Serialized Quick Turn Programming (SQTP) service mark Microchip Technology Incorporated U.S.A. other trademarks mentioned herein property their respective companies. 2003, Microchip Technology Incorporated, Printed U.S.A., Rights Reserved. Printed recycled paper.
2003 Microchip Technology Inc.
DS41214A-page
Worldwide Sales Service
AMERICAS
Corporate Office
Tel: 480-792-7200 Technical Support: 480-792-7627
ASIA/PACIFIC
Australia
Tel: 61-2-9868-6733
Taiwan
Kaohsiung Tel: 886-7-536-4818
China-Beijing
Tel:86-10-85282100
Taiwan
Tel: 886-2-2717-7175
Atlanta
Tel: 770-640-0034
China-Chengdu
Tel: 86-28-86766200
EUROPE
Austria
Tel: 43-7242-2244-399
Boston
Tel: 978-692-3848
China-Fuzhou
Tel: 86-591-7503506
Denmark
Tel: 45-4420-9895
Chicago
Tel: 630-285-0071
Dallas
Tel: 972-818-7423
China-Hong Kong
Tel: 852-2401-1200
France
Tel: 33-1-69-53-63-20
Detroit
Tel: 248-538-2250
China-Shanghai
Tel: 86-21-6275-5700
Germany
Tel: 49-89-627-144-0
Kokomo
Tel: 765-864-8360
China-Shenzhen
Tel: 86-755-82901380
Italy
Tel: 39-0331-742611
China-Shunde
Tel: 86-765-8395507
Angeles
Tel: 949-263-1888
United Kingdom
Tel: 44-118-921-5869 11/24/03
China-Qingdao
Tel: 86-532-5027355
Phoenix
Tel: 480-792-7966
India
Tel: 91-80-2290061
Jose
Tel: 650-215-1444
Japan
Tel: 81-45-471- 6166
Toronto
Tel: 905-673-0699
Korea
Tel: 82-2-554-7200
Singapore
Tel: 65-6334-8870 Microchip received ISO/TS-16949:2002 quality system certification worldwide headquarters, design wafer fabrication facilities Chandler Tempe, Arizona Mountain View, California October 2003. Company's quality system processes procedures PICmicro® 8-bit MCUs, KEELOQ® code hopping devices, Serial EEPROMs, microperipherals, non-volatile memory analog products. addition, Microchip's quality system design manufacture development systems 9001:2000 certified.
*DS41215A*
DS41214A-page 2003 Microchip Technology Inc.
Microchip Technology Inc. 2355 Chandler Blvd. Chandler, 85224 U.S.A. Phone: 480-792-7200 Fax: 480-792-9210 www.microchip.com 2003, Microchip Technology Inc., 12/03 DS41214A
*DS41214A*

Other recent searches


W681308 - W681308   W681308 Datasheet
Si7461DP - Si7461DP   Si7461DP Datasheet
ROS-5580-119+ - ROS-5580-119+   ROS-5580-119+ Datasheet
PCA9532 - PCA9532   PCA9532 Datasheet
LTC2495 - LTC2495   LTC2495 Datasheet
2SC4880 - 2SC4880   2SC4880 Datasheet
2N1975 - 2N1975   2N1975 Datasheet
2N1983 - 2N1983   2N1983 Datasheet
2N1984 - 2N1984   2N1984 Datasheet
2N1985 - 2N1985   2N1985 Datasheet
2N1986 - 2N1986   2N1986 Datasheet
2N1987 - 2N1987   2N1987 Datasheet
2N1988 - 2N1988   2N1988 Datasheet
2N1989 - 2N1989   2N1989 Datasheet
2N1990 - 2N1990   2N1990 Datasheet
2N2017 - 2N2017   2N2017 Datasheet
2N2049 - 2N2049   2N2049 Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive