Sayfalar

Menü

28 Haziran 2022 Salı

Pwm motor hız kontrol ccs compiler

 Pwm motor hız kontrol ccs compiler 16f877a

#include<16f877a.h>

#device adc=8

#use delay(clock=4m)

#fuses xt,nowdt,noput,nolvp,nocpd,noprotect,nodebug

#use fast_io(a)

#use fast_io(b)

#use fast_io(c)

#define use_portb_lcd TRUE

#include<lcd.c>

unsigned int deger;

float voltaj;

void main()

{

setup_timer_2(t2_div_by_4,255,1);

setup_ccp1(ccp_pwm);

setup_adc(adc_clock_div_32);

setup_adc_ports(all_analog);

set_tris_a(0x20);

set_tris_b(0x00);

set_tris_c(0x00);

set_adc_channel(4);

delay_us(20);

output_c(0x00);

lcd_init();

printf(lcd_putc,"\fDc motor\nHiz Kontrol:");

delay_ms(1000);

set_pwm1_duty(0);

while(true)

{

deger=read_adc();

delay_us(20);

voltaj=deger/51.0;

output_high(pin_c3);

output_low(pin_c4);

set_pwm1_duty(deger);

printf(lcd_putc,"\fVoltaj=%f v",voltaj);

lcd_gotoxy(1,2);

printf(lcd_putc,"Deger=%u",deger);

delay_ms(r00);

}

}



Hiç yorum yok:

Yorum Gönder

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