Haberler:

Forum kuralları güncellendi LÜTFEN  okuyunuz:  https://bit.ly/2IjR3ME

Ana Menü

16f628a PWM özelliği

Başlatan oyhan, 24 Şubat 2005, 21:17:34

oyhan

628 in pwm , compare  ve capture gibi özellikleri var. Ama bunlar ile ilgili hiç bir uygulama yapmadım nasıl kullanılıyor bu konuda özellikle pwm ve diğer özellikleri ile konularda örnek kod veya açıklama sahibi arkadaşlar veya link varmı acab...
İyi çalışmalar....
BİRLİKTEN KUVVET DOĞAR:

XNHCX

PWM ile ilgili aşağıdaki örneği inceleyebilirsin...

Alıntı YapBelow is a code sample showing how to use hardware PWM with the PIC16F628 & PicBasic Pro. To use this code, connect three LEDs (as shown below) to each port-pin B.0, B.1, and B.2 through 470-ohm series resistors to ground.



Alıntı YapConnect an oscilloscope to PortB.3 to view the PWM signal of approximately 38.5KHz output on B.3 using internal hardware PWM.

Here's a peek at what the hardware PWM signal looks like using the internal oscillator option:



Alıntı YapIf you really want to get fancy, and see how multitasking works when using internal hardware features, try sending tons of serial data in a tight loop, and watch the PWM signal.

It's totally un-affected by anything until you physically modify the control registers.

CMCON     = 7          ' PortA = digital I/O
VRCON     = 0          ' A/D Voltage reference disabled
TRISB     = %11110000  ' B.3=PWM,B.0,B.1,B.2 blink LEDs
PR2       = 25         ' Set PWM for approximately 38KHz
CCPR1L    = 13         ' Set PWM Duty-Cycle to 50%
CCP1CON   = %00001100  ' Mode select = PWM
T2CON     = %00000100  ' Timer2 ON + 1:1 prescale

begin:
  high PortB.0
  pause 50
  low PortB.0
  pause 50
  high PortB.1
  pause 50
  low PortB.1
  pause 50
  high PortB.2
  pause 50
  low PortB.2
  pause 50
  goto begin

If you own the PicBasic Pro compiler, try programming this code into the PIC16F628, and setting the oscillator as internal. Next try setting it as external, and use a 4MHz ceramic resonator or external crystal. This will give you an idea of how the internal oscillator timing compares to an external oscillator.

This will give you a good look at why you may want to use an external oscillator for timing critical applications as well.

If you don't own the PicBasic Pro compiler or just prefer to do it the easy way, I have pre-compiled a couple files here for you.


INT-PWM.HEX uses the internal oscillator. The other uses an external oscillator @ 4MHz. Both files will output a 38.5KHz PWM signal on PortB.3 - while port-pins B.0, B.1, and B.2 blink three LEDs.

Note: INT-PWM.HEX will be slightly OFF-frequency due to the internal oscillator being used. A slight fudge-factor normally will be necessary to get a precise PWM signal using the internal oscillator, and it will vary from PIC-to-PIC due to process variables.

Your mileage may vary .....!

http://www.rentron.com/Files/int-pwm.hex
http://www.rentron.com/Files/ext-pwm.hex

http://www.rentron.com/PIC16F628.htm

XNHCX


XNHCX

Bu örneği de inceleyin Dostum...

Building a Wireless Infrared Temperature Transmitter / Receiver
Using Visual Basic & The PicBasic Pro Compiler


http://www.rentron.com/PicBasic/VB_PIC_TEMP.htm