PWM: Vernacular/Function (Newbee)


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2008
    Posts
    5

    Default PWM: Vernacular/Function (Newbee)

    I note that PWM "Sample Code" examples:
    http://www.melabs.com/resources/samples/pbp/767pwm.bas and
    http://www.melabs.com/resources/samples/pbp/hardpwm.bas
    both refer to using "Hardware PWM". Too, neither use the PWM or HPWM instruction.
    Is "Hardware PWM" the same, then, as "Bit-Banging" PWM ...?
    [Presumably "Bit-Banging PWM" can be done with (generally speaking) any output pin, and with (generally speaking) any uC, right?]
    Does Hardware PWM simply mean the uC must have the 'hardware' to do PWM...and is that 'hardware' the CCP(s)?

    My 16F737 has 3 Channels of CCP: I've seen examples that DO and DON'T use the PWM or HPWM. Should I be trying to use one of those instructions or not? (And Why?)

    [My app: PWM Motor Control via opto-isolated MOSFETs].

    Your patience apprecitated!

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You should decide whether or not a PWM frequency of 32,767Hz is fast enough for your application. That is the highest PWM frequency you can get with the PBP command "HWPWM" regardless of your oscillator frequency. If you need a PWM frequency higher than 32Khz, you need to write CCP1CON[4:5] and CCPR1L directly. You can get a PWM frequency of several hundred kilohertz that way - depending on your oscillator frequency and the number of bits of resolution you need.

    HWPWM is not "bit banging". Bit banging usually involves sitting in a tight loop running software counters to do the PWM function - the PIC can't do anything else at that same time. HWPWM on the other hand, sets up the hardware to produce a PWM signal and your main program can go merrily on its way.

    A third possible alternative is to use Darrel Taylor's PWM routine. It uses interrupts and counters to perform software (or bit-banging) PWM. The highest PWM frequency isn't very high, but this method can give you lots of channels of PWM without using 100% of your processor.
    Charles Linquist

  3. #3
    Join Date
    Jul 2008
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Thanks

    Very helpful post, Thank You.

Similar Threads

  1. Half-bridge PWM with a 16F684 ?
    By Byte_Butcher in forum General
    Replies: 7
    Last Post: - 17th January 2010, 22:18
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  4. Newbee Hardware PWM clarification needed
    By emmett brown in forum General
    Replies: 3
    Last Post: - 9th July 2006, 09:18
  5. Tidying Up PWM Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st February 2005, 00:26

Members who have read this thread : 1

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