
15. Re: A PWM Algorithm Realized With Only One Add Instruction
fezhc_293666 Jul 24, 2013 9:53 PM (in response to fezhc_293666)2. EdgetoEdge interval
SoftwarePDM generator is desired to run in a Timer_ISR. The edges of 0t01 or 1to0 are ensured by Timer (if it is accurate enough), not by instruction numbers as in example running in the main loop.

16. Re: A PWM Algorithm Realized With Only One Add Instruction
fezhc_293666 Jul 24, 2013 9:54 PM (in response to fezhc_293666) 
17. Re: A PWM Algorithm Realized With Only One Add Instruction
fezhc_293666 Jul 24, 2013 9:55 PM (in response to fezhc_293666)4. More about this algorithm
(1) Only a part of this algorithm is shown in this topic above :
N, H (0...N1) are positive integers.
For some numbers as N=2^m, we use ANDoperator instead of modoperator for faster processing.
And even no any modoperator is needed for N=256(8bit ALU),N=65536(16bit ALU),and so on.
(2) a little more  for software implementation only.
For n=1 and any positive real number h in [0,1), for example , h=0.123456789...or h= a fraction, and even h=1/pi or h=sqroot(1/2).
For positive real number Remainder with arbitrary initial value in [0,1), the software PDMgenerator is as following:
Timer_ISR:
...
Remainder += h;
if (Remainder >= 1)
{ Pout = 1 ; Remainder = 1 ;}
else Pout = 0 ;
...
END of Timer_ISR
Cutting a fragment with any length(N) at any point from the output pulse train, and counting the 1's number(H) in this fragment, you can find , that the ratio H/N is always the best fraction approximation of the real number h (comparing with same denominator N).
Sometime I called it as Software DeltaSigma Output.
Jitter? No problem. A lowpass filter is waiting at output port.
A jitter is not always bad. Sometime, jitter will cut the noise peak and spread it.

18. Re: A PWM Algorithm Realized With Only One Add Instruction
fezhc_293666 Jul 24, 2013 9:56 PM (in response to fezhc_293666)5. I'll continue my blog about this PDMalgorithm in Chinese.
All of you are welcome to visit and discuss there.
If I can't express my opinion in English, I can use Chinese there.
If I made any typo, I can edit it. I made many typos here, but I can't correct it, because Cypress Forum has no edit tool.

19. Re: A PWM Algorithm Realized With Only One Add Instruction
ki.leung Jul 25, 2013 12:01 AM (in response to fezhc_293666)1. a. Using timer interrupt to perform the operation is better. I think we were discussing with what you presented which is software instruction only.
b. I did program chips with 64 nibbles(not bytes) of RAM, no interrupt, 1 level of stack. and every function cannot be longer then 64 bytes. So I understand the need for these cleaver tricks.
2. See 1.a
3. Analog voltage generation is one of the application of PWM, the jitter is not a problem
for this usage, but may cause problem in other situations.
Again, using for LED driver is not a problem because the eye does the filtering.
4. a. See 1.a
b. Yes, it is like a delta sigma operation5. A lot of people here is from nonEnglish speaking country, so don't worry.
If we don't understand we would ask question to clarify.
Editing function has been requested for a long time already.

20. Re: A PWM Algorithm Realized With Only One Add Instruction
ki.leung Jul 25, 2013 8:43 AM (in response to fezhc_293666)When I say "people here is from nonEnglish speaking country." acually means English is not their first language. 
21. Re: A PWM Algorithm Realized With Only One Add Instruction
fezhc_293666 Jul 28, 2013 3:53 PM (in response to fezhc_293666)The Priciple of The PWM Algorithm Based On Addition
 A PDM Algorithm Based On Addition (2)
http://blog.chinaaet.com/detail/33392.html in Chinese.

22. Re: A PWM Algorithm Realized With Only One Add Instruction
fezhc_293666 Aug 7, 2013 3:45 PM (in response to fezhc_293666)Hardware PWM vs Hardware PDM Based On Addition
 A PDM Algorithm Based On Addition (3)
http://blog.chinaaet.com/detail/33470.html in Chinese.

23. Re: A PWM Algorithm Realized With Only One Add Instruction
fezhc_293666 Aug 14, 2013 4:42 PM (in response to fezhc_293666)How to Realize the Hardware PDM with PSoC UDB
 A PDM Algorithm Based On Addition (4)
http://blog.chinaaet.com/detail/33508.html in Chinese.

24. Re: A PWM Algorithm Realized With Only One Add Instruction
user_264321 Aug 15, 2013 10:08 AM (in response to fezhc_293666)Nice Write up fyzhu, quite interesting use.
in chineese but fortunatelly there is chrome autotranslation :)

25. Re: A PWM Algorithm Realized With Only One Add Instruction
fezhc_293666 Aug 28, 2013 8:33 PM (in response to fezhc_293666)The Origin Of The PDM Algorithm Based On Addition
 A PDM Algorithm Based On Addition (5)
http://blog.chinaaet.com/detail/33600.html in Chinese.