Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help me 10kHz PWM to control DC motor by AT89c52

Status
Not open for further replies.

member_tdh

Member level 5
Joined
Feb 6, 2006
Messages
86
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,187
c keil at89c52 delay

Hi all!!
I have a project is control a DC motor (1KW). I tried to generate pulse PWM at 10kHz but not successed. Can anybody hepl me how to generate pulse PWM at 10kHz use IC AT89C52.
Thanks all!!!
 

pwm at only 10 khz

Hi!!!
I want to write a code by C language.Can anybody help me!!!
 

10khz pwm

member_tdh:
It is no wise to use a AT89c52 produce 10K PWM,unless tasks you give to the chip is few.
However,I will answer your question.
Use keil C to compile the following C programme

//Use 24M oscillator

#define T0_Init_Data 0x38
sbit PWM_Pin=P0^0;
unsigned char High_V_Data;
unsigned char Low_V_Data;
unsigned char PWM_Flag=0;

void Init_T0( void ) //initiate T0
{
TH0=T0_Init_Data;
TL0=TH0;
//T0 use Timer function and operating mode 2
TMOD&=0xf8;
TMOD+=0x02;
//enable interrupt
EA=1;
ET0=1;
}

void Set_PWM( unsigned char data ) //the parameter means PWM high voltage.The data's range:0---(0xff-T0_Init_Data)
{
//stop T0 timer
TR0=0;
//set new PWM parameter
High_V_Data=0xff-(T0_Init_Data+data);
Low_V_Data=data;

PWM_Flag=1;
TH0+=High_V_Data;
//start T0 timer
TR0=1;
}

//T0 overflow interruption serve
void int_T0 interrupt 1
{
if(PWM_Flag==1)
{
PWM_Pin=0;
PWM_Flag=0;
TH0+=Low_V_Data;
}
if(PWM_Flag==0)
{
PWM_Pin=1;
PWM_Flag=1;
TH0+=High_V_Data;
}
}

It's a long time I haven't use 51Core chip,if there any mistake in the programme,I apologize for that.
If any question,plz send me an E-mail:aaaaaaaaaalyl@163.com
I will try my best to help you.
 

pwm controller 10k hz

hi!
this is my test source: (.c) following your code that you gived me, but this code is not fine run. Can u fix it for me?
thanks!!!

void Init_T0(void)
{
TMOD|=0x22; // Timer1, mode 2, Timer0, mode 2
TH0=T0_Init_Data;
TL0=TH0;
ET0=1;
EA=1;
}

void Set_PWM(BYTE pwm)
{
TR0=0;
High_V_Data=0xff-(T0_Init_Data+pwm);
Low_V_Data=pwm;
PWM_Flag=1;
TH0+=High_V_Data;
TR0=1;
}

void int_T0() interrupt TF0_VECTOR//1
{
if(PWM_Flag&1)
{
PWM_Pin=0;
PWM_Flag=0;
TH0+=Low_V_Data;
}
else
{
PWM_Pin=1;
PWM_Flag=1;
TH0+=High_V_Data;
}
}

void main(void)
{
Init_T0();

while (1)
{
Set_PWM(pwm_val);
SenChr(PWM_Pin);

if (Inc_pwm_val==0)
{
delay(12000);
while (Inc_pwm_val==0)
{
pwm_val+=1;
if (pwm_val>250) pwm_val=250;
}
}
else
{
if (Dec_pwm_val==0)
{
delay(12000);
while (Dec_pwm_val==0)
{
pwm_val-=1;
if (pwm_val<5) pwm_val=5;
}
}
}

}//End while
}//End main
 

interrupt tf0_vector using

Can anybody help me???
 

pwm 10 khz dc to dc

Can anybody help me???
 

pwm+at89c52 c code

hi IanP,

this page cannot open and i have same problem

i need assembly code...


23 Mar 2006 10:11 Re: help me 10kHz PWM to control DC motor by AT89c52

--------------------------------------------------------------------------------

Here is an example on how to generate PWM using Timer0 Interrupt ..

Try to follow it and if you have any further problems - come back ..
h**p://www.iguanalabs.com/pwm.htm

Regards,
massive attack
 

It looks like the IGUANALABS server has problems or it's gone ..
Meanwhile, maybe this short example will be of any use to you ..
Code:
		$NOPAGING
		$MOD252

; 8051 and PWM

		ORG	0000h 
		LJMP	Start

		ORG	000Bh 
		LJMP	Timer
 
Start:
		mov 	TMOD, #00000001b 
		mov	TH0, #11101010b 
		mov	TL0, #01111001b 
		setb	TR0 
		setb	ET0 
		setb	EA 
		mov	R0, #0d 
		mov	R1, #85d 
		mov	R2, #170d 
		mov	P2, #11111111b 
		mov	A, #255d
Again: 
		inc	A 
		mov	B, R0 
		cjne	A, B, Next_1 
		clr	P2.0 
Next_1:
		mov	B, R1 
		cjne	A, B, Next_2 
		clr	P2.1 
Next_2:
		mov	B, R2 
		cjne	A, B, Next_3 
		clr P2.2 
Next_3:
		cjne	A, #255d, Again 
		mov	P2, #11111111b 
		ljmp	Again

Timer:
		inc	R0 
		inc	R1 
		inc	R2 
		mov 	TH0, #11101010b 
		mov 	TL0, #01111001b 
		reti

	end
It generates 8-bit PWM on P2.0, P2.1 and P2.2 ..

Regards,
IanP
 

use SG3525 with the AT89c52 ......... and generate the 20khz pwm then u will get very good results
 

Try this link though it was intentionally used as PCB drill controller, it works with other DC motor, i've already done this and still in great shape all the years.

**broken link removed**
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top