Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
/* * for ATtiny 84. * */#define F_CPU 1000000#include <avr/io.h>#include <util/delay.h>void initPWM(){ TCCR1A = 0; ICR1 = 19999; DDRA = _BV(DDA6) | _BV(DDA5); TCCR1A = (1 << WGM11); TCCR1B = (1 << WGM13) | (1<<WGM12) | (1 << CS11); TCCR1A |= (1 << COM1A1) | (1 << COM1B1);}int main(){ initPWM(); OCR1A = 500; OCR1B = 1000; _delay_ms(1000); OCR1A = 750; OCR1B = 1000; _delay_ms(1000); OCR1A = 800; OCR1B = 1000; _delay_ms(1000); for(;;) { }}
When you set the motors (modified servos) to stop do they?How do run in reverse?How heavy is you Bot?Do the motors run sluggish if you lift the Bot off the ground?Have you tried to set the pulse width further from the stop value?
Try disconnecting one servo and the distance sensors, and possibly add a reasonably large capacitor, just to check it isn't a power issue... it looks like you could be cutting it fine and possibly seeing brownout.
My maths isn't the strongest but (8000000 / 800) != 20000 That said be sure you are using the correct formula for the pwm mode you have selected. It looks like you are using fast pwm so the formula you use above doesn't apply. Also worth a try would be increasing your ICR1 value to give a ~25ms total period.