10 Eylül 2020 Perşembe

ccs c pwm ile motor kontrol

Pic programlama ccs c pwm ile motor kontrol örnek çalışma

#include<16f877a.h>
#device adc=8
#fuses xt,nowrt,nowdt,nodebug,nobrownout,nolvp,nocpd,noput,noprotect
#use delay(clock=4m)
#use fast_io(b)
#use fast_io(c)
#use fast_io(e)

#define use_portb_lcd true
#include <lcd.c>

unsigned int digital;

void main()
{
setup_timer_2(T2_DIV_BY_16,250,1);
setup_CCP1(CCP_PWM);
setup_CCP2(CCP_OFF);
setup_adc(adc_clock_div_2);
setup_adc_ports(ALL_ANALOG);

set_tris_b(0x00);
set_tris_c(0x00);
set_tris_e(0xff);

set_adc_channel(5);
delay_us(20);

lcd_init();
printf(lcd_putc,"\fPWM mot kontrol");
delay_ms(1000);
set_pwm1_duty(0);

while(true)
{
digital=read_adc();
delay_us(20);

output_high(pin_c3);
output_low(pin_c4);

if(digital > 250)
digital=250;

set_pwm1_duty(digital);

printf(lcd_putc,"\fDigital= %u",digital);
delay_ms(50);
}
}


Hiç yorum yok:

Yorum Gönder

Her yorum bilgidir. Araştırmaya devam...