Using following code wouldn't I get 100% duty cycle on PWM?
#include#include #include #include volatile bool TS; int main() { static bool TF,TRF1; volatile uint8_t value; //Sets pin direction, PD6 Motor Drive, PB1 Motor Brake DDRD |= 0x40; DDRB |= 0x02; //Sets initial state of PD6 and PB1 PORTD &= ~0x40; //Motor Drive off PORTB &= ~0x02; //Motor Brake off //Enable Pull Up Resistors PORTC |= 0x05; //PC0(Gbx. Pos.),PC2(Trig.) PORTD |= 0xA0; //PD5,PD7 PORTB |= 0x05; //PB0,PB2 //Sets TC0 for Phase Correct PWM (opt. 5) TCCR0A |= 0x01; TCCR0B |= 0x08; OCR0A = 0xFF; //255 (100% duty cycle) //Main Loop while(1){ //Fire Gun when PINC2 is low if( TRF1 ){ if( ((PINC&_BV(PINC2)) == 0) ){ TCCR0A |= _BV(COM0A0); TCCR0B |= _BV(CS00); TRF1 = false;} } //Stop Firing when PINC2 is high if( ((PINC&_BV(PINC2)) != 0) ){ TCCR0B &= ~_BV(CS00); TCCR0A &= ~_BV(COM0A0); PORTD &= ~_BV(PIND6); TRF1 = true; } }//End Main Loop }
Because when I tested this I could audibly hear the gearbox turning much slower than when I just turn PIND6 on and off directly without PWM. I want to be able to changed the duty cycle but also be able to have full power(100% duty cycle) as a setting. Perhaps I'm missing something.