Picproje Elektronik Sitesi

MİKRODENETLEYİCİLER => Atmel => Konuyu başlatan: berkay_91 - 21 Mayıs 2015, 12:44:21

Başlık: Ynt: ESC çalışmıyor
Gönderen: berkay_91 - 21 Mayıs 2015, 12:44:21
mrb arkdaşlar, aliexpress den getirdiğim ESC nin faz uçlarını BLDC motora, sinyal kablosunuda (beyaz) Atmega 8 in OC1B pinine  bağladım güç kaynağını açtığımda motordan  bip bip bip diye bir ses geliyor daha sonra çalışsın diye butona basıyorum potu çeviriyorum ama tık yok güç kaynağında da her hangi bir akım artışı veya azalışı olmuyor tabi hemen ESC nin uçlarına osiloskop bağladım ve butona bastığımda herhangi bir sinyal göremedim. mikrodenetleyici, butona bastığımda istediğim duty cycle da (%5 - %10) PWM sinyali üretebiliyor orda sorun yok ya ESC bozuk yada yazdığım programda bir hata var... yardımcı olursanız sevinirim

BLDC HIZ KONTROL (ATMEGA8)

/*
* BLDC.c
*
* Created: 22.04.2015 21:01:40
*  Author: BERKAY
*/

#define F_CPU 8000000UL
#include <stdio.h>
#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"

#define F_PWM (unsigned int) 50 // 50 Hz lik puls üretmek için
#define PRESCALAR 256
#define PWM_RESOLUTION (unsigned int) ( F_CPU / (PRESCALAR*F_PWM) )


int Read_adc();
void don();
void adc_init();
void pwm_init();

volatile int temp=0,kontrol=0;

FILE lcd_str = FDEV_SETUP_STREAM(lcd_putc, NULL, _FDEV_SETUP_WRITE);

int Read_adc(){

ADCSRA |= 0x40; // start the adc conversion
while(ADCSRA & 0x40);
return ADCH;         // ADCW = adc low bits + adc high bits

}

void adc_init(){

ADMUX= 0x65;  // ADC pin is selected ADC5, referrance voltage is VCC and ADLAR bit is set for 8 bit
ADCSRA = 0x86;  // prescalar is used 64

}



void pwm_init(){

TCCR1A=(1<<WGM11)|(1<<WGM10)|(1<<COM1B1);
TCCR1B=(1<<WGM12)|(1<<WGM13)|(1<<CS12); // PRESCALAR 256
OCR1A = PWM_RESOLUTION - 1; // OCR1A=624

DDRB|=(1<<2); // for PWM

}


void don(){

PORTB|=(1<<0); // LED on

_delay_ms(400); // buton arkı için

pwm_init();

OCR1B=31; // starting signal

_delay_ms(20); // motor başlangıç sinyali için

while(kontrol==0){

temp=Read_adc();
temp=31+(temp/8);

OCR1B=temp; // OCR1B value change 30-62

lcd_gotoxy(5,1);
printf("%2d",temp);

_delay_ms(200);

if(bit_is_set(PINB,3)) // Çıkmak için
kontrol=1;

}

TCCR1B=0x00;
TCCR1A=0x00;
PORTB&=~(1<<0); // LED off
kontrol=0;

_delay_ms(400); // buton arkı için

}

// (8.10^6)/256 = 31250 Hz
// (1/31250) = 32 us

// (1x10^3)/32 = 31.25 for 1 ms (-90 derece)
// (1.5x10^3)/32 = 46.875 for 1.5 ms (0 derece)
// (2x10^3)/32 = 62.5 for 2 ms (+90 derece)

int main(){

DDRD = 0xFF; // for lcd
DDRB|=(1<<0); // for led

adc_init();
lcd_init(LCD_DISP_ON);

stdout = stdin = &lcd_str;

lcd_clrscr();

lcd_gotoxy(4,0);
lcd_puts("BLDC MOTOR");

lcd_gotoxy(0,1);
lcd_puts("PWM DEGERI:");


while(1){

if(bit_is_set(PINB,3))
don();

temp=Read_adc();
temp=31+(temp/8);

lcd_gotoxy(12,1);
printf("%2d",temp);

}

return 0;

}




mesaj birleştirme:: 21 Mayıs 2015, 12:51:29


(http://s11.postimg.cc/byjyx1v8f/Ads_z.jpg) (http://postimg.cc/image/byjyx1v8f/)