امتیاز موضوع:
  • 0 رأی - میانگین امتیازات: 0
  • 1
  • 2
  • 3
  • 4
  • 5
مدار آتش یکسوسازها
نویسنده پیام
linaz آفلاین
كاربر تک ستاره
*

ارسال‌ها: 51
موضوع‌ها: 14
تاریخ عضویت: خرداد ۱۳۸۸

تشکرها : 165
( 126 تشکر در 31 ارسال )
ارسال: #1
مدار آتش یکسوسازها
سلام
من یه برنامه نوشتم برای مدار آتش یکسوسازها در چند mode مختلف با زاویه آتش قابل تغییر .
تو یه تاپیک دیگه هم تحت عنوان ریست کردن میکروکنترلر مشکلمو عنوان کردم ، با همه راهکارایی که دوستان لطف کردنو گفتن مشکل برنامم در نیومد. برنامه رو می ذارم شما هم نظر بدین
کد:
This program was produced by the
CodeWizardAVR V1.24.4 Standard
Automatic Program Generator
© Copyright 1998-2004 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
e-mail:office@hpinfotech.com

Project :
Version :
Date : 5/18/2009
Author : l
Company : l
Comments:


Chip type : ATmega8
Program type : Application
Clock frequency : 1.000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
Data Stack size : 256
*****************************************************/

#include <mega8.h>
#include <delay.h>
#include <stdio.h>

// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x18 ;PORTB
#endasm
#include <lcd.h>
char bufer[10];
int key2,i,key,b,mode,count,g=0,h,f,ab;
unsigned int time1,time180,time2,time60,time120,time3,time4;

// External Interrupt 0 service routine




interrupt [EXT_INT0] void ext_int0_isr(void)
{
// Place your code here

}

#define ADC_VREF_TYPE 0xC0
// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input|ADC_VREF_TYPE;
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}



interrupt [TIM1_OVF] void timer1_ovf_isr(void)
{
// Place your code here
if(mode==1){
if(h==0){
PORTD=0x01;
TCNT1=time180;
TCCR1B=0x01;
h=1;
g=0;
}
g++;
if(g>1){
if(g==2)
PORTD=0x02;
if(g==3){
PORTD=0x01;
g=1;
}
TCNT1=time180;
TCCR1B=0x01;
}
}
if(mode==2){
if(h==0){
PORTD=0x03;
TCNT1=time180;
TCCR1B=0x01;
h=1;
g=0;
}
g++;
if(g>2){
if(g==3)
PORTD=0x0c;
if(g==4){
PORTD=0x03;
g=2;
}
TCNT1=time180;
TCCR1B=0x01;
}
}
if(mode==3){
if(h==0){
PORTD=0x01;
TCNT1=time120;
TCCR1B=0x01;
h=1;
g=0;
}
g++;
if(g>2){
if(g==3)
PORTD=0x02;
if(g==4)
PORTD=0x04;
if(g==5){
PORTD=0x01;

g=2;
}
TCNT1=time120;
TCCR1B=0x01;
}
}
if(mode==4){
g++;
if(h==0){
PORTD=0x01;
TCNT1=time60;
TCCR1B=0x01;
h=1;
g=2;
}
if(g>2){
TCNT1=time60;
if(g==3)
PORTD=0x02;
if(g==4)
PORTD=0x04;
if(g==5)
PORTD=0x08;
if(g==6)
PORTD=0x10;
if(g==7)
PORTD=0x20;
if(g==8){
PORTD=0x01;
g=2;
}
}

}

}




// Declare your global variables here
int set_key(void);
int set_angle(void);
void main(void)
{
// Declare your local variables here
char bufer1[10];
float value,t,t120,t60,div;
unsigned int var,angle;


PORTB=0x00;
DDRB=0x00;

PORTC=0x00;
DDRC=0x00;

PORTD=0x00;
DDRD=0xFF;

TCCR0=0x00;
TCNT0=0x00;

TCCR1B=0x00;
TCCR1A=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

GICR|=0x40;
MCUCR=0x03;
GIFR=0x40;


TIMSK=0x04;


// ADC initialization
// ADC Clock frequency: 125.000 kHz
// ADC Voltage Reference: Int., cap. on AREF
ADMUX=ADC_VREF_TYPE;
ADCSRA=0x83;


ACSR=0x80;
SFIOR=0x00;

// LCD module initialization
#asm("cli")
lcd_init(16);
mode=1;
lcd_clear();
lcd_putsf("ENTER THE MODE");
//goto loop1;
goto br;

loop1:
while(1){
key=set_key();
if(key>4){
key=0;
i=0;
}
mode=key;
lcd_clear();
sprintf(bufer,"NUMBER OF MODE:%i",key);
lcd_puts(bufer);
delay_ms(500);
key2 =PINC.3 & 0x01;
if(key2 ==0x01){
delay_ms(50);
key2 =PINC.3 & 0x01;
if(key2 ==0x01)
b=1;
}
if(key>0 & b==1){
lcd_clear();
lcd_putsf("MODE IS ACCEPT");
delay_ms(500);
lcd_clear();
lcd_gotoxy(0,0);
sprintf(bufer1,"MODE=%i",mode);
lcd_puts(bufer1);
delay_ms(1000);
goto angel;
}
}
br:
switch(key)
{
case 1:
goto mode1;
case 2:
goto mode2;
case 3:
goto mode3;
case 4:
goto mode4;
case 0:
goto loop1;
}

AD: //////////////////////////
var=read_adc(0);
var=var+1;
value=var*2.56;
value=value/1023;
if(value>0 && value<2)
{
goto atash;
}
else
{
goto AD;
}


atash: /////////////////////////////
if(mode==1){
TCNT1=time1;
TCCR1B=0x01;
h=0;
#asm("sei")
g++;
while (1){
}
}
if(mode==2){
TCNT1=time2;
TCCR1B=0x01;
h=0;
#asm("sei")
g=1;
while(1){
}
}
if(mode==3){
TCNT1=time3;
TCCR1B=0x01;
h=0;
#asm("sei")
g=1;
while(1){
}
}
if(mode==4){
TCNT1=time4;
TCCR1B=0x01;
h=0;
#asm("sei")
g=1;
while(1){
}
}

mode1:
mode=1;
angle=30;
lcd_clear();
lcd_putsf("mode=1");
div=angle/180;
t=0.01; ///////////time of f=50hz 1/f=0.02/2=0.01
t=0.01*div;
t=t/0.000001;
time1=65535-t;
t=0.01/0.000001;
time180=65535-t;
goto atash;


mode2:
mode=2;
lcd_clear();
lcd_putsf("mode=2");
div=angle/180;
t=0.01; ///////////time of f=50hz 1/f=0.02/2=0.01
t=0.01*div;
t=t/0.000001;
time2=65535-t;
t=0.01/0.000001;
time180=65535-t;
goto AD;


mode3:
mode=3;
div=180/angle;
t=0.01; ///////////time of f=50hz 1/f=0.02/2=0.01
t=t/div;
t=t/0.000001;
time3=65535-t;
t120=2*0.01/3;
t120=65535-t120;
t120=t120/0.000001;
time120=65535-t120;
TCCR1B=0x00;
goto AD;

mode4:
mode=4;
t60=0.01/3;
t60=t60/0.000001;
t60=65535-t60;
time60=t60;
div=180/angle;
t=0.01; ///////////time of f=50hz 1/f=0.02/2=0.01
t=t/div;
t=t/0.000001;
time4=65535-t;
TCCR1B=0x00;
goto AD;


angel:
f=0;
angle=0;
goto y;
y:
ab=set_angle();
angle=ab*12;
if (angle>170 | angle<0)
{
angle=168;
f=14;
}
sprintf(bufer,"ANGLE:%i DEG",angle);
lcd_gotoxy(0,1);
lcd_puts(bufer);
delay_ms(500);
b=0;
key2 =PINC.3 & 0x01;
if(key2 ==0x01)
{
delay_ms(50);
key2 =PINC.3 & 0x01;
if(key2 ==0x01)
{
b=1;
}
}
if (b==1)
goto br;
else
goto y;



}

int set_key(void)
{
key2 =PINC.1 & 0x01;
if(key2 ==0x01)
{
delay_ms(50);
key2 =PINC.1 & 0x01;
if(key2 ==0x01)
{
i++;
}
}
key2 =PINC.2 & 0x01;
if(key2 ==0x01)
{
delay_ms(50);
key2 =PINC.2 & 0x01;
if(key2 ==0x01)
{
i--;
}
}
if(i<0)
{
i=0;
}
return i;
}
int set_angle(void)
{
key2 =PINC.1 & 0x01;
if(key2 ==0x01)
{
delay_ms(50);
key2 =PINC.1 & 0x01;
if(key2 ==0x01)
{
f++;
}
}
key2 =PINC.2 & 0x01;
if(key2 ==0x01)
{
delay_ms(50);
key2 =PINC.2 & 0x01;
if(key2 ==0x01)
{
f--;
}
}
if(i<0)
{
i=0;
}
return f;

درد من تنهايي نيست؛ بلكه مرگ ملتي است كه گدايي را قناعت، بي‏عرضگي را صبر، و با تبسمي بر لب اين حماقت را حكمت خداوند مي‏نامند.گاندي
(آخرین ویرایش در این ارسال: ۲۱-تير-۱۳۸۸, ۲۰:۰۰:۴۹، توسط 1nafar.)
۲۱-تير-۱۳۸۸, ۰۹:۱۳:۱۶
ارسال‌ها
پاسخ
1nafar غایب
مدیر بازنشسته
*****

ارسال‌ها: 1,195
موضوع‌ها: 91
تاریخ عضویت: فروردین ۱۳۸۷

تشکرها : 1577
( 4273 تشکر در 953 ارسال )
ارسال: #2
RE: مدار آتش یکسوسازها
سلام
میتونم بپرسم مشکل چی هست ، یعنی کجای برنامه جواب نمیده ؟
۲۱-تير-۱۳۸۸, ۲۰:۰۲:۳۷
وب سایت ارسال‌ها
پاسخ
تشکر شده توسط : mahdi20, t3r!p3000
linaz آفلاین
كاربر تک ستاره
*

ارسال‌ها: 51
موضوع‌ها: 14
تاریخ عضویت: خرداد ۱۳۸۸

تشکرها : 165
( 126 تشکر در 31 ارسال )
ارسال: #3
RE: مدار آتش یکسوسازها
ممنون
مشکل برنامه دراومد

درد من تنهايي نيست؛ بلكه مرگ ملتي است كه گدايي را قناعت، بي‏عرضگي را صبر، و با تبسمي بر لب اين حماقت را حكمت خداوند مي‏نامند.گاندي
۰۱-مرداد-۱۳۸۸, ۰۸:۱۸:۴۴
ارسال‌ها
پاسخ
6369849 آفلاین
تازه وارد

ارسال‌ها: 1
موضوع‌ها: 0
تاریخ عضویت: شهریور ۱۳۸۹

تشکرها : 0
( 0 تشکر در 0 ارسال )
ارسال: #4
RE: مدار آتش یکسوسازها
میشه حلا بزاریش؟
۱۴-شهریور-۱۳۸۹, ۰۰:۵۹:۵۵
ارسال‌ها
پاسخ
reza555 غایب
مدیر بازنشسته
*****

ارسال‌ها: 1,073
موضوع‌ها: 17
تاریخ عضویت: شهریور ۱۳۸۸

تشکرها : 3779
( 3261 تشکر در 1342 ارسال )
ارسال: #5
RE: مدار آتش یکسوسازها
تاریخ آخرین ارسالو ببین:
۱-مرداد-۱۳۸۸

زندگی مدیریت فرصت هاست.
۱۴-شهریور-۱۳۸۹, ۰۱:۴۶:۱۶
ارسال‌ها
پاسخ
تشکر شده توسط : t3r!p3000
fleraneenue آفلاین
تازه وارد

ارسال‌ها: 1
موضوع‌ها: 0
تاریخ عضویت: مهر ۱۳۹۰

تشکرها : 0
( 0 تشکر در 0 ارسال )
ارسال: #6
PeectVonRet Payday Loans with Savings Plans Can be found On-Line
The main good thing about these kinds of financial loans is they present wage day and that denotes you will possess the cash an individual anxiously need with your examining bank account inside of Twenty four hours involving posting an online program for the mortgage. Yet another appealing factor is the fact that these types of short loans are quick and trouble-free to acquire, considering that almost the entire course of action is fully gone on the internet regarding one particular application for the loan type having fields just like brand, tackle, information, banking information and so forth. Seeking to is that you could qualify for a short-term cash advance while you have a very a bad credit score rating. Endorsement to get a pay day loan will not depend on to your credit rating; actually you just need to demonstrate you skill to pay back the loan quantity. payday cash advance

In the case of really poor credit loans, there are specific pre requisites, that you just need to meet. To be able to entitled to the loans:-- payday loans online

The largest attraction involving fast payday advances is the fact that there won't be any credit rating checks. Actually those with good credit are already recognize to take out these kind of financial products for that very reason, while every single credit check marks your credit rating. payday loans

The particular Round-the-clock payday advances scheme works since your best ally within situations just like if you should pay health care bills, wish to purchase apparels pertaining to union, get the vehicle fixed, through redecoration or perhaps mending of your property and more which are even challenging to anticipate. The number you use, you'll need to repay again until the next pay day advance. Certainly costs a really lower interest rate. You can take advantage the amount of money ranging from several hundred dollars with a thousands of dollars and cash is going to be available to you inside 24 hours. Merely satisfy some other specifications just before money by means of this scheme: online payday loans

The lending company calls for you to definitely fulfill the qualification circumstances with regard to purchasing this fund plan. These kinds of circumstances bring that you should be the British isles citizenship, you need to be higher than the ages of 18, you have to be regularly employed and you ought to use a looking at banking account. payday loans online

These loans are available in both collateralized along with unguaranteed means. You will get the cash approved in any manner you need. Inside collateralized approach, you have to pledge many property to get the funds approved. They're authorized rapidly. Inside the 2nd scenario, the financial loans are accepted with no security. However, these are approved with greater rate of interest. Simply because of the risk the lending company is displaying in allowing anyone mortgage loan without any security.

Genuine cash advance house loan businesses that supply financial products while using the web, you will need to give you a very good money loan that can hold you until finally the subsequent shell out period or two, with respect to the lender. Most accommodate an individual as much as Three months to repay the borrowed funds. This is fairly beneficial when you're requiring trip shelling out riches - or perhaps basically provide an cost that is simply not maneuvering to hang on.

The tooth ache which results in an emergency trip to the actual dental professional could established a person back a massive amount, in particular when serious dental care perform must be carried out due to the particular pay a visit to. Next unexpected emergency is paid for you personally still need every one of the standard requirements you had for example foodstuff and also power bills to pay while using staying funds. payday loans
۱۱-مهر-۱۳۹۰, ۱۳:۲۲:۴۶
ارسال‌ها
پاسخ


موضوعات مرتبط با این موضوع...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  درخواست مدار منبع تغدیه payamtafe 0 558 ۱۵-تير-۱۳۹۹, ۱۳:۴۱:۰۸
آخرین ارسال: payamtafe
  [فوری] راهنمایی در شماتیک مدار mehrdad137 0 2,610 ۰۳-بهمن-۱۳۹۵, ۰۰:۵۴:۲۷
آخرین ارسال: mehrdad137
  مدار کنترل جریان velakat 1 3,938 ۲۱-مرداد-۱۳۹۵, ۱۱:۲۷:۳۷
آخرین ارسال: maysamshirani
  [ایرانویجی] برد مدار چاپی kimiafars 6 4,007 ۰۸-اسفند-۱۳۹۳, ۱۹:۱۳:۱۰
آخرین ارسال: yaseri
  مدار تقویت کننده کلاس b abbasalifix 0 2,873 ۲۳-دى-۱۳۹۱, ۱۸:۳۶:۲۸
آخرین ارسال: abbasalifix
  درخواست مدار مبدل dc به dc توان بالا golestansara 2 5,640 ۲۶-فروردین-۱۳۹۰, ۲۲:۰۷:۵۹
آخرین ارسال: reza555
Question در خواست راهنمائئ در مورد مدار شارژر باطری alimled 5 6,685 ۲۴-آذر-۱۳۸۹, ۱۴:۲۱:۱۴
آخرین ارسال: reza555

پرش به انجمن:


کاربرانِ درحال بازدید از این موضوع: 1 مهمان

صفحه‌ی تماس | IranVig | بازگشت به بالا | | بایگانی | پیوند سایتی RSS