3 channel PWM with customize duty cycle


Results 1 to 40 of 57

Threaded View

  1. #33
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 3 channel PWM with customize duty cycle

    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.
    Last edited by HenrikOlsson; - 21st April 2011 at 14:54.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts