# Need Equation for PWM

Discussion in 'General Electronics' started by jack, Apr 12, 2005.

1. ### jackGuest

negative numbers and fractional exponents....however this isn't always
true, is it? X^(1/2) is a no-no for negative numbers (i.e. imaginary
result) but X^(1/3) is O.K. for negative numbers (real result). EXCEL
treats both of these these correctly (error for X^(1/2) and real number
for X^(1/3)). But EXCEL chokes on X^(2/3) for a negative number - this
should be O.K. (real number result) for negative numbers....right?

I will probably go with Equation 2, although how to incorporate duty
cycle into the equation is still perplexing me.

It's just a shame that a seemingly straightforward periodic function as
a square wave (+1,-1,+1,-1,.....) could not be expressed as a
straightforward function. If they can fake putting a man on the moon,
why can't they figure this one out?

2. ### Fred BloggsGuest

Well- if you know duty D and period T, then at any time t, the function
is +1 if FRACT(t/T)<=D and -1 if FRACT(t/T)>D. If you have an offset,
to, then use t-to for t in the above. How hard is that? Excel doesn't
allow logic coefficients in expressions?

3. ### jackGuest

I said:

Then you said:
I assume you are being a hyper-stickler because I did not explicitly
include a reference (Vo) voltage in my problem statement. Would you be

I think everyone else understood this as a given, which did not need to
be explicitly stated.

If this still doesn't satisfy you, then just do a Google search for
"voltage as a function of time" +"edu" and you will get a ga-zillion
hits showing how voltage can be expressed as a time function. Random
example from Bucknell Univ.:

http://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Signal/Signal2.htm

No, you're orthogonal.
Rather, I think you need to go back to Kindergarten and learn how not
to be a ball-breaker over something that is obvious.

4. ### jackGuest

Life is truly tough. It is made up of a series of trick problems.
In my original post I clearly indicated that I had done a fair amount
of due diligence and wasn't asking without having done some homework
already. The assumption in my original post was that there must be a
straigtforward answer and since high-powered math-oriented folk
frequent such internet groups, it might be a good place to ask....this
should be an easy question IF the answer is indeed straightforward.

Also, I did pay attention to the replies and patiently explained why
responses were off-target or not what I was looking for. Check out my
responses, I paid attention to all the replies and I always explained
myself.

5. ### jackGuest

Do you even know what a "square wave" is?
Suggest you contact each of the authors (all somehow associated with
educational institutions) of the approximately 745 web pages that show
up when you Google the terms +"voltage equation" +"edu" and tell them
they are "stupider than a joke"....

Semi-random example page...this doesn't exactly look "stupider than a
joke"...does it?

http://www.klab.caltech.edu/~stemmler/s1node1.html

6. ### jackGuest

Was trying to get an elegant equation that avoided such things as
special EXCEL functions, IF/THEN deals, piecewise deals (like
Heaviside) and infinite series.

7. ### numberdudeGuest

Jack,

Assuming your square wave oscillates from some voltage V+ to V- at some
frequency and duty cycle, here's a simple equation that will work. You *can*
implement an IF statement in Excel very easily. Here's the equation:

Given:
t = time in seconds
f = frequency in Hertz
d = duty cycle expessed as a decimal (e.g. 35% = 0.35)

IF = tf - INT(tf) < d/f THEN V(t,f,d) = V+ ELSE V(t,f,d) = V-

The INT function in Excel returns the whole number portion and drops the
decimal part.

tf - INT(tf) gives the fraction of the last wave completed after t seconds.
d/f gives the fraction of a cycle where the voltage is V+. If the first
fraction is less than the second, the voltage is V+. Otherwise it's V-.

Hopes this helps.

Allen

8. ### jackGuest

Thank you very much.....I appreciate it.

9. ### Dave RusinGuest

Maybe. Some would say (-1)^(1/3) = (-1/2) + i sqrt(3)/2.
Maybe. Some would say that -- with the exception of integer n , perhaps --
the right definition of X^n is exp( n log(X) ), which forces such
people to add "... for positive X only."
Oh, we can fake this too. What you want is the straightforward function
f(x) = squarewave(x). You got a problem with that? Most mathematicians
would probably accept that answer. (Maybe after a beer or two.)

You could also opt for f(x) = sin(x) / |sin(x)| or f(x) = (-1)^floor(x) .
Much depends on what you're trying to accomplish. (You might already
have said; I haven't been paying attention, sorry.)

dave

10. ### Guest

I don't have a formula, but I do have a simple approach:
If all you want is to know whether the signal (Vinst) is
hi or low at any given instant, it is a simple divide and compare.

From the frequency and duty cycle you compute total time
for the cycle, and determine the "on time" from the duty cycle.
Assume your pulse is positive going at time Tsubzero:
Divide Tsubn by total time. If there is no remainder, the ampltude
is at Tsubzero amplitude - high. If there is a remainder, and the
remainder is greater than the "on time" the signal is low.
If the remainder is less than or equal to the "on time" , the signal is
high.
Tsubzero, it still works, but you have to invert the highs
and lows in the description.

Ed

11. ### numberdudeGuest

Jack,

You're welcome. By the way, I noticed that I put an equals sign after the
IF. It shouldn't be there.

Allen

12. ### MGGuest

Small correction to function parameters (arguments).
Period is required, Phase is optional or default to zero.
A (V) = f{t (sec), duty cycle (%), Period, Phase(%)}

MG  