Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Can someone double check my assumptions ATMega128 PWM

2005-01-29 by Brian Dean

Just FYI, I've implemented your function in one of my MAVRIC-II boards
and verified the PWM signals from PORTE3 and PORTE4 on my scope.  They
work as I think you expect.  OCR3x = 0 gives a 0% duty, OCR3x = 1023
gives 100% duty, and 0 < OCR3x < 1023 give a duty cycle proportionally
in between.

It would still be worthwhile to verify your actual setup using a scope
if possible and make sure that what you are feeding the h-bridge is
correct.  Electronics are not indestructible, of course, and its
possible that one of your PWM outputs has been damaged or something.
Which side is not working, PORTE3 or PORTE4?  Whichever one, try using
PORTE5 instead (OCR3C) and try again.  Be sure and turn on COM3C1 and
DDRE bit 5 during initialization.  You can also use Timer1/PORTB5,6,7
in the same way you are using Timer3/PORTE3,4,5.  Chances are that if
the problem is a bad port pin, that all of them are not going to be
bad.  If you get the same behaviour by moving to a different port
pins, I'd lean toward the problem being in the h-bridge or wiring.

-Brian
-- 
Brian Dean
BDMICRO - ATmega128 Based MAVRIC Controllers
http://www.bdmicro.com/


On Fri, Jan 28, 2005 at 11:44:08PM -0500, wbounce wrote:
> To: <AVR-Chat@yahoogroups.com>
> From: "wbounce" <wbounce@safeplace.net>
> Date: Fri, 28 Jan 2005 23:44:08 -0500
> Subject: RE: [AVR-Chat] Can someone double check my assumptions ATMega128 PWM
> 
> No and I would not know how to work with it anyhow. I will be going to
> my club's meeting in 2 weeks and one of the guys there may have one.
> >From what I see I do not think I am getting any pulse on the left side
> and I am seeing some but not as much as I would expect on the right.
> 
> Hopefully, I can do some more checking tomorrow between helping my son
> study for mid terms and starting to prepare my taxes. Too much work to
> do and not enough robot time
> 
> 
> -----Original Message-----
> From: Brian Dean [mailto:bsd@bdmicro.com]
> Sent: Friday, January 28, 2005 10:43 PM
> To: AVR-Chat@yahoogroups.com
> Subject: Re: [AVR-Chat] Can someone double check my assumptions
> ATMega128 PWM
> 
> 
> 
> On Fri, Jan 28, 2005 at 06:54:31PM -0500, wbounce wrote:
> 
> > void initmotor(void)
> > {
> > OCR3A = 0;
> > OCR3B = 0;
> >
> > TCCR3A = BV(WGM31) | BV(WGM30) ; /* set timer/counter 3 to fast PWM
> > mode 7 */ TCCR3A |= BV(COM3A1) | BV(COM3B1); /* Clear OCnA/OCnB/OCnC
> > on compare match when up-counting. */
> > TCCR3B = BV(CS30) | BV(WGM32) ; /* prescale: 1 @ 16 MHz, 10 bit PWM
> > overflows @ 15625 HZ */
> >
> > // turn everything off
> > OCR3A = 0;
> > OCR3B = 0;
> >
> > DDRE |= BV(PORTE3)|BV(PORTE4); /* enable PWM outputs */
> > }
> > According to how I read the data sheet this should be setting up (Page
> 
> > 133) Mode 7 fast PWM 10 bit with no prescale which should give me
> > 15.6K PWM
> >
> > And setting COM3A1 and COM3B1 should turn the pin to 0 when the
> > counter hits the value I set in OCR3A or OCR3B?
> >
> > Is this COM3A1 part correct?
> 
> Your code looks correct.  Do you have a scope to double check the output
> waveform?
> 
> -Brian
> --
> Brian Dean
> BDMICRO - ATmega128 Based MAVRIC Controllers http://www.bdmicro.com/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.