Hi,
HPWM works in the background, once you tell it to output a certain dutycycle with a certain frequency it does that in hardware. There's no need to continously execute the HPWM commands like your doing in your main loop.
If you change the prescaler to 1:1 you'll get an interrupt every 65536us or around 15Hz, I'd try that as a starting point. If you need faster interrupt rate than that you need to preload the TMR1 register in the ISR so that it doesn't start from 0. If you load with 55536 there will be 10000 cycles (or 10000us in this case) untill the next interrupt.
I have no idea if analog or digital sensor is best. I don't even know what sensors you're using....
If you have two sensors, one on "each side" of the line then I think two speeds for each motor should do. Run both motor at the lower speed to go straight forward, increase the speed of one motor to turn. (Or do the oposite if you want).




Bookmarks