Thanks for the post Ian. Hopefully this thread will be of some assistance in your project. THAT'S what this forum is for. The conveyance of information.
My main goal was COST. Yes a better pic with more PWM outputs would have been better but at what price?
Yes a transistor or Fet on the PWM output would be a easy fix but why not use the resources available. In this case 4 PWM outputs that are multiplexed together. Heck why not put a transistor or Fet on each output or use a uLN2308 instead(think I got the right numeration?). Then stuff a voltage regulator, a Mosfet for preventing the batteries from being inserted in backwards. The list could be endless but COST was my first item on the list.
Hopefully Ghostman 11 has a beer or brandy with that popcorn--lol
first off i think you have been disingenuous with LG, he is very young and put ALOT of effort into helping you.
1) Q. AT WHAT COST
A. it is hardly a cost saving when you buy a part that will NOT DO what you would like it to do, Despite Logan posting several diagrams and pointing you to the parts of the datasheet that show why the pic will not do what you want and why it will not do it,you still fail to see the error. ONCE you do see that the chip WILL NOT work with the pwm unit and once you discover that actually LOGAN was right, it will dawn on you that the only realistic way forward with this chip is bu using the method he has outlined above I.E by using a timer and array(s).
When that all hits home ask the question again, AT WHAT COST. Because once you switch to software PWM using a timer you will discover that there are many other cheaper chips that would have done the same job.
2) using the resource available, had you of had these chips in a box hanging around then i would of agreed with you, however you failed to plan the project properly, infact i was always taught a saying that goes along these lines.. Proper Planning Prevents P##s Poor Performance!
Before posting again go back and study the diagram of the H bridge that LG kindly posted,
Next you NEED to understand what the CCP1 peripheral does, in the case of pwm it is designed for such things as the H bridge circuit for driving motors, therefore it will not give you more than one usable modulated output at a time (actually it will but you cant use it for what you want), its not that it's multiplexed, its because it is designed to do a certain job.
Stubbornly staying on the path you are currently on is going to make you feel and look foolish in the end, because despite not only being told it will not work but because several attempts have been made to make you understand exactly why it wont work.
ERASE from your mind the belief that somehow you will be able to make the four outputs work to simulate a candle, because they wont.
Resign yourself to the fact that it is time to pay attention to what is being said to you, especially by a young lad that has given you the solution on a plate that will give you the end result you want and use the resource available!
YOU can get a candle effect with that chip, BUT NOT THE WAY YOU INSIST on doing it. actually LG's maths for the timer are off slightly but what he outlined is correct.
you have 3 options at this point
1) continue with trying to get the pwm peripheral to work, in which case the cost is more because you have wasted every dime/penny on a chip that aint gonna do it that way
2) PWM using a timer, software PWM with one timer will work the effect will be acceptable to pretty good (and way better than results so far) the cost for this is higher than it needed to be because any old pic with a timer could be used!
3) total software PWM using nothing but program loops and updating variables
i put this as an option because i cant think of a single chip you couldnt have used, but realistically without an oscilloscope and decent maths and reasonable to good coding skills its harder than method 2
4) choice 4 is your choice i have no idea what it is but i am sure its the one you are going to pick.