PWM PULSE WITH MEGA8A??

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HI

can I produce a pwm pulse with mega8 that 5us=on & 10ms=off?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends on your skill level, but for those skilled in the art, your requirements are easy to achieve. Sounds like you want to control a RC servo. If so, there are plenty of examples on the interwebs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to apply this pulse to a meg16.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mostafa147 wrote:

can I produce a pwm pulse with mega8 that 5us=on & 10ms=off?

 

Yes.

 

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To my knowledge, in case of ATmega8, the best resolution of PWM is 1/1024 [10 bits]. The ratio 5us/10,000us is 1/2000. So, to me in the least, the answer to your question is no if ATmega8 is used... though I wish I am wrong. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KerimF wrote:

To my knowledge, in case of ATmega8, the best resolution of PWM is 1/1024 [10 bits]. The ratio 5us/10,000us is 1/2000. So, to me in the least, the answer to your question is no if ATmega8 is used... though I wish I am wrong. 

 

And yet my screen grab above, and this one below, would appear to say otherwise...

 

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Same 10ms repeat rate, here I've set a wider pulse width...

 

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KerimF wrote:

To my knowledge, in case of ATmega8, the best resolution of PWM is 1/1024 [10 bits]. The ratio 5us/10,000us is 1/2000. So, to me in the least, the answer to your question is no if ATmega8 is used... though I wish I am wrong. 


Yes you are wrong. Yes, there is at least one canned 10-bit mode. But there is also at least one canned 16-bit mode.
See the

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

KerimF wrote:

To my knowledge, in case of ATmega8, the best resolution of PWM is 1/1024 [10 bits]. The ratio 5us/10,000us is 1/2000. So, to me in the least, the answer to your question is no if ATmega8 is used... though I wish I am wrong. 

 

Yes you are wrong. Yes, there is at least one canned 10-bit mode. But there is also at least one canned 16-bit mode.
See the

 

Thank you for pointing out that there is a 16-bit mode when using PWM of ATmega8 (the only MCU I have for my various projects).

Would you please let me know on which table on its datasheet this mode is shown (I write my codes in assembly only).

Thank you in advance for your time.

 

Last Edited: Tue. Oct 31, 2017 - 12:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
See the

Don't you just love a cliffhanger!

 

surprise  cheeky

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KerimF wrote:

Would you please let me know on which table on its datasheet this mode is shown ...

 

Table 39 (or at least it is in the version of the datasheet I have downloaded.)

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Brian for your fast reply.

Yes, it is on table 39; titled 'Waveform Generation Mode Bit Description'.

 

It seems I am getting old faster than I was expecting ;)

Only now I noticed that by using the 'Phase Correct PWM Mode' or 'Phase and Frequency Correct PWM Mode', a 16-bit PWM could be generated.

 

I used skipping these two modes because it happens that I didn't need better than 10-bit PWM in my projects.

 

So, thanks to you and theusch for opening my eyes on this.

 

 

 

Last Edited: Tue. Oct 31, 2017 - 01:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Don't you just love a cliffhanger!
Not a cliffhanger, it's a leehanger.devil

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wondered if anyone else would spot that!

 

laugh

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KerimF wrote:
Only now I noticed that by using the 'Phase Correct PWM Mode' or 'Phase and Frequency Correct PWM Mode', a 16-bit PWM could be generated.

I used skipping these two modes

But it's not only that two modes. There are also 16 bit Fast PWM modes (mode 14 and 15).

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sternst wrote:

KerimF wrote:

Only now I noticed that by using the 'Phase Correct PWM Mode' or 'Phase and Frequency Correct PWM Mode', a 16-bit PWM could be generated.

I used skipping these two modes

 

But it's not only that two modes. There are also 16 bit Fast PWM modes (mode 14 and 15).

 

Yes, you are right. In Fast PWM mode, OCR1A\B or ICR1 is also used.

 

Thank you for your remark.

  

Last Edited: Tue. Oct 31, 2017 - 02:00 PM