Hi,
Perhaps you could do something like:
Code:
For i = 0 to 2
Phase(i) = Phase(i) + 1
If Phase(i) > 185 then
Phase(i) = 0 'When pointer is > 185 we need to wrap around to 0.
Gosub ChangeBridgeDrive 'One phase is starting over, go change the outputs.
ENDIF
NEXT
And the ChangeBridgeDrive subroutine might then look something like:
Code:
ChangeBridgeDrive:
' When we come here the value i contains the phase counter that just got reset so we
' can use that to determine for which phase we should switch the outputs.
Select Case i
Case 0 ' It was Phase 1 that rolled over
TOGGLE PORTA.1 ' Invert the state of the pin
TOGGLE PORTA.2 ' Invert the state of the pin
Case 1 ' It was Phase 2 that rolled over
TOGGLE PortB.1 ' Invert the state of the pin
TOGGLE PortB.2 ' Invert the state of the pin
Case 2 ' It was Phase 1 that rolled over
TOGGLE PortC.1 ' Invert the state of the pin
TOGGLE PortC.2 ' Invert the state of the pin
END SELECT
RETURN
Again, it compiles but I've not tested. One concern I have is the time between the two outputs for each halfbridge switching but since the dutycycle is effectively zero at the time of switching there should be no risk of shoot-thru etc. This of course also depends on the design of the hardware which I haven't seen so I'm just raising a warning about it.
/Henrik.
Bookmarks