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.

How Generate Signal with frequency and duty Cycle?(8051 Assembly)

Status
Not open for further replies.

panda1234

Full Member level 2
Joined
Jan 22, 2015
Messages
125
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Activity points
1,172
Hi,
suppose we have frequency and duty cycle in R7 and R6 now how generate signal with internal interrupt?
Thanks a lot
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
20,542
Helped
4,463
Reputation
8,935
Reaction score
4,497
Trophy points
1,393
Activity points
135,804
Hi,

this is discussed very often.

It is also called "PWM generation" or "waveform generation".

check below the "similar threads"
and check other forum thread on this
and check wikipedia and google.

Good luck

Klaus
 

panda1234

Full Member level 2
Joined
Jan 22, 2015
Messages
125
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Activity points
1,172
Thanks but i want use internal interrupt only not instructions for PWM generating.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
20,542
Helped
4,463
Reputation
8,935
Reaction score
4,497
Trophy points
1,393
Activity points
135,804
Hi,

sure you can do this with interrupts.

The benifit of PWM generation is:
* low frequency jitter
* low duty cycle jitter
* extremely low and extremely high duty cycle possible
* no processing power needed (besides setup)

Klaus
 

panda1234

Full Member level 2
Joined
Jan 22, 2015
Messages
125
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Activity points
1,172
Thanks for your hints but first i want to generate it without PWM please help me for do that.

- - - Updated - - -

for example suppose i would like to have a signal 200 Hz and 45% duty cycle how to generate it with internal interrupt.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
20,542
Helped
4,463
Reputation
8,935
Reaction score
4,497
Trophy points
1,393
Activity points
135,804
Hi,

200 Hz is OK. it makes 5ms for a total cycle.

Now you have to decide what resolution you need.

Maybe 5%. This gives 20 steps. 20 steps in 5ms.
Means you need to generate interrupt with 200Hz x 20 = 4000Hz.

This means you need to setup your timer to generate an interrupt eveery 250us.

Within the ISR you need a counter.
increment the counter every time you enter the ISR. set it to zero if it is >=19.
So it counts 0 up to 19.
Now you have to compare this counter with your PWM value. ( in the range of 0...20)
if pwm_value > counter then set PWM_PORT, else clear PWM_PORT.
return from ISR
****

0 gives 0% duty cycle
1 give 5% duty cycle
...
19 gives 95% duty cycle
20 gives 100% duty cycle.

*****

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top