1 2 Previous Next 25 Replies Latest reply on Aug 28, 2013 8:33 PM by fezhc_293666 Go to original post
• ###### 15. Re: A PWM Algorithm Realized With Only One Add Instruction

2. Edge-to-Edge interval

Software-PDM generator is desired to run in a Timer_ISR. The edges of 0-t0-1 or 1-to-0 are ensured by Timer (if it is accurate enough), not by instruction numbers as in example running in the main loop.

• ###### 17. Re: A PWM Algorithm Realized With Only One Add Instruction

(1) Only a part of this algorithm is shown in this topic above :

N, H (0...N-1) are positive integers.

For some numbers as N=2^m, we use AND-operator instead of mod-operator for faster processing.

And even no any mod-operator is needed for N=256(8-bit ALU),N=65536(16-bit 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 PDM-generator 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 Delta-Sigma Output.

Jitter? No problem. A low-pass 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

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

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 operation

5. A lot of people here is from non-English 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
When I say "people here is from non-English speaking country." acually means English is not their first language.
• ###### 21. Re: A PWM Algorithm Realized With Only One Add Instruction

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

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

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

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

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.

1 2 Previous Next