The servo driver and brushless motor driver SW now works as intended. The motor runs for 10.0 seconds and then stops instantly. I found (after much trial and error) that commanding changes to motor speed only works when placed inside the TMT1 interrupt handler instead of the main program section.
New handler shown below in case it may be of help to someone in the future.
Code:;____This routine is Called on each TMR1 Interrupt______________________ T1handler: 'interrupts are every 20 ms if sum <= MTtime then 'MTtime = 10.0 second pre-set run time throttlepos = 400 'full speed pulse = 2.00 ms at 8mhz else throttlepos = 200 'zero speed pulse = 1.00 ms at 8mhz endif pulsout portc.5,throttlepos 'send pulse to motor speed controller pulsout portc.4,servopos 'send pulse to servo (pulse range is Ticks = Ticks + 1 '1 ms to 2 ms for both pulses) if Ticks = 5 then Ticks = Ticks - 5 Tenths = Tenths + 1 if tenths = 10 then Seconds = Seconds + 1 Tenths = 0 endif sum = 10*Seconds + Tenths 'calculate time in tenths of seconds endif @ INT_RETURN




Bookmarks