Help Choosing the correct PIC for 2 Channel PWM


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2012
    Posts
    64

    Default Help Choosing the correct PIC for 2 Channel PWM

    Hi,
    I could use some help choosing the correct PIC. I need to have 2 independent PWM outputs to be used for generating two distinct tones. The only other thing required is to have two input pins to trigger the PWM outputs and a few inputs for dip switches to select the frequencies. I have spare 16f1938, 18F14k22 chips. I would like to keep the pin count as small as possible. The 16f1938 shows 3 ECCP ports, which I thought was all you need, but then it shows 0 for stand alone PWM. The Hardware PWM seems confusing to me once you go over one output so I want to make sure I am at least stating with a micro that can do what I need to do since I don’t really have enough hair left to pull out.
    I am using PicBasic 2.6c

    Thanks,
    Jim

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: Help Choosing the correct PIC for 2 Channel PWM

    Hi Jim,
    As far as I can see the 1938 has three ECCP modules (for which HPWM might not work, I don't know for sure) AND two standard CCP (for which the HPWM command "should" work). And in the event you should find that HPWM doesn't work it's not that hard to setup manually - and it gives you more "power", like being able to have more than 8bits of resolution. I'll promise to help you out if you need, just make a post here.

    So, if you already have the 1938 on hand and it's suitable from other perspectives then I'd use that.

    /Henrik.

  3. #3
    Join Date
    Feb 2012
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Help Choosing the correct PIC for 2 Channel PWM

    Thanks Henrik. I will give it a try and let you know if (When?) I run into problems.

    Jim

    Quote Originally Posted by HenrikOlsson View Post
    Hi Jim,
    As far as I can see the 1938 has three ECCP modules (for which HPWM might not work, I don't know for sure) AND two standard CCP (for which the HPWM command "should" work). And in the event you should find that HPWM doesn't work it's not that hard to setup manually - and it gives you more "power", like being able to have more than 8bits of resolution. I'll promise to help you out if you need, just make a post here.

    So, if you already have the 1938 on hand and it's suitable from other perspectives then I'd use that.

    /Henrik.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Help Choosing the correct PIC for 2 Channel PWM

    I don't think you will be able to generate 2 distinct tones. From the PBP manual:

    Frequency is the desired frequency of the PWM signal. On devices
    with 2 channels, the Frequency must be the same on both channels.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: Help Choosing the correct PIC for 2 Channel PWM

    That's a very valid point, one that I totally missed when reading Jims initial post, sorry about that!

    That limitation comes from the fact that the CCP module(s) are (historically) tied to the same timebase so they need to have the same output frequency. Thankfully things have changed over the years and the CCP modules on the 16F1938 can individually be assigned any of TMR2/TMR4/TMR6 as their timebase. It does however mean that HPWM is out (at least I Think it is) and you'll need to setup the CCP modules manually.

    /Henrik.

  6. #6
    Join Date
    Feb 2012
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Help Choosing the correct PIC for 2 Channel PWM

    So that means directly writing to the correct ports might do what I want? I didn't start testing yet. I did purchase an LED 3 channel 8-bit PWM driver to try (TLC59731DR). I thought it was SPI, but it isn't, and It also controls duty cycle. There are plenty of external devices available that look like they might work, but I'll wait until after I rule out the 16F1938 as an option.

    Thanks

    Quote Originally Posted by HenrikOlsson View Post
    That's a very valid point, one that I totally missed when reading Jims initial post, sorry about that!

    That limitation comes from the fact that the CCP module(s) are (historically) tied to the same timebase so they need to have the same output frequency. Thankfully things have changed over the years and the CCP modules on the 16F1938 can individually be assigned any of TMR2/TMR4/TMR6 as their timebase. It does however mean that HPWM is out (at least I Think it is) and you'll need to setup the CCP modules manually.

    /Henrik.

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: Help Choosing the correct PIC for 2 Channel PWM

    So that means directly writing to the correct ports might do what I want?
    Well, not the ports but the registers for the CCP modules(s), yes. Two-three registers per module maby, so four to six lines of code to have both running. The "trick" is to figure out what to write to the registers, the datasheet is key.

    I did purchase an LED 3 channel 8-bit PWM driver to try (TLC59731DR). I thought it was SPI, but it isn't, and It also controls duty cycle.
    No, it's not SPI, more "like" async serial and yes the dutycycle of the fixed frequency output IS the only thing it controls - that's how it dims the LEDs.

    It's not really clear what exactly you want to do. In the first post you mention generating two distinct tones but then you're talking about LED dimmers. Can you explain what you're trying to achieve?

  8. #8
    Join Date
    Feb 2012
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: Help Choosing the correct PIC for 2 Channel PWM

    Yes, Registers are what I meant. I just ordered a few PIC10F322 & 12F1840 chips (They are very small - 6 & 8 pin). I figure the best way to be sure I get the tones I want at a volume I expect would be to use one of these for each tone. One input pin to trigger, one output for the sound, and either two inputs to select 1 of 4 pre-set tones or one analog input to select a range of tones. the 6-pin SOT package wouldn't take up much board space and the price is right. I still plan on playing around with the CCP module of the 1938, but using a couple of these small chips seems to be the easiest way to go for this project.

    I thank you for your help and will let you know the outcome of the testing.

    Jim


    Quote Originally Posted by HenrikOlsson View Post
    Well, not the ports but the registers for the CCP modules(s), yes. Two-three registers per module maby, so four to six lines of code to have both running. The "trick" is to figure out what to write to the registers, the datasheet is key.


    No, it's not SPI, more "like" async serial and yes the dutycycle of the fixed frequency output IS the only thing it controls - that's how it dims the LEDs.

    It's not really clear what exactly you want to do. In the first post you mention generating two distinct tones but then you're talking about LED dimmers. Can you explain what you're trying to achieve?

  9. #9
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Help Choosing the correct PIC for 2 Channel PWM

    16F876A has 2 independent pwm channels, and I'm using them just fine.

Similar Threads

  1. max frequency on pwm channel 16f88
    By queenidog in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st June 2013, 16:47
  2. Replies: 1
    Last Post: - 4th March 2013, 22:57
  3. 3 channel PWM with customize duty cycle
    By photoelectric in forum mel PIC BASIC Pro
    Replies: 56
    Last Post: - 16th May 2011, 14:49
  4. Is this the correct PIC?
    By The Master in forum Off Topic
    Replies: 8
    Last Post: - 6th May 2008, 17:44
  5. Help choosing right PIC
    By Darrenmac in forum General
    Replies: 2
    Last Post: - 13th June 2006, 08:51

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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