Posts Tagged ‘ Si5351 ’

Audio Adapter for the Si5351 Signal Generator

I had just finished building a three port RF signal generator when the January 2018 QST arrived in the mail. January is the annual Do It Yourself issue and there was an intriguing article by Keith Kunde, K8KK titled “A Low Distortion Digital Audio Oscillator”. The heart of Keith’s circuit is a MAX294 filter chip, a sophisticated 8th order switched capacitor filter capable of rounding off a square wave into a pretty good sine wave. The ‘294 is fed with a square wave at the desired frequency and also a clock signal 100 times the desired frequency. Keith generates his clock with a 555 timer and then feeds a divide by 128 chip to develop the base output frequency. My new Si5351 RF generator could be a crystal controlled clock source and all I would only need the divider and filter circuits to add audio capability. The MAX294 costs about six bucks each.

Goals for the Audio Adapter were:

  1. 20 to 20000 Hz capability
  2. Sine or Square wave output
  3. Line level output, one volt peak to peak into 600 ohms
  4. Be as portable as the signal generator, meaning battery operation in an Altoids tin
  5. Two channels
  6. Direct frequency readout from the signal generator display

That sixth requirement means decimal dividers throughout. If I add one additional decade to the ‘294 chip’s clock divide by 100 requirement, the total division would be 1000. When the signal generator display shows 25 megahertz, the output would be 25 kilohertz. No math necessary.

The MAX294 has an uncommitted on board op amp but it is intended as a pre or post processing filter and has weak output specs. To get line level output I decided to buffer the ‘294 output with an LM358 op amp connected as a voltage follower. Later on, this proved to be the most troublesome part of the project.

Internet searching did not turn up many choices for decade frequency dividers. I decided on the 74hct390 chip which I have used before. It’s a dual decade divider, each side has a divide by two, and a divide by five stage. Cascading these gives a divide by ten with BCD output of the counter state. For this two channel build I would need a total of ten divide by ten stages, achievable with five 74hct390s. This diagram shows the basic filter wiring.

Basic MAX294 Application

Basic MAX294 Application

The last divider stage is a divide by two so the ‘294 filter sees a symmetrical square wave. 100k and 39k resistors form a voltage divider network to get the TTL level square wave down to an amplitude the ‘294 can handle without clipping.

 

I decided the project was indeed viable and ordered parts from Digikey.

Software in the signal generator was tweaked to have a lower range limit of 100 Kilohertz. The Si5351 should go all the way down to 10 Khz with appropriate software support but rather than press my luck, I added two additional decade divider stages to the design. A three position switch selects a frequency tap from the chain so the frequency ranges are:

  • Divide by 10**3  100 to 25,000 Hz
  • Divide by 10**4  10 to 2,500 Hz
  • Divide by 10**5  1 to 250 Hz

With the additional ranges, I can still read the LCD display directly but have to mentally move the decimal point. The first requirement is met. Also added is an SPDT switch to connect the op amp input to either the filter input (square wave) or the filter output (sine wave). That meets the second requirement.

Digikey parts finally in hand, I bread boarded the circuit. The dividers are on the left, the op amp is on the right.

Audio Adapter Breadboard

Audio Adapter Breadboard

This is the final schematic of the filter circuits. Eagle made the drawing and I did go through the exercise of generating a PC board  just to see if there really was room for the parts.  Since the project is a one-off, I built everything on perf board, using 30 gauge wire wrapped around IC pins with my standard wire wrap tool – a ballpoint pen refill. It would have been a lot faster if I had a real PC board.

Analog Board Schematic

Analog Board Schematic

Analog Board

Analog Board

A 2000 mAh portable USB power pack was sacrificed to obtain an 18650 battery, it’s associated charger, and 5 volt up converter. That would satisfy the portability requirement. I stuffed the battery, charger board, four RCA jacks and three slide switches into an Altoids tin while waiting for Digikey.

I used Eagle to generate a schematic and proposed PC board for the higher level digital divider circuits. This board had to fit between the 18650 battery and the range switches, and I had to nip off the corners to work around the battery charger circuit. This board is mounted on #4 screws soldered to the bottom of the Altoids tin. I built the digital divider board first, it is much simpler than the analog boards.

Digital Board Schematic

Digital Board Schematic

Digital Divider Board

Digital Divider Board

I used the analog portion of the bread board to verify the digital dividers were working properly. I found the 74hct390 chips would accept a signal as high as 90 MHz. They will be loafing at 25 MHz. This photo shows the digital board seated in the bottom of the Altoids tin. Only six wires will connect to the analog board in the tin lid, 5 volt power, ground, two divided outputs from the range switches, and two audio output leads. Audio connects to 1000 ufd  capacitors nestled on either side of the battery.

Digital Divider Board and Charger Installed

Digital Divider Board and Charger Installed

Now came extensive testing on the breadboard. Keith Kunde’s QST article discusses the level and DC offset considerations of the MAX294 filter when used with a single ended supply. I used a pair of 10k resistors to create a half supply voltage virtual ground and bypassed that rail with 22 uF capacitors.  I’m using DC coupling between the dividers, the filter chip, and the op amp so had to do some fussing with the voltage divider parameters Keith talks about to get a filter output with no clipping. My final divider has 100k resistor in series with the TTL level divider output, and a 36k resistor to virtual ground. I also found that connecting a VOM in series with the 5 volt supply to measure current seriously upset the DC balance for some reason. It appears the final circuit will draw about 25-30 milliamps from the battery. At that rate, the adapter should run 60 hours on a charge.

But the output waveform from the LM358 buffer amp was horrible! To make a long story short, Google “LM358 Crossover Distortion”.  The ‘358 has a class B push pull output stage and when the signal crosses over from one side to the other it takes a short nap. After a good bit of troubleshooting and research, the fix is simple. Add a 1000 ohm resistor from amp output to ground. This forces the output stage into a class A region and I was able to get 2 volts peak to peak out with no glitches and it will drive a 100 ohm load with no clipping or distortion.  I believe 2200 ohms to ground will also work and draw less current through the amp.

Also the ‘358 has a slow slew rate which causes the sides of the square wave to lean noticeably.   If I knew then what I know now I would have ordered an MC34072 amp which has better specs and no crossover problem, still less than a dollar.

The following photos are the analog board top, bottom and trial fit into the lid. The board is supported in the Altoids tin by the pot mounting nuts at the front and a single L shaped bent paper clip soldered to the lid at the back. I’ve also added an LED in the lid to remind me to turn the power off.

Top of Analog Board

Top of Analog Board

Bottom of Analog Board

Bottom of Analog Board

Connecting Digital Divider Board to Analog Board

Connecting Digital Divider Board to Analog Board

I took a couple of weeks part time to wire and debug the analog circuits but I was finally satisfied and mounted the board in the Altoids tin lid. It JUST clears the battery and the inductor on the battery charger. This photo is as finally assembled. Note a small bit of blue clay on the charger inductor, that’s how I checked the clearance.

Interior of Finished Audio Adapter

Interior of Finished Audio Adapter

These are the money shots of the fully assembled Audio Adapter.

Dual Channel Audio Adaptor

Dual Channel Audio Adaptor

Dual Channel Audio Adaptor

Dual Channel Audio Adaptor

But does it work?

This shot has sine wave selected on one channel and square wave selected on the other.

MAX294 Filter Out and In

MAX294 Filter Out and In

A 10 KHz sine wave. As K8KK noted in QST, there is some clock noise on the wave form at 100x the output frequency.

10000 Hz Sine Wave

10000 Hz Sine Wave

This is a 1 (ONE!) Hz sine wave. Notice the sweep speed setting on the right. It took some creative manipulation of room lights and the camera shutter speed to get this to show properly. You can definitely see the clock noise on this trace.  It looks a lot like the synthesized sine waves I experimented with a couple of years ago.

One Hertz Sine Wave

One Hertz Sine Wave

The next two photos show the waveform when the two channels are combined in an external resistor network. 1500 ohms from either side to a junction, then 1500 ohms to ground to load the signal.

Combined Waveform: 10000 + 10500 Hz

Combined Waveform: 10000 + 10500 Hz

Combined Waveform: 1000 Hz + 1100 Hz

Combined Waveform: 1000 Hz + 1100 Hz

Finally, here is the family connected together to the resistive combining network.

Set Up for Combined Waveform Test

Set Up for Combined Waveform Test

This was an enjoyable but sometimes frustrating project. It’s definitely the densest thing I ever built and would be much simpler if I wasn’t too cheap to order a PC board. I learned that 0603 resistors are not a good choice for hand soldering. I learned that LM358 op amps suck. It is working great now though, and even though I have two other audio oscillators, this is a welcome addition to my test equipment stable.

de WB8NBS/9

 

Addendum

April 27 2018:  I acquired a Brother P-touch labeler. Labels help my feeble memory. The P-touch came with a short reel of 12 mm black on white background – these labels were made in two line mode which fits well on the edge of the lid. I will probably replace them with black on clear sometime as that would better keep the Altoids theme.

PTouch Labels Added

PTouch Labels Added

Advertisements

Arduino – Si5351 Powered Signal Generator

Arduino-Si5351 Signal Generator

Arduino-Si5351 Signal Generator

Device Description

For a long time I wanted a general purpose signal generator. Now Direct Digital Synthesizer hardware is available on a single programmable chip. The Analog Devices AD9851 is used in many ham radio projects, also widely used is the Silicon Labs Si5351. Either of these can be obtained from many sources such as Adafruit, Sparkfun, or on EBay and there’s lots of information on the internet. Even Amazon has them. A few dollars gets a DDS chip that will tune continuously from audio to VHF mounted on a small breakout board. I purchased an Si5351 board from Etherkit because they offer a version with a TCXO.

Silicon Labs makes the Si5351 in several variations. It’s intended use is as a multiple output clock generator with up to eight individually programmed frequencies. Most commonly available breakout boards though, use the A version with three outputs. Digikey has the bare chips for less than $1. Connectors are optional, most boards are set up for SMA female jacks. The signal generator I built brings out all three outputs but I used good old RCA phono jacks. SMA connectors are wonderful but the cables to use them are pricey. My box will be used to check and align receivers so precision impedance control is less important.

AD9851 chips have a real Digital/Analog converter on board, it uses an amplitude lookup table to produce a fair sine wave. The data sheet says:

“The AD9851 uses an innovative and proprietary angle rotation algorithm that mathematically converts the 14-bit truncated value of the 32-bit phase accumulator to the 10-bit quantized amplitude that is passed to the DAC. This unique algorithm uses a much-reduced ROM look-up table and DSP to perform this function.”

which sounds suspiciously like the quarter wave sine synthesis I experimented with a few years ago. I’ll have to revise my WordPress pages about quarter wave DDS techniques to include the phrase “angle rotation algorithm”. The price for pure sine wave complexity is, the device has only a single output. In contrast, the Si5351 outputs a square wave on all it’s ports – it is intended to serve as a programmable frequency clock source but for my purposes I don’t care and the available multiple outputs are attractive.
I breadboarded the Etherkit breakout along with one of Paul Stoffregen’s Teensy-LCs I had on hand for the controller. A Teensy-LC has an ARM Cortex M0 heart clocked at 48 Mhz. An ordinary 16 Mhz Arduino would probably work in this circuit but would have trouble with sweep. I used basic software from N6QW to get started and my oscilloscope soon showed it was working. Then a series of enhancements to the N6QW sketch followed:
  • expand to controlling all three outputs
  • setting up frequencies using rotary encoder and LCD menus
  • save and restore setup in EEPROM
  • add output power change to the menus
  • add  output OFF to the power menu
  • add sweep capability with menu control

The Box

A thin metal gift card box was cut up to form an enclosure for the generator. It is about a quarter inch larger than the usual Altoids tin in all three dimensions. I needed the extra volume to fit in a battery and charger removed from a cheap phone power pack. These booster packs usually contain a single 18650 cell and it just fits.

Arduino-Si5351 Signal Generator Interior

Arduino-Si5351 Signal Generator Interior

The components are, top to bottom, blue 16×2 LCD board supporting the Teensy-LC. The entire unit can be 5 volt powered either from the Teensy USB jack or from the battery charger, I added a fat diode to isolate the two sources.  Both the Teensy and the Si5351 board are using their on board voltage regulators. The LCD is five volt, but the Teensy-LC does not have 5 volt tolerant inputs. There are 2.2k resistors between the LCD data pins and the Teensy to smooth over that discrepancy, these would not be necessary if the LCD was a 3.3 volt unit. The pot below the Teensy adjusts the LCD contrast.
At left below the LCD is the Adafruit (Bourns) rotary encoder. It just clears the battery. Right of the encoder is a strip of perf board with the three output select pushbuttons mounted. The LCD, encoder and buttons are Adafruit parts.
At the top of the open box bottom is the salvaged 18650 cell. The measured drain of the whole circuit is less than 100 milliamps so the battery should last half a day at least. The gooey glob at the center is a 2.5 amp fuse. To the right of the battery is the on/off switch and isolation diode. The salvaged Lithium charge/boost circuit is the green board at bottom right. It has it’s own separate USB jack because the USB data leads are not accessible. To program the unit you have to plug into the Teensy USB jack.
Finally the blue board in the bottom is the Etherkit breakout. The actual Si5351 chip is at the left end, next to the TCXO. There are three RCA output jacks mounted in the left side of the box, the fourth jack next to the handle is for syncing the scope when sweeping.

Operation

On power up the unit reads saved frequency settings from EEPROM. The display then shows frequency, current port selected, and the output power setting.

Click one of the three buttons to change the port selected to display on the LCD.

Rotating the encoder knob will change the frequency digit under the flashing cursor. Press click the encoder knob to change the digit under the cursor, you can set the cursor to change digits from 1 Hz to 10 MHz.

Hold one of the port select buttons down and turn the encoder knob to change output power for that port. The chip has choices of 8 milliamps, 6 mA, 4 mA, 2 mA, and OFF. Silicon Labs’ spec for driver impedance is 50-85 ohms.

If any of the above settings are changed, the software waits ten seconds, then copies the current settings into EEPROM. In the event the unit gets confused, it can be restored to last saved settings by cycling the power switch. Also it can be returned to default settings by holding down all three port select buttons, while powering up.

Arduino-Si5351 Signal Generator Frequency/Power

Arduino-Si5351 Signal Generator Frequency/Power Setting

 

Sweep Function

Sweep is accessed from a separate menu. Press down the encoder knob for more than two seconds (a long press) and release to enter sweep parameters for the currently selected port.  A short click of the encoder knob will advance the menu through the sweep choices, currently +/-  0, 1000, 5000, 15000, 50000, or 150000 Hz. The unit sweeps from frequency minus that amount to frequency plus that amount so the total width of sweep is twice the setting. Sweeping is done by reprogramming frequencies in 20 steps between the limits.

A second long press of the encoder knob will return to the frequency menu. The letters “sw” appear on the LCD to indicate that that port is set up to sweep. All three ports can be set up but only the port currently selected in the display will be sweeping at any given time.

A pulse is available at a phono jack on top of the box to trigger an oscilloscope at start of each sweep iteration.

Sweep parameters are not currently saved in EEPROM.

Arduino-Si5351 Signal Generator Sweep

Arduino-Si5351 Signal Generator Sweep Setup Screen

 

The Software

I am using the Si5351 library from Etherkit. I added a function to completely disable the output drivers to save battery when a port is set to “OFF” so I will include the library in the zip file.
Most of the sketch, implementing multiple port and the menus, was straight forward. The one thing that gave me fits was the quadrature nature of the rotary encoder. This is a mechanical switch and it glitches. Not a problem if you are say, setting an analog output from 0 to 1023, you probably wouldn’t notice but if you need to change a digit by exactly one, glitches are intolerable.  Conventional debouncing a switch usually just waits a certain amount of milliseconds after a transition is detected, read again and proceed. There are debounce libraries for doing this. I had no luck. I finally found an post by Oleg Mazurov about treating the quadrature pulses as a Gray code. It helped a lot and I posted about my findings in the Adafruit Feather forum.
The Adafruit rotary encoder outputs four state transitions on each of it’s 24 rotary detent positions. To get one increment per detent, I tried skipping four state reads with a software counter but it was still glitching if the knob was inadvertently touched. What finally worked was changing the Gray code decode table to disallow all but one positive change and one negative change. The allowed changes remaining are in the middle of the detent so glitches near the resting position are unlikely.
Sweep is accomplished by reprogramming a port frequency on the fly. Tests indicate this is slow and the 20 step sweep takes about 65 milliseconds which limits the sweep rate to about 15 per second. I found a very good way to time something is to write a 1 to some output pin at the beginning, then write a 0 at the end. It’s easy to see exactly how much time the intervening code took by measuring the pulse on an oscilloscope. The send_frequency function takes 3.5 milliseconds. Looking at the Si5351 library, the set_freq code is long and complex. It might be possible to speed this up by using the set_freq_manual call but I’m not smart enough to do that. Porting this code to a 16 Mhz Arduino might make the sweep unusably slow.

Addendum April 4, 2018: Amplitude Modulation Experiment

I thought I might try generating an AM modulated signal by summing three generator outputs.  A 1.1 MHz signal modulated  at 1 KHz would have a 1.100 MHz carrier, a 1.101 MHz upper sideband at half the carrier amplitude, and a 1.099 MHz sideband at half the carrier amplitude. I breadboarded a resistive combiner as follows:
Resistive Combiner

Resistive Combiner

The Si5351 was set to equal drive power on all three outputs.  I examined the output on the oscilloscope, channel 1 connected to AM Out, channel 2 to Audio Out with sync taken from Channel 2. The result is not encouraging. It does output an amplitude modulated signal but the waveforms are bizarre. I see a blocky square wave changing at a 1000 Hz rate but there is some phase problem I can’t control.  This is the best I could capture:

AM Modulated Signal

AM Modulated Signal

Connecting an audio amp and speaker does show a 1 KHz tone if the phases happen to line up just right. I found that setting any one of the generators to be one Hz off frequency results in a rolling pattern with about a one per second beat note in the speaker.

This method of faking Amplitude Modulation is certainly not precise or controllable. Setting one of the outputs off frequency by a few Hz does give a useful warbling tone in an AM receiver.

Files

A zip archive is available including sketch source, the Si5351 library, and a schematic
Jan 4, 2018 V1.1 including the sweep function
 Jan 5, 2018 V1.11 Sweep bug would not change freq while in sweep mode. Cleaned up schematic.
https://www.dropbox.com/s/hk7nc063ipjisr7/SignalGenV1.11.zip?dl=0
Advertisements