Go Down

Topic: PWM resolution (Read 3780 times) previous topic - next topic

13litzkri3g

Hello,

I'm working on a project to use an Arduino board as a significantly less expensive alternative to a PDI box for motor control.  I'm relatively inexperienced when it comes to software/electronics, just a heads up.  We've got an atmega2560 and we've got the pwm output to 16 bits which is fast enough but we need a higher resolution.  The counter currently counts from 0 to 255 but how can I change that to a 16 bit counter if that's possible.

Thanks

13litzkri3g

I'm using an mega 2560 by the way.
I spent some time sifting through the datasheet for the 2560 and it seems I need to change ICRn or OCRnA to max, whatever that value may be.

PaulS

Quote
We've got an atmega2560 and we've got the pwm output to 16 bits which is fast enough but we need a higher resolution.

If you are performing PWM with 16 bits, that's 32,768 steps of resolution. That's not enough?

What are you controlling that you can see more that 32,768 steps?
The art of getting good answers lies in asking good questions.

13litzkri3g

To my knowledge we were only getting 8 bits of resolution so 0 to 255. We had the pwm hooked up to an scope to check.

AWOL

16 bits is 65536 steps, but maybe 4096 steps would do?
That would be 12 bits.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

13litzkri3g

The more accuracy the better. How would I go about doing that. I've been pouring over the atmel datasheet for the last day or 2 and have gotten somewhere but haven't figured it out yet

13litzkri3g

@PaulS 32768 counts would be more than enough. We're doing very precise motor control. Accuracy needs to be at the micron level. 

AWOL

32768 is 15 bits, but your original post said you'd already got 16 bits.
I'm confused.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

13litzkri3g

#8
Aug 30, 2012, 09:15 pm Last Edit: Aug 30, 2012, 09:20 pm by Beno-Mcpheeno Reason: 1
I was shooting for 16 bits of resolution in the duty cycle. Right now its an 8 bit duty cycle resolution.

15 bit would work, we just need significantly higher resolution than 0-255.

My bad on the poor communication.

In my original post, I meant to say the frequency is 62500 hz. But the resolution is too low. Hope that clears it up

AWOL

What sort of frequency?
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

13litzkri3g


AWOL

That doesn't make any sense.
Your central heating thermostat operates on PWM, just a low (mHz) frequency.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

13litzkri3g

Now I'm really lost haha. My problem is this. I have the arduino board controlling a motor using PWM. I'm using timer 2, pin 3; a 16 bit timer. I have the prescaler value for the timer set to 1 meaning a PWM frequency of 62500. (i used this http://arduino.cc/playground/Main/TimerPWMCheatsheet). The frequency of the PWM signal is fast enough but, we need a higher counter resolution to better control the duty cycle. In this case, we don't want a duty cycle from 0 to 255, but something larger, hence I said 16 bit because I'm assuming that's the cap. On the atmega 2560 datasheet, the MAX value for the counter is 0xFFFF which is what I want to set it to. But I don't know how, which is what I'm inquiring about.

Erni

Take a look at the PWM library

http://arduino.cc/forum/index.php/topic,117425.0.html

Go Up