%!
% POSTSCRIPT RMS VALUE FINDER
% ===================================================================
% by Don Lancaster February 28, 1997
% ===================================================================
% Copyright c 1997 by Don Lancaster and Synergetics, Box 809,
% Thatcher AZ, 85552. (520) 428-4073 www.tinaja.com don@tinaja.com
% All commercial rights and all electronic media rights are
% *fully* reserved. Linking welcome. Reposting expressly forbidden.
% ===================================================================
% Two-way recordable PostScript comm is **REQUIRED** for these utilities.
% ===================================================================
% Unusual waveforms often produce surprisingly low average current or voltage
% values. Especially waveforms having a low duty cycle. If such a waveform is
% measured with an average responding meter or VOM, wildly low readings will
% result. Leading to bizarre conclusions involving efficiency or power.
% This PostScript routine takes an arbitrary waveform and then calculates
% the normalized and scaled average current or voltage, the scaled rms
% current or voltage, and their ratio.
% Modify the code that follows with a suitable editor. Then route it to any
% PostScript device that offers TWO WAY RECORDABLE COM. Such as a PostScript
% printer communicating Ethernet, Appletalk, serially, or the new BIDIRETIONAL
% parallel. GhostScript can also be used on host.
% The fastest and sneakiest way to run this code is to send it to the Acrobat
% Distiller. Then throw away the generated .PDF file and view the LOG file for
% your results! Note that reporting times will be somewhat slower this way.
% default variables
/scaleamp 117 2 sqrt mul def % use a 117 volt ac cycle
/startang 0 def % set limits
/stopang 180 def %
/endang 360 def %
/res 0.1 def % step resolution in degrees
% Assume a ONE OHM load. Generate a normalized array holding the desired
% waveform values...
% This particular routine optimizes for ac power phase control. Any array
% of values normalized to peak = 1 can be substituted...
/makewaveform {/waveform mark
0 res endang {/ang exch store
ang startang gt
ang stopang lt and {ang sin} {0} ifelse
} for
] def } def
% do the actual rms and average calculations on the waveform array...
/findrms1 { 0 waveform {add } forall waveform length div
/normaverage exch store
0 waveform {dup mul add} forall waveform length div
sqrt /normrms exch store
normrms normaverage dup 0 eq {pop 0.000001} if div
/normratio exch store} def
% report the results...
/crlf true def % IBM or sanity?
/return {(\r) print crlf {(\n) print} if} def
/reportrms {
return return
(The average normalized waveform value is ) print
normaverage 20 string cvs print
return return
(The rms normalized waveform value is ) print
normrms 20 string cvs print
(.) print return
(The ratio of rms to average is ) print
normratio 20 string cvs print
(.) print return return
(The average scaled waveform value is ) print
normaverage scaleamp mul 20 string cvs print
(.) print return return
(The rms scaled waveform value is ) print
normrms scaleamp mul 20 string cvs print
(.) print return
return return
} def
/findrms {findrms1 reportrms} def % convenience linker
flush
%%%%%%%%% demos - remove or alter before reuse %%%%%%%%%%%%%%%%%%
% (A) Find the rms and average values for half a sinewave...
/res 0.1 def % 0.1 degree accuracy
/startang 0 def % start at beginning
/stopang 180 def % go to the end of...
/endang 180 def % half an ac cycle
/scaleamp 117 2 sqrt mul def % use a 117 volt ac cycle
makewaveform
findrms
% should return the expected values of...
%% The average normalized waveform value is 0.636619.
%% The rms normalized waveform value is 0.707108.
%% The ratio of rms to average is 1.11072.
%% The average scaled waveform value is 105.337.
%% The rms scaled waveform value is 117.0.
% Which are very close to the theoretical values.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (B) Find the rms and average values for a triac that conducts only from
% 150 to 180 degrees of a full ac line cycle
/res 0.1 def % 0.1 degree accuracy
/startang 150 def % start at turnon angle
/stopang 180 def % go to the end of half cycle
/endang 180 def % stop at full ac cycle
/scaleamp 117 2 sqrt mul def % use a 117 volt ac cycle
makewaveform
findrms
% should give results of...
%% The average normalized waveform value is 0.021252.
%% The rms normalized waveform value is 0.0846966.
%% The ratio of rms to average is 3.98534.
%% The average scaled waveform value is 3.51642.
%% The rms scaled waveform value is 14.0142.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (C) Plot the rms voltage versus phase angle for a triac that conducts only
% a portion of each ac half cycle
/res 0.1 def % 0.1 degree accuracy
/startang 0 def % start at turnon angle
/stopang 180 def % go to the end of half cycle
/endang 180 def % stop at one half ac cycle
/scaleamp 117 2 sqrt mul def % use a 117 volt ac cycle
0 10 180 { /startang exch store
(The phase angle is ) print
startang 20 string cvs print
( degrees.) print return
makewaveform
findrms} for
% should return these edited results...
%% The phase angle is 0 degrees.
%% The rms voltage is 117.0.
%% The ratio of rms to average is 1.11072.
%%
%% The phase angle is 10 degrees.
%% The rms voltage is 116.936.
%% The ratio of rms to average is 1.11852.
%%
%% The phase angle is 20 degrees.
%% The rms voltage is 116.488.
%% The ratio of rms to average is 1.14006.
%%
%% The phase angle is 30 degrees.
%% The rms voltage is 115.309.
%% The ratio of rms to average is 1.17299.
%%
%% The phase angle is 40 degrees.
%% The rms voltage is 113.091.
%% The ratio of rms to average is 1.21622.
%%
%% The phase angle is 50 degrees.
%% The rms voltage is 109.671.
%% The ratio of rms to average is 1.26805.
%%
%% The phase angle is 60 degrees.
%% The rms voltage is 104.915.
%% The ratio of rms to average is 1.32866.
%%
%% The phase angle is 70 degrees.
%% The rms voltage is 98.7891.
%% The ratio of rms to average is 1.39851.
%%
%% The phase angle is 80 degrees.
%% The rms voltage is 91.3392.
%% The ratio of rms to average is 1.47872.
%%
%% The phase angle is 90 degrees.
%% The rms voltage is 82.6861.
%% The ratio of rms to average is 1.57131.
%%
%% The phase angle is 100 degrees.
%% The rms voltage is 73.0175.
%% The ratio of rms to average is 1.67944.
%%
%% The phase angle is 110 degrees.
%% The rms voltage is 62.5814.
%% The ratio of rms to average is 1.80811.
%%
%% The phase angle is 120 degrees.
%% The rms voltage is 51.6775.
%% The ratio of rms to average is 1.96535.
%%
%% The phase angle is 130 degrees.
%% The rms voltage is 40.6507.
%% The ratio of rms to average is 2.16476.
%%
%% The phase angle is 140 degrees.
%% The rms voltage is 29.8877.
%% The ratio of rms to average is 2.43144.
%%
%% The phase angle is 150 degrees.
%% The rms voltage is 19.819.
%% The ratio of rms to average is 2.81806.
%%
%% The phase angle is 160 degrees.
%% The rms voltage is 11.0204.
%% The ratio of rms to average is 3.4529.
%%
%% The phase angle is 170 degrees.
%% The rms voltage is 3.94639.
%% The ratio of rms to average is 4.88476.
%%
%% The phase angle is 180 degrees.
%% The rms voltage is 0.0.
%% The ratio of rms to average is undefined.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (D) Plot the rms voltage versus phase angle for triac that conducts only
% a portion of the positive half of each ac full cycle...
/res 0.1 def % 0.1 degree accuracy
/startang 0 def % start at turnon angle
/stopang 180 def % go to the end of half cycle
/endang 360 def % stop at one half ac cycle
/scaleamp 117 2 sqrt mul def % use a 117 volt ac cycle
0 10 180 { /startang exch store
(The phase angle is ) print
startang 20 string cvs print
( degrees.) print return
makewaveform
findrms} for
% should return these edited results...
%%
%% The phase angle is 0 degrees.
%% The rms scaled waveform value is 82.7316.
%% The ratio of rms to average is 1.5708.
%%
%% The phase angle is 10 degrees.
%% The rms scaled waveform value is 82.6859.
%% The ratio of rms to average is 1.58183.
%%
%% The phase angle is 20 degrees.
%% The rms scaled waveform value is 82.3692.
%% The ratio of rms to average is 1.61229.
%%
%% The phase angle is 30 degrees.
%% The rms scaled waveform value is 81.536.
%% The ratio of rms to average is 1.65886.
%%
%% The phase angle is 40 degrees.
%% The rms scaled waveform value is 79.9671.
%% The ratio of rms to average is 1.72.
%%
%%
%% The phase angle is 50 degrees.
%% The rms scaled waveform value is 77.5489.
%% The ratio of rms to average is 1.79329.
%%
%% The phase angle is 60 degrees.
%% The rms scaled waveform value is 74.186.
%% The ratio of rms to average is 1.87901.
%%
%% The phase angle is 70 degrees.
%% The rms scaled waveform value is 69.8544.
%% The ratio of rms to average is 1.97779.
%%
%% The phase angle is 80 degrees.
%% The rms scaled waveform value is 64.5866.
%% The ratio of rms to average is 2.09123.
%%
%% The phase angle is 90 degrees.
%% The rms scaled waveform value is 58.4679.
%% The ratio of rms to average is 2.22216.
%%
%% The phase angle is 100 degrees.
%% The rms scaled waveform value is 51.6312.
%% The ratio of rms to average is 2.37508.
%%
%% The phase angle is 110 degrees.
%% The rms scaled waveform value is 44.2517.
%% The ratio of rms to average is 2.55705.
%%
%% The phase angle is 120 degrees.
%% The rms scaled waveform value is 36.5415.
%% The ratio of rms to average is 2.77942.
%%
%% The phase angle is 130 degrees.
%% The rms scaled waveform value is 28.7444.
%% The ratio of rms to average is 3.06143.
%%
%% The phase angle is 140 degrees.
%% The rms scaled waveform value is 21.1338.
%% The ratio of rms to average is 3.43857.
%%
%% The phase angle is 150 degrees.
%% The rms scaled waveform value is 14.0142.
%% The ratio of rms to average is 3.98534.
%%
%% The phase angle is 160 degrees.
%% The rms scaled waveform value is 7.79263.
%% The ratio of rms to average is 4.88314.
%%
%% The phase angle is 170 degrees.
%% The rms scaled waveform value is 2.79052.
%% The ratio of rms to average is 6.90809.
%%
%% The phase angle is 180 degrees.
%% The rms scaled waveform value is 0.0.
%% The ratio of rms to average is undefined.
%%
% Consider a phase angle somewhere around 125 degrees. The rms voltage will
% be 32.0 and thus will fully light a 32 volt lamp. The RMS to average ratio
% is approximately 2.9. Meaning that an average voltage reading would be 11.0.
% But a typical average reading meter fudges its results by 1.11 to make full
% sinewaves come out correctly. Thus, the pointer would point to 12.2, or
% slightly above twelve volts. And the virtual error would be 32/12.2 = 2.61.
% If a twelve volt reading was claimed for full brilliance of a 32 volt lamp,
% then an average reading device is almost certainly in use. The other
% alternate is a lamp that is lit to a dull orange glow.
% If the same instrument was used to measure current, and if "power" was
% found by multiplying average volts times average amps, then the virtual
% "power" error would SQUARE. Thus 2.61 x 2.61 = 6.83. An "efficiency"
% improvement of almost SEVEN TIMES could then be claimed by the wrong
% use of the wrong readings.
% A simple test for a real seven times efficiency improvement is to touch
% the bulb. If the efficiency is real, the bulb should be ridiculously cooler.
% The efficiency of any incandescent lamp can be raised simply by raising
% its voltage above spec. But doing so *dramatically* lowers lamp life.
% Double the voltage and the life goes down by 128!
flush
% %%%%%%%%%%%%%%% END POSTSCRIPT RMS FINDER %%%%%%%%%%%%%%%%%%%%%%
% Consulting services available on concepts shown.
% ===================================================================
% Copyright c 1997 by Don Lancaster and Synergetics, Box 809,
% Thatcher AZ, 85552. (520) 428-4073 www.tinaja.com don@tinaja.com
% All commercial rights and all electronic media rights are
% *fully* reserved. Linking welcome. Reposting expressly forbidden.
% ===================================================================