Quantcast
Channel: Reprap Forum - Controllers
Viewing all articles
Browse latest Browse all 10211

Re: Need some help with writing code for PWM

$
0
0
Thanks,

Hmm i see the 644 has more timers on board.

BTW.

In my experiments i did this:


void setup() {
pinMode(9, OUTPUT); //OC1A
pinMode(10, OUTPUT); //OC1B
}

void loop() {


TCCR1A = bit (COM1A0) | bit (COM1B0); // | bit (WGM10) | bit (WGM11);
OCR1A = 50000; //count to 50001, relative to ZERO!

TCCR1B = bit (CS12) | bit (WGM12);// | bit (WGM13);

OCR1A = 50000; //count to 50001, relative to ZERO!

OCR1B = 10; //count to 10001, relative to ZERO!

}

But as you can see when i change the pulse width then the frequency also changes and vice versa.
I then mapped analog inputs to change the countervalues etc, but that method isn't what i'm after

i did that some time ago

I'll have a look at how you used fastpwm and if that works the same on the 328 chip.
Yea.. I tend to waste time on doing things the hard way hehehe i tried to take a shortcut with my question and yea i've cut the corner a bit rough there.:-)

Viewing all articles
Browse latest Browse all 10211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>