Thursday, September 27, 2018

Plot Smith Chart Data in 3-D with MATLAB


MATLAB is a wonderful tool for the capture, analysis, and display of data.  And their Home version provides an inexpensive way for the casual user (such as myself) to utilize its analytical power.

While analyzing Antenna Tuner power dissipation, I thought it would be great to have some way to visually represent, on a Smith Chart, the value of the tuner power dissipation versus the tuner's load.

Plotting this data in color or 3-D could provide an excellent visual representation, I thought, but how to do it?

I first attempted to use MATLAB's smithchart() function (in their RF Toolbox) with their surfc() function, but without success.

Fortunately, Dick Benson (W1QG) had written his own Smith Chart function (having been frustrated with the one provided in the RF Toolbox), and he showed me how his function could be used for my requirements

Below is an example.  It is a plot displaying power loss in low-pass L-networks, given component Q (and calculating the L and C values for a 1:1 match) for SWRs from 1:1 to 10:1.  Thus, the outer "rim" of the data corresponds to the impedances of L-network loads lying on a Smith Chart's 10 to 1 SWR circle.


Contour lines (that match the index marks on the right-hand color bar scale) are also displayed.

This plot can be rotated in 3-D space:


Dick's enhanced Smith Chart function (smith_rab_v2.m) is available on the MATLAB file-central website in his S-Parameter Utilities zip file.  This file includes a documentation PDF.

But Dick's documentation only describes normal "2-D" plots.  To plot in 3-D, we need to use another MATLAB function, surfc():

surfc

Contour plot under a 3-D shaded surface plot

Syntax

surfc(Z)
surfc(Z,C)
surfc(X,Y,Z)
surfc(X,Y,Z,C)
surfc(...,'PropertyName',PropertyValue)
surfc(axes_handles,...)
h = surfc(...)

Description

surfc(Z) creates a contour plot under the three-dimensional shaded surface from the z components in matrix Z, using x = 1:n and y = 1:m, where[m,n] = size(Z). The height, Z, is a single-valued function defined over a geometrically rectangular grid. Z specifies the color data, as well as surface height, so color is proportional to surface height.
surfc(Z,C) plots the height of Z, a single-valued function defined over a geometrically rectangular grid, and uses matrix C, assumed to be the same size as Z, to color the surface.
surfc(X,Y,Z) uses Z for the color data and surface height. X and Y are vectors or matrices defining the x and y components of a surface. If X and Yare vectors, length(X) = n and length(Y) = m, where [m,n] = size(Z). In this case, the vertices of the surface faces are (X(j), Y(i), Z(i,j)) triples. To create X and Y matrices for arbitrary domains, use the meshgrid function.
surfc(X,Y,Z,C) uses C to define color. MATLAB® performs a linear transformation on this data to obtain colors from the current colormap.
surfc(...,'PropertyName',PropertyValue) specifies surface properties along with the data.
surfc(axes_handles,...) plots into the axes with handle axes_handle instead of the current axes (gca).
h = surfc(...) returns handles to a chart surface and a contour object.

3-D Plotting using smith_rab_v2.m:

Below is the code to create a Smith Chart plot of data in 3-D.  Note that it invokes surfc in the form surfc(X,Y,Z), per the description, above.

% Plot 3-d smith chart

% First, set Smith Chart parameters for smith_rab_v2.m,
% per its documentation:

LW=2;  % Line Width
SP.Rvalues=[0 10 25 50 100 250];   % SP.*= Smith Parameters
SP.Xvalues=[10 25 50 100 200 500];
SP.Zo=50;
SP.Nseg=60;
SP.LW  = 1;                 % LW= line width for Smith coordinates
SP.swr_circles = [];        % set to [] for no SWR circles
SP.LW_swr = 2;              % LW= line width for SWR Circles

SP.colors.grid   = [1 1 0]*0.5;       % coordinate lines
SP.colors.fill   = [0,0,0];           % background
SP.colors.inner_text = [1 1 0];       % inner labels
SP.colors.outer_text = [1 1 0];       % outer labels
SP.colors.swr    = [1 0 0];           % swr circle color
SP.colors.Q      = [0 0 1];           % Q contour color

SP.Q_contours    = [];
SP.Q_pts         = [];  % number of points in a Q contour
SP.LW_Q          = 1;

my_color_choice = [0.5 0.5 0.5];

% And now, PLOT!
handles.figure(4)     = figure('NumberTitle','Off',...
                        'Name', ' Match Space',...
                        'color',my_color_choice,...
                        'Position',[380 300 756 695]);
handles.Axes_Smith(4) = axes;
handles.smith(4)      = smith_rab_v2(handles.Axes_Smith(4),SP);
set(handles.Axes_Smith(4),'visible','on',...
                          'Xcolor',my_color_choice,...
                          'Ycolor',my_color_choice,...
                          'Zcolor',SP.colors.outer_text);
zlabel(['Gp Power Loss in PERCENT']);
title(handles.Axes_Smith(4),['Gp Percent Power Loss'],'Color',[1 1 0]);
colormap jet;

handles.cb(1)=colorbar;
set(handles.cb(1),'Color', SP.colors.outer_text,...
                  'FontWeight','Bold');
set(handles.cb(1).Label,'String','Percent Power Loss',...
                  'Color',SP.colors.outer_text,...
                  'FontWeight','Bold');

handles.surf(1,:) = surfc(real_gamma,imag_gamma,Percent_Loss);
set(handles.surf(1,1),'Edgecolor','none',...
                      'FaceAlpha',0.5,...
                      'LineStyle','none');
set(handles.surf(1,2),'Linewidth',2);  % nice fat contours lines!

sinfo = {['Ql : ',num2str(Q_L)],...
         ['Qc : ',num2str(Q_C)]};

ht=text(-1,1,15,sinfo);
set(ht,'Color',[0 1 0],'FontSize',12)
 
Notes on the plotting code, above:

1.  The code begins by customizing the Smith Chart plot parameters for smith_rab_v2.m (refer to the documentation PDF contained in the  S-Parameter Utilities download).

2.  The actual 3-D plot is made using MATLAB's surfc.  In the script below, I call surfc in the form of surfc(X,Y,Z):

handles.surf(1,:) = surfc(real_gamma,imag_gamma,Percent_Loss);
where, given the function's input variable's X, Y, Z (i.e. surfc(X,Y,Z)):  
  • X = real_gamma (i.e. an array containing the Cartesian x-coordinates of gamma (in this particular example, the array is a 2-D matrix)).
  • Y = imag_gamma (i.e. an array containing the Cartesian y-coordinates of gamma (in this particular example, the array is a 2-D matrix)).
  • Z = the percent value of power loss for each x,y pair.  This data is also an array, and in this particular example it is a 2-D matrix whose dimensions are the same as the real_gamma and the imag_gamma matrices.
3.  Note that to be able to view the Smith Chart axes that lie beneath the 3-D surface overlay, the plotted surface must be transparent.  Transparency is set via the 'FaceAlpha' parameter in the line:

set(handles.surf(1,1),'Edgecolor','none',...
                      'FaceAlpha',0.5,...
                      'LineStyle','none');
4.  The parameter 'colormap' determines what colors that data values should be mapped into.  The map I've used is the predefined 'jet' map, which colors the data from blue for the lowest values of data to red for the highest values.

5.  Hopefully the code is self-explanatory.  But if something is puzzling, note that MATLAB provides excellent documentation of their functions, which you can either google (e.g. google 'Matlab surfc') or invoke by using the 'doc' command in MATLAB's workspace (e.g. type 'doc surfc' in the Workspace command line).


Applying 3-D Plotting:

Below is the complete MATLAB script I used to generate the power-dissipation data I've displayed, above.  This code analyzes both the series-L/parallel-C and parallel-C/series-L (LsCp and CpLs) low-pass configurations of two-element lossy L-Networks.

I do this by calculating the L-network L and C values required to match various loads to 50 ohms, given frequency and component Qs.  (Please refer to this post for the equations used for calculating L and C, and their derivation:
http://k6jca.blogspot.com/2018/09/l-networks-new-equations-for-better.html

The load impedances were calculated from gamma found while stepping around various Smith Chart "circles of constant SWR" in 2 degree increments.  L and C was then calculated for each impedance, and from these values (and their Qs), L-network power dissipation was calculated and plotted.

The code responsible for plotting the data is at the end of the listing.

 (Let me add -- unlike Dick, who is a true MATLAB expert, I am a MATLAB dilettante, which I am sure is reflected in my code, below.  MATLAB experts undoubtedly will find better ways of implementing what I have attempted to do).

% Plot power loss of a low-pass L-Network
% around circles of constant swr.
% k6jca

clear all
close all
clc

% The Givens:

F = 3.5e6;
Zo = 50;
Rsource = Zo;
Xsource = 0;
Q_L = 100;
Q_C = 100;

% Define the SWRs of the circles that will be plotted.
swr_array = [10 9 8.5 8 7.5 7 6.5 6 5.5 5 4.5 4 3.5...
              3 2.5 2 1.8 1.6 1.4 1.2 1.1 1.05];

% Will plot a point every 2 degrees around the SWR,
% So that delta, in radians, is:
radian_delta = 2*pi/180;
w = 2*pi*F;


for swr_index = 1:length(swr_array)
    swr = swr_array(swr_index);
    rho = (swr-1)/(swr+1);
    for i = 1:181  % plotting 360 degrees
        % calculate the real and imaginary components of gamma.
        % (i.e. the x and y coordinates of each data point).
        real_gamma(swr_index,i) = rho*cos(radian_delta*(i-1));
        imag_gamma(swr_index,i) = rho*sin(radian_delta*(i-1));
        % from gamma, calculate Zload (and its real and imaginary
        % parts.
        Rld(i) = Zo*(1 - real_gamma(swr_index,i)^2 - imag_gamma(swr_index,i)^2)/((1 - real_gamma(swr_index,i))^2 + imag_gamma(swr_index,i)^2);
        Xld(i) = Zo*2*imag_gamma(swr_index,i)/((1 - real_gamma(swr_index,i))^2 + imag_gamma(swr_index,i)^2);
        Zld(i) = Rld(i) + 1i*Xld(i);

        % Given Zload, Zsource (which is 50 ohms here), Ql and Qc,
        % calculate the XL and XC values of the LsCp or CpLs network
        % than will match Zload to Zsource, using the equations
        % developed with MATLAB's Symbolic Match toobox (and
        % subsequently placed into the function calls, below).
        %
        % Note that for an LsCp network, these equations return
        % two XL and two XC terms.  Ditto for the CpLs network.
        [LsCp_XL(i,:), LsCp_XC(i,:)] = ser_L_shunt_C_Q_3(Rld(i),Xld(i),Rsource,Xsource,Q_L,Q_C);
        [CpLs_XL(i,:), CpLs_XC(i,:)] = shunt_C_ser_L_Q_3(Rld(i),Xld(i),Rsource,Xsource,Q_L,Q_C);

        % Of the four pairs of XL and XC terms returnd by the
        % two functions,(each function call returns two pairs),
        % only one pair is valid.  This pair will have
        % no imaginary components (that is, neither XL nor
        % XC is a complex number),
        % and both XL and XC will be positive.
        %
        % So let's first march through all 8 values of XL and XC and
        % identify any that are both real (not complex) AND positive.
        if(isreal(LsCp_XL(i,1)) && real(LsCp_XL(i,1)) > 0)
            itsValid(i,1) = 1;
        else
            itsValid(i,1) = 0;
        end
        if(isreal(LsCp_XL(i,2)) && real(LsCp_XL(i,2)) > 0)
            itsValid(i,2) = 1;
        else
            itsValid(i,2) = 0;
        end
        if(isreal(LsCp_XC(i,1)) && real(LsCp_XC(i,1)) > 0)
            itsValid(i,3) = 1;
        else
            itsValid(i,3) = 0;
        end
        if(isreal(LsCp_XC(i,2)) && real(LsCp_XC(i,2)) > 0)
            itsValid(i,4) = 1;
        else
            itsValid(i,4) = 0;
        end
        if(isreal(CpLs_XL(i,1)) && real(CpLs_XL(i,1)) > 0)
            itsValid(i,5) = 1;
        else
            itsValid(i,5) = 0;
        end
        if(isreal(CpLs_XL(i,2)) && real(CpLs_XL(i,2)) > 0)
            itsValid(i,6) = 1;
        else
            itsValid(i,6) = 0;
        end
        if(isreal(CpLs_XC(i,1)) && real(CpLs_XC(i,1)) > 0)
            itsValid(i,7) = 1;
        else
            itsValid(i,7) = 0;
        end
        if(isreal(CpLs_XC(i,2)) && real(CpLs_XC(i,2)) > 0)
            itsValid(i,8) = 1;
        else
            itsValid(i,8) = 0;
        end

        % Next, we are looking for "pairs" of XL and XC that are valid.
        % Only one pair should be valid.  The other three pairs should
        % be invalid.
        % For example, let's first check XL(1) and XC(1) for LsCp networks
        % and see if both are valid...
        LsCp(i) = 0;
        if(itsValid(i,1) && itsValid(i,3))    % XL(1), XC(1), LsCp netwrk
            LsCp(i) = 1;
            XL(i) = LsCp_XL(i,1);
            XC(i) = LsCp_XC(i,1);
        elseif(itsValid(i,2) && itsValid(i,4)) % XL(2), XC(2), LsCp netwrk
            LsCp(i) = 1;
            XL(i) = LsCp_XL(i,2);
            XC(i) = LsCp_XC(i,2);
        elseif(itsValid(i,5) && itsValid(i,7)) % XL(1), XC(1), CpLs netwrk
            XL(i) = CpLs_XL(i,1);
            XC(i) = CpLs_XC(i,1);
        elseif(itsValid(i,6) && itsValid(i,8)) % XL(2), XC(2), CpLs netwrk
            XL(i) = CpLs_XL(i,2);
            XC(i) = CpLs_XC(i,2);
        else
            % if there are no valid pairs...
            LsCp(i) = 2  % just a flag to id where the problem is.
            swr
            i
            disp('huh?');
        end

        % from XL and XC, calculate Ls and Cp
        Ls(i) = XL(i)/w;
        Cp(i) = 1/(XC(i)*w);

        % and calculate the S-parameters based upon whether the valid pair
        % is for an LsCp network or a CpLs network...
        if(LsCp(i))
            Spar = S_LsCp(Ls(i),Q_L,Cp(i),Q_C, Zo, F);
        else
            Spar = S_CpLs(Ls(i),Q_L,Cp(i),Q_C, Zo, F);
        end

        % With the s-parameters and Zload, calculate power loss
        Gp_Lnet(i) = powergain(Spar,Zo,Zld(i),'Gp');
        dBLoss(i) = 10*log10(Gp_Lnet(i));
        Percent_Loss(swr_index,i) = (1-Gp_Lnet(i))*100;

    end;

end

% Plot 3-d smith chart

% First, set Smith Chart parameters for smith_rab_v2.m,
% per its documentation:

LW=2;  % Line Width
SP.Rvalues=[0 10 25 50 100 250];   % SP.*= Smith Parameters
SP.Xvalues=[10 25 50 100 200 500];
SP.Zo=50;
SP.Nseg=60;
SP.LW  = 1;                 % LW= line width for Smith coordinates
SP.swr_circles = [];        % set to [] for no SWR circles
SP.LW_swr = 2;              % LW= line width for SWR Circles

SP.colors.grid   = [1 1 0]*0.5;       % coordinate lines
SP.colors.fill   = [0,0,0];           % background
SP.colors.inner_text = [1 1 0];       % inner labels
SP.colors.outer_text = [1 1 0];       % outer labels
SP.colors.swr    = [1 0 0];           % swr circle color
SP.colors.Q      = [0 0 1];           % Q contour color

SP.Q_contours    = [];
SP.Q_pts         = [];  % number of points in a Q contour
SP.LW_Q          = 1;

my_color_choice = [0.5 0.5 0.5];

% And now, PLOT!
handles.figure(4)     = figure('NumberTitle','Off',...
                        'Name', ' Match Space',...
                        'color',my_color_choice,...
                        'Position',[380 300 756 695]);
handles.Axes_Smith(4) = axes;
handles.smith(4)      = smith_rab_v2(handles.Axes_Smith(4),SP);
set(handles.Axes_Smith(4),'visible','on',...
                          'Xcolor',my_color_choice,...
                          'Ycolor',my_color_choice,...
                          'Zcolor',SP.colors.outer_text);
zlabel(['Gp Power Loss in PERCENT']);
title(handles.Axes_Smith(4),['Gp Percent Power Loss'],'Color',[1 1 0]);
colormap jet;

handles.cb(1)=colorbar;
set(handles.cb(1),'Color', SP.colors.outer_text,...
                  'FontWeight','Bold');
set(handles.cb(1).Label,'String','Percent Power Loss',...
                  'Color',SP.colors.outer_text,...
                  'FontWeight','Bold');

handles.surf(1,:) = surfc(real_gamma,imag_gamma,Percent_Loss);
set(handles.surf(1,1),'Edgecolor','none',...
                      'FaceAlpha',0.5,...
                      'LineStyle','none');
set(handles.surf(1,2),'Linewidth',2);  % nice fat contours lines!

sinfo = {['Ql : ',num2str(Q_L)],...
         ['Qc : ',num2str(Q_C)]};

ht=text(-1,1,15,sinfo);
set(ht,'Color',[0 1 0],'FontSize',12)
 



Downloading MATLAB functions for Plotting VNA Data:

Dick Benson's MATLAB functions and Utilities can be downloaded from his page in the MathWorks file exchange section:  Dick Benson MATLAB files.

Note that his enhanced Smith Chart function is in the "S-Parameter Utilities" (version 1.0.1) zip file.  A documentation PDF is included in the download.


Antenna Tuner Blog Posts:

A quick tutorial on Smith Chart basics:
http://k6jca.blogspot.com/2015/03/a-brief-tutorial-on-smith-charts.html

Plotting Smith Chart Data in 3-D:
http://k6jca.blogspot.com/2018/09/plotting-3-d-smith-charts-with-matlab.html

The L-network:
http://k6jca.blogspot.com/2015/03/notes-on-antenna-tuners-l-network-and.html

A correction to the usual L-network design constraints:
http://k6jca.blogspot.com/2015/04/revisiting-l-network-equations-and.html

Calculating L-Network values when the components are lossy:
http://k6jca.blogspot.com/2018/09/l-networks-new-equations-for-better.html

A look at highpass T-Networks:
http://k6jca.blogspot.com/2015/04/notes-on-antenna-tuners-t-network-part-1.html

More on the W8ZR EZ-Tuner:
http://k6jca.blogspot.com/2015/05/notes-on-antenna-tuners-more-on-w8zr-ez.html  (Note that this tuner is also discussed in the highpass T-Network post).

The Elecraft KAT-500:
http://k6jca.blogspot.com/2015/05/notes-on-antenna-tuners-elecraft-kat500.html

The Nye Viking MB-V-A tuner and the Rohde Coupler:
http://k6jca.blogspot.com/2015/05/notes-on-antenna-tuners-nye-viking-mb-v.html

The Drake MN-4 Tuner:
http://k6jca.blogspot.com/2018/08/notes-on-antenna-tuners-drake-mn-4.html


Standard Caveat:

As always, I might have made a mistake in my equations, assumptions, drawings, or interpretations.  If you see anything you believe to be in error or if anything is confusing, please feel free to contact me or comment below.

And so I should add -- this information is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Monday, September 24, 2018

Repair Log: HP 8640B Rotary Switches and Gears


The venerable HP 8640B Signal Generator has long had a place of honor on many an engineer's workbench.  But these generators are becoming long in tooth and some common modes of failure have appeared.

Two failures that one often sees in these generators are broken gears in the "Peak Deviation and Range Switch" Assembly, and missing rotary-switch wipers on HP's custom rotary switch assemblies (note that these rotary switches are used in the "Peak Deviation and Range Switch" Assembly and in the "Output Level" Assembly.


Repairing Gears and Switch Contacts in the "Peak Deviation and Range Switch" Assembly:

As I've noted, above, the plastic gears in the Peak Deviation and Range Switch assembly are prone to cracking and, in the worst case, falling apart.  Here are some examples from several different 8640B generators:


Several web sites discuss gluing cracked gears back together (see links at end of this post), but a better solution (in my opinion) is to replace the flawed plastic gears with brass gears.

At this time (September, 2018), there is at least one manufacturer selling brass replicas of the three 8640B gears most likely to fracture (the gears are sold either as a set of three or individually):


I purchased my set on eBay.  You can search eBay for "HP 8640B gears" and check if they are still available.  These gears do not replace every plastic gear in the assembly, just the three large ones, as these are the three most likely to crack.

Another common problem is that the "wiper" contacts on the rotary switches in this assembly (or in the Output Level Assembly) can sometimes fall off. 


These wipers are each normally held onto its round clear plastic switch "rotor" with two small plastic nipples extruding from the round rotor's clear plastic surface.  With age, however, these nipples can weaken and, if a generator experiences mechanical shock or vibration, the nipples can break loose and wiper contacts will no longer press down against the PCB traces below them or, in the worst case, they can completely fall off the switch assembly and into the instrument.


Peak Deviation and Range Switch Assembly Removal:

To repair gears or install switch-rotor wipers in the Peak Deviation and Range Switch Assembly, we must first remove the assembly from the generator's chassis.

The 8640B's Operating and Service Manual has detailed instructions for removal and disassembly of this module.  In my manual (printed April, 1978), this assembly's removal and disassembly is discussed in Service Sheet D, "A9 Assembly Removal and Disassembly", on page 8-88.

The instructions on the Service Sheet are self-explanatory when combined with the companion "Illustrated Parts Breakdown" illustration.  But there are a few instructions that, I believe, need better explaining (or a slight change in procedure).  I'll explain these, below:

Original Instruction 1Set PEAK DEVIATION and RANGE switches to fully ccw.

My modification to Instruction 1:  Set PEAK DEVIATION switch to fully ccw, but set RANGE switch to the 2-4 MHz range (two clicks clockwise from fully ccw).

This will place one of the grooves in the plastic portion of the switch coupler in a vertical position, which I find makes it a bit easier to withdraw the assembly.  See picture, below:


(NOTE:  After the assembly has been removed from the chassis, I put the RANGE knob back onto the assembly's RANGE switch shaft and turn it fully ccw, as was the intention of the original instruction.)

Instruction 5 (Removal of the assembly), note that there are lock washers on the threaded shaft assemblies (these normally protrude through the front panel).  Be aware that they might fall off while you are pulling the assembly out of the chassis.


After removing the assembly from the chassis, disassembly can begin.  Below is the Peak Deviation and Range Assembly that I will be working on.  You can see that a large chunk of one of the gears is missing.  (It is also missing three switch wiper contacts, which I will repair below, too).


Before continuing with disassembly, if you intend to repair any of the wipers on the switch rotors, I recommend noting where the contacts are for the three round clear plastic switch rotors when the two rotary switches are in their fully ccw position (the two pictures, below, are taken with the Peak Deviation and Range switches both in their fully ccw positions, per the manual's instructions).



Instruction 6 instructs us to desolder the three wires attached to the potentiometer terminals.  I prefer to desolder these wires at the PCB.  Be sure to note which wires go where (I took a photo rather than trust my memory).


Perform Instruction 7 (removing the retainer ring at the front of the potentiometer shaft), but before proceeding with the next instruction (Instruction 8), you first need to remove the coupler at the back end of the Range Switch shaft, as shown below (this step is not mentioned in the instructions):


(Note:  the Range Switch in the photo, above, is in its fully ccw position).

Instruction 8 calls for the removal of a retainer ring.  I've done this several times without "Retainer Ring Pliers", but I finally purchased a pair.  Having now used them, I strongly recommend them -- they make the task of removing and installing this type of retainer ring so much easier.

(Note that the Retainer Ring Pliers tip diameters needs to be 1 mm (0.039") to fit into the holes at the end of the retainer ring.)



(Channel Lock makes a similar "Retaining Ring" pair of pliers.  They are available through Amazon).

Continue with the manual's disassembly instructions.

(Note:  if you are only replacing the gears and not also repairing the wipers on either of the two side-by-side rotors at the front of the assembly, you can stop disassembly after completing instruction 14 and jump to my "Installing the Brass Gears" section, further below.)

At the end of Instruction 16, the final two switch rotors can be removed from the switch shafts.  Mine are shown below.


One of the switch rotors should have two wipers, but both of these broke off along with their mounting nipples.  Fortunately, there is a spare set of nipples 180 degrees away from the original set, and I can mount the wipers onto these nipples, instead.

(Note: rotors in later versions of the 8640B might also have two white plastic "bumpers" (load levelers) installed on them.  If you move the wipers to the spare set of nipples, you will need to move these bumpers 180 degrees around the rotor, too.  I discuss this further, below, in the "Output Level" Assembly's repair instructions.)

The other switch rotor has three wipers, of which one broke off.  The other two seem to still be solidly attached, so I've decided to glue the wiper back onto its original location, even though there are no nipples, rather than move all three wipers 180 degrees to the untouched nipples.

I use a drop of Super Glue (cyanoacrylate) to glue each metal wiper to its plastic rotor.


For wipers that have fallen off, I'll put the drop onto the rotor first and then press the wiper into it and hold it down (using a pair of tweezers).  For wipers that are still on the rotor, I'll put a drop on the top surface of the wiper, and this drop spreads across its surface to the plastic on all sides of the wiper.

I will then let the super glue "cure" for the better part of a day (just to be sure).  (Note that others have used 2-part epoxy successfully -- refer to the links at the end of this post).

Here are the three switch rotors from the assembly.  I have applied drops of super-glue to all wipers, even those that have not yet fallen off.


A quick test of the bond of the "nipple-less" wiper to its plastic rotor.


Also, while the assembly is apart, I recommend cleaning the switch contact traces on the printed-circuit boards by wiping them with a clean cloth.

Now reassembly of the module can commence.  This is simply the reversal of the manual's disassembly instructions.  But instead of mounting the original three large plastic gears that are prone to cracking, I will replace them with the new brass gears, as follows:

First, follow Instruction 17.b and ensure that both switches are in their fully ccw position (which they should already be).

Then install the 3-wiper and 2-wiper rotors per Instruction 17.c.  Note the wiper positioning of the two rotors in the photo, below.  (By the way, my "TOP" notation specifies that this side of the assembly is UP when the module is installed in the chassis and the chassis placed in its normal operating position, not upside-down):

Now start working backwards from instruction 16.



Installing the Brass Gears:

After instruction 15, you will begin installing the three brass gears.  Two of these are "combination gears" and one is a "spur gear":


Note that one of the combination gears does not need set screws.

The diagram below shows the location of these gears:


In Instruction 14, mount the brass "spur gear" (this is the gear with only one set of teeth, not two), identified as item 40 in figure 8-97 of the manual.  Note that one of its two set screws should be positioned on the "flat" surface of the shaft, but do not tighten them yet.

In Instruction 13, mount a brass "combination gear" (item 14 in figure 8-97) in lieu of the original plastic gear.  Note that a "combination gear" has two sets of teeth, not one.  And note that one of the gear's set screws should also be positioned towards the flat side of the shaft, but don't tighten the set screws yet! (keep the screws loose so that you can adjust this gear's position after you complete Instruction 8, per the procedure in Instruction 17.d, as I will discuss, below).

In Instruction 12, replace the plastic "combination gear" (item 19 in figure 8-97) on the T-shaft with its brass equivalent.  Note that this gear should have no set screws (although the brass gear has holes for set screws).

Try to align the planetary gears close to vertical when you slide it onto the solid Range Switch shaft.



When you've completed Instruction 8, you will need to rotate the four-wiper rotor at the back of the assembly to its proper position before tightening the set screws of the combination gear (item 14 in figure 8-97).  This is best done by unmeshing the combination gear (with the set-screws in it) from the smaller planetary gears so that the T-shaft can rotate freely.


You will have successfully aligned the rear rotor when the wipers on the rotor and the two small planetary gears that contact the brass combination gears are all vertically aligned.

You can now remesh the gears and tighten the set screws on both of the brass gears that have set screws, per the pictures, below.  (Note, again, that one set screw of each gear should align with the flat surface of the appropriate shaft).



Verify that all gears are positioned properly (for example, none of the three brass gears should be touching any PCB (their brass could short out traces!).  And all set screws should be tight (four screws, total).  Then temporarily install the two large knobs and rotate each, testing that the switches turn without significant resistance or binding.  (Loosen the gears' set screws and reposition them slightly if there seems to be an issue).

After completing this alignment, reinstall the Shaft Coupler (that was just after instruction 8, above) onto the rear of the Range switch shaft and continue with the reassembly, following the manual's instructions in reverse order.

When you reach instruction 5, before you remove the Range switch's knob (so that you can install the assembly into the chassis), rotate it two clicks clockwise from its fully counter-clockwise position.  The rear groove in the plastic coupler should now be vertical (if you've correctly installed the shaft coupler):


Now remove any knobs that you've temporarily installed and put the lockwashers back onto the switch threads:


To keep these lockwashers from falling off as you install the module, tilt the generator up:


Screw on the two nuts onto the switch threads, attach the knobs, and you are done!

Here is my reworked module with its three new brass gears, installed back in my generator:


That's it for my Peak Deviation and Range Switch Assembly repairs!


Repairing Switch Contacts in the "Output Level" Assembly:

There is also a plastic switcher rotor at the rear of the "Output Level" assembly.  It, too, can lose its wiper contacts, as I discovered while tracing down a problem in a different 8640B...

This 8640B had very low output, and I traced this problem back to a missing wiper on this rotor (which caused the MOD signal to the modulator assembly to be "open").

Here's the assembly.  You can see the switch rotor mounted on the back of the assembly.


Again, the manual gives comprehensive instructions for removal of this assembly (refer to Service Sheet A, "A1 Assembly Removal Procedure", on page 8-82, and its companion drawing on page 8-83).

Before removing the Output Level assembly, I recommend rotating the Output Level switch to its "-130 dBm" position.  Its wiper contacts will then be in the position shown, below:


Below is this assembly, removed from the chassis.  If you look closely you will notice that the third wiper (of three) furthest from the outer edge of the rotor is missing.


(And if you look closely you will also see two white "bumpers" also mounted on the rotor.  These are on the opposite side of the "circle" from the wipers and act to provide a counter-force to help keep the wipers in contact with the gold-plated traces below them.)

I haven't seen these bumpers on early models of the 8640B, so I suspect they were added in a later revision -- this 8640B has a serial number prefix of 2153A (i.e. built (or revised) in 1981), whereas the unit whose Output Deviation and Range Switch assembly that I repaired, above, has no bumpers on its rotors and its serial number prefix is 1745A (1977 build (or revision)).

Service Sheet A does not discuss the disassembly of the Output Level Assembly, but it should be obvious from inspection after you've removed the assembly from the chassis.  I used the following procedure:

1.  Check that the Output Level switch has been rotated to its -130 dBm position (i.e. fully ccw).  Note where the wiper contacts are in relation to their PCB traces.

2.  Note the colors of the wires going to the potentiometer from the PCB.  Then unsolder them either at the PCB or at the pot.

3.  Remove the two long screws holding the potentiometer bracket to the rear of the step-attenuator and remove the potentiometer and bracket.

4.  Pull out the potentiometer shaft extension that passes through the center of the step-attenuator's shaft.

5.  Now remove the Retainer Ring.  (Use a pair of Retaining Ring Pliers!):


6.  You can now remove the washer, spring, and the switch rotor.

With the rotor removed, you can replace any missing wipers and glue all of them to the rotor (I use drops of super glue).  (And now would be a good time to wipe the switch PCB contact-traces with a clean cloth).


IMPORTANT NOTE:

Because the two nipples for the missing rotor were also missing, I mounted the three rotors on the spare set of nipples 180 degrees from the original set (using a drop of super glue for each wiper, as I did for the other assembly).  And I moved the two white bumpers 180 degrees, too, per the picture, below:



Reassembly is just the reverse of disassembly.  Note that having a pair of "Retaining Ring Pliers" makes the reinstallation of the retainer ring a snap, rather than a chore replete with much swearing.


Sources of Wiper Contacts:

If a wiper contact falls off of a rotor, it might be lost forever.  To check, though, I would recommend removing all covers (top, bottom, and sides) and vigorously shaking the unit over a terry-cloth towel (the latter to prevent a wiper from bouncing away).  Turn the 8640B upside down, sideways, etc., and shake!  If you are lucky you will find the missing wiper on the towel.

But if the wiper is gone forever, there is still hope.

A number of people have fashioned their own wiper from other materials, for example, from a relay contact.  (See the links below, at the end of this post.)

But the ideal solution is to find a junker piece of HP test gear that uses HP's custom slide switches -- there's a good chance that the slide switches have the same contact wipers, and you can use these wipers in the 8640B.

For example, I found an HP 8013B Pulse Generator at the De Anza fleamarket.  Per the seller it was non-functional (which I later verified at home), and the price was right:  $10.00.

Its custom slide switches (circled below) all use the same wiper contacts as are used in the 8640B.


Here is 8013B's front panel PCB:


And below is the back side of one of the slide switches, after it has been removed (they slide right out).  Note that this particular switch has two wipers.  Just remove the tops of the nipples and you have two spare wipers!



8640B Hints and Kinks:

Additional notes on the 8640B:

1.  If the display shows all zeroes rather than the frequency, and it remains all zeroes as you turn the frequency knob, before you abandon hope first check the position of the Time Base toggle switch on the unit's back panel.  It should be down, in the INT position, not up in the EXT position.

2.  HP seems to always use screws with "Pozi-drive" heads. I recommend using matching "pozi-drive" screwdrivers -- they are less likely to bung up the slots in a screw's head.


Useful 8640B Links:

Manual PDFs:

Several versions of the HP 8640B Operating and Service Manual can be found at the BAMA website:
http://bama.edebris.com/manuals/hp/8640b/


Other links:

http://antiqueradios.com/forums/viewtopic.php?p=1055125 (Bulb Replacement, Gluing switch wipers, and don't store an 8640B on its end)

https://www.eevblog.com/forum/repair/hp-8640b-signal-generator-switch-disk-plastic-gear-repairs/ (Making contact wipers and using epoxy to hold them)

http://jvgavila.com/hp8640b.htm (Using relay contact as wiper replacement)

http://jvgavila.com/wb1.htm (Using two-part epoxy to hold wipers).

https://www.ve7ca.net/TstH86.htm (Many useful repair notes!)

http://www.wb0smx.net/?p=2023 (Detailed gear replacement (but with gears from a different manufacturer).  Many pictures!)

(And googling "HP 8640B repair" will return many other links).


Standard Caveat:

As always, I might have made a mistake in my equations, assumptions, drawings, or interpretations.  If you see anything you believe to be in error or if anything is confusing, please feel free to contact me or comment below.

And so I should add -- this information is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.