IF sweep from PIC16F18345 NCO

Trying to get a 455kHz sweep signal out of a PIC MCU

Similar projects worth following
PIC16F18345 has a NCO peripheral and a 32MHz internal oscillator. Can this chip generate a 400-500kHz sweep signal? Can the sweep signal be used to make a bode plot? Will it work with very analog technology?

This project will experiment with the NCO (numerically controlled oscillator) peripheral found in many recent PIC16F chips.  The goal is to make a very limited RF sweep generator.  In most AM radios, the IF stage is a set of tuned filters with a center frequency of 455kHz.  This frequency is just below the AM broadcast band.  This is basic superheterodyne radio operation.  The tuned filter bandwidth is normally about 15kHz to 20 kHz wide or twice the audio bandwidth.  Old radios need adjustment to get reasonable performance from the tuned stages.

The project will generate a RF signal that quickly sweeps from 400-500kHz.  An oscilloscope can be used to plot amplitude versus frequency.  This plot is the frequency response of the IF filter stages.  In practice, the tuning adjustments interact.  There is some practice and art to align and peak the filter stages.  Most vacuum tube (AA5) radios have 4 IF tuning adjustments.

The PIC16F18345 was selected because it has the NCO peripheral and a high internal clock frequency, 32MHz max.  The PIC16F18345 was also available on a development board with a USB port for programming.  The frequency output from a micro is always the peripheral clock divided by some integer.  Unfortunately 32MHz/455kHz isn't an integer.  The NCO peripheral dithers between the 2 closest integer divisors to generate an accurate AVERAGE frequency at a non-integral value.  The period of a cycle is still based on the integer divider.  The average over many periods will be accurate.  The NCO peripheral is injecting frequency domain noise to generate a "blended" frequency value.  This noise will blur the fundamental in an FFT plot.  The noise should be low enough to use the signal for testing a filter.

The math says that a narrow band-pass filter (IF stage) will filter out the frequencies outside the band-pass.  That's good if the filter is working.  It's unknown if this can be used for tuning and repairing filter circuits.

  • PIC16F18345 EVB and IDE

    bobu03/20/2021 at 17:41 0 comments

    The PIC16F18345 evaluation board (DM164141) is a MPLAB Xpress evaluation board.  I bought the 20 pin version since it was the smallest and cheapest option.  Several distributors sell the EVB

    At first I thought of using a Linux toolchain to program the part, but some of the tools were a bit out of date.  I decided to go with the Linux version of Microchip MPLAB X IDE.  This is proprietary software, but it is offered free of charge.  Microchip has decent installation instructions.  Be aware, it's a huge program and it runs in a specific Java version.  It worked on my old workbench laptop, but it is a VERY busy user interface.  This took some time to understand and use.  This ain't Arduino.  It's a professional IDE with half the features disabled in the free version.  It suffers from cluttered menus.  Some menus did not fit on my crummy laptop screen.

    The MPLAB Configurator is really nice and useful.  It's a separate installation, but it's worthwhile.  It's a GUI tool to set up all the system and peripheral options needed for a project.  Again, the user interface was designed for higher screen resolution than my laptop.  The configurator will generate header and C files that get included in the project.  This saved a lot of time reading about peripheral register bits.

    The EVB connects by USB and acts like a tiny FAT partition.  The command line or file manager can be used to copy the .hex file.  The EVB has a programmer section and a target section.  Copying the file is all that was needed to program the target.  This is very convenient.

    I did have a problem programming the target MCU with the default 3.3V setting.  5V is working fine.  Maybe this EVB has some issue.  I've asked Microchip for technical help.

  • initial success

    bobu03/19/2021 at 02:13 0 comments

    The project log is written backwards.  After some initial success, the development will be described.  In short, it worked better than expected.

    • A PIC16F18345 EVB is configured to generate 400-500kHz using the NCO peripheral
    • Sweep is generated by a for loop and updating the NCO registers
    • Internal HF osc is configured for 32 MHz.  Supply is 5V from USB port.
    • Frequency output is on RC0.  This is turned on and off for each sweep.
    • A trigger and marker signal is generated on RC1.  The marker goes low when output is between 453 and 457 kHz.
    • The 5V frequency output is attenuated and filtered by a simple R-C network and pot.  Not very good, but it did work
    • The signal is tied to a vacuum tube radio IF strip.  It's coupled into the signal grid of the converter tube.
    • IF output is at the detector, where the AVC voltage is typically found.
    • IF output is AC coupled into the scope channel.
    • The other scope channel is connected to the marker at RC1.
    • The scope display is very stable.
    • The IF transformers could be adjusted to get a nice peak centered around the marker notch.

    The code was done in MPLAB X.  It's ugly.  I'll clean it up a bit and post it later.

View all 2 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates