PWM problem

Hi, i'm trying to modify pwm frequency to fit to my DC motor, i think i would need at least 20khz, the problem seems that i'm not good at it :smiley:

i'm testing this code :

//First clear all three prescaler bits:
int prescalerVal = 0x07; //create a variable called prescalerVal and set it equal to the binary                                                       number "00000111"
TCCR0B &= ~prescalerVal; //AND the value in TCCR0B with binary number "11111000"

//Now set the appropriate prescaler bits:
int prescalerVal = 1; //set prescalerVal equal to binary number "00000001"
TCCR0B |= prescalerVal; //OR the value in TCCR0B with binary number "00000001"

this should bring my pin 5 and 6 to 64khz ... but no luck, my motor seems to still have problem, when i increase the duty cycle it spins , not at full power, and in 30sec it stops.

(i'm driving it with an SN754410NE, wich i used with some other smaller dc without any problem)

when i connect the motor to the +5V from my generator it spins like hell ...

its so frustrating ... :-/

Running at 64KHz or even 20KHz is not likely to work with a motor. This is because a motor is an inductive load and at initial switch on it looks like an open circuit. It takes time for the current to rise in the coil and switching it so rapidly is not allowing it to rise very far before you cut it off again.
I would expect it to run but not as fast.
I am not sure why it stops after 30 seconds, is the chip overheating?

chip aint overheating, and everyone that used this kind of motors told me that need a pwm to ~20khz

anyway i'm trying at different frequencys but i dunno if i'm doing it in the right way ... 'cause seems no difference between frequencys