This post will describe the building of a complete instrument based on the earlier investigation of the Tektronix SG505 Signal Generator described here:
The power LED is optional. If you're going to use the OLED display, it will show that there is power. During testing, I used an LED to tell me that power is on, otherwise I can't see it visually, and before I added it, to my dismay, I left the unit powered on for a whole night. Not good.
While working on the final layout for the main board and the front panel, I became more and more agitated with the two screws that mount the potmeter reduction unit that are visible on the font panel.
After some hemming and hawing, I bit the bullet and redesigned the hardware construction such that there are no more screws visible on the front panel. It meant that I had to move some parts on the main board out of the way, and add another bracket and holes to the main board. I also used this moment to slightly change some positions and changed some of the silkscreen text.
Construction Details
The three boards have arrived from my sponsor PCBWay and as usual, look great. Especially the front panel came out very well with the black color of the solder mask and the crisp white silkscreen. Compared to other fab houses, PCBWay uses a special matt black color that is especially interesting for front panels because does not shine or mirror and does not leave finger prints. It is more difficult to clean though, so don't spill any flux on it. I use it on all my front panels and I quickly counted 5 of them on different instruments.
This time I forgot to ask them to put their manufacturing number on the back side of the board. By default, they put it on the front, as you can see here in the bottom left. It's not hindering though.
The Power Supply
I already populated the power supply board (top left above) the same afternoon. The next day I tested the vitals and all the voltages where there.
One important notice that I now also added to the schematic is that with this supply, you always need to connect a nominal load to the output of the shunt supplies, otherwise the TL431's will get too hot. They will try to reduce the voltage by sinking all the current. I used two 680R 1/4 W resistors as a load, connected to the board as you can see in the picture below.
I could easily adjust the voltages, the trimmers have a good range. The LED that I mounted on the board, to have a visual indication of the applied power, was too bright. I changed the series resistor from 10K to 47K to reduce the brightness. Now that I know that the supply is working, I can give it a good soak & scrub.
The Main Board
After knowing that the power supply works, I can start on the main board. I normally keep the prototype in a functioning state, but there are so many special parts on it that I can't do that. I'll simply transfer the parts from the prototype to the new board.
The challenge will be that I used the Tek part identifiers on the prototype, but started anew for the new board. I will have to use the iBOM plugin for KiCad on both PCB's to figure out which is which and where.
Here's a very valuable tip.
If you don't have this iBOM plugin installed yet, you're missing out on a fantastic addition. Highly recommended! My buddy Bud looked at it when I told him, and initially was not impressed. However it took only a little explanation of the features to make him a true believer as well. Now he swears by it.
Here is how that looks like:
The top screen shows the iBOM windows for the prototype with the parts list on the left, and the layout on the right. Everything is linked, so when you select a part in the layout, iBOM parts list or iBOM layout, the cursor will go there and highlight the part(s).
The bottom screen shows the Version 2 board, using a second browser. So I select a certain part value on the prototype, and also select the same part value on the V2 and then know where it is located on the prototype and where it needs to go on the V2 board. I first apply solder paste on the V2 board, and then use my heat-gun to remove the part from the prototype and place it on the V2 board. When everything is done, I can use the heat-gun or reflow plate to solder all the parts on the V2. Easy-peasy in theory, not so easy in practice, but after discovering and correcting a few errors, I could also add the other parts.
In the parts list, there are checkmarks you can fill in so you can keep track of where you are.
The main board is now ready for a reflow soldering process on my new hot plate. This is the largest board with a lot of parts, so yet another good test of the hot plate design.
Wave soldering went well, although I had to nudge a few tiny (0402 diodes - I ran out of the 0805 types) components in place. I'm now soaking the boards for several hours so I can clean them properly in order to inspect them better with my microscope. With the amount of flux and very tiny solder ball bearings in the way, that's not really possible.
Aftermath of reflow soldering
This is a little deviation, but I wanted to share it with you nonetheless. I will probably move this information to a new post, but at least you know why I did not present any progress for about a week.
After a reflow process, you end-up with a lot of flux that was part of the solder paste. Unfortunately, you need to remove that completely because it will have influences on hf circuits, and is hygroscopic so will attract water that will result in corrosion. Another side-effect of using solder paste is that you end-up with a number of so called ball-bearings. They are very tiny solder balls that are the result of the part sucking down to the PCB and that will push solder from beneath the part to the sides of the component.
Below is a good example of this issue. Mind you, this is after cleaning and scrubbing the board twice already!
The whitish goo is the solder flux and you can clearly see several ball bearings.
The remedy is to soak the board in a solvent for a while, and then vigorously scrub the PCB with a brush to remove the unwanted flux and the ball bearings.
Sounds easy, but is not so. The selection of the most optimum solvent is a science by itself, and is highly depending on the solder paste you are using. Some have water base paste, most have not. When you soak the board with a solvent, and use a brush, you typically end up with a very sticky board. To remove that, you can use IPA 99% to rub the PCB some more, and then generously poor fresh IPA on the board to let is drop of the board, and hopefully take the sticky goo with it. After that process, you can use clean (distilled to avoid calcium deposits) water to wash the remaining IPA off, and then dry the board. You can use a hairdryer, or use a solder heat gun, as I do, because that will allow you to blow the remaining liquid out of small pockets.
That's the process, and I have been using that for a long time.
This time however, it did not go well at all. First of all, the PCB was the largest I ever used on my reflow hotplate and that meant that the solder in the middle was overly done, and on the edges just about. There was an abundance of flux and I have never seen so many ball bearings. Cleaning as I describe above did not give a good result. Even after soaking for several hours, the goo stayed and the ball bearings with it.
Rather frustrated, I finally bit the bullet on purchasing an ultrasonic bath. I had been eyeing them for a while, but thought I could do without yet another box and also save the money. So I bought one for 2 liters that is just large enough for this PCB (160mmx115mm). It fits, but not in the wire-bucket.
After trying it with my solder paste solvent in the pure state, I first set the heating of the solvent to 50C and tried it for 5 minutes. That was much, much better, but still not good enough so I tried it for another 10 min. after adding some liquid dish washing soap to further breakdown the flux. That resulted in about a 90% successful cleaning. The edges of the board were not as clean as the middle, but that's because the single transducer is in the middle, and I'm pushing the size limit.
In the process, I noticed that one of the tiny 0402 diodes that I soldered by hand after the reflow soldering got loose (note the circle below). It must have been a cold solder joint, but I'm actually glad that happened because finding that error would have been difficult and I'm warned for the next time.
You can also clearly see the cloud of the solder paste solving into the liquid.
In any case, I'm happy with the results of the cleaning session now.
In the meantime, I may have discovered the reason for my reflow issues. It turns out that my solder paste is probably expired. I used SN4258 (Sn42/Bi58/Ag1), 138C melting point with a mesh (size of balls) 20-38um, or size #4. Unfortunately, there is no expiration date.
The effects that I see are exactly what is described when using expired solder paste. I always keep mine in the fridge, but it explains a lot. Unfortunately, I can't find the purchase date anymore but must be less than a year. I ordered it when I was working on my reflow hotplate. Lesson learned...
First Power Up
I connected the 12V rail to my Lab Power Supply to keep an eye on the current and used a jumper to select the frequency ranges, and listened for the relays clicking, which they did.
I then added the +/- 17V rails again using my Lab Supply and set the current to the expected value of 35mA. That didn't work, the supply went into current limiting, so something was wrong. Upon inspection, it turned out that I goofed with the location of two of the NE5534 Opamps, they were rotated 180 degrees. The marking is very difficult to see on them.. Unfortunately, trying the power again did not result in a lower current. I probably fried them, because after replacing them, I got the expected current result.
By then I could use the current shunt power supply for the SG505 and use that from now on. While checking the voltages, I noticed that the +17 could no longer be adjusted higher than 16.4V, so I lowered the -17V to also 16.4V to have symmetry. I need to investigate that in more detail later on, but I now had the 12V rail and the +/- 16.4V rails.
I then added the three potmeter connections and used my DSO to look at the generator output. Nothing, just some weird very low frequency flopping of the trace. That smelled of a bad connection in the overall loop so I hunted for poorly soldered parts. It took a while adding some flux (here we go again) and using either the heat gun or my solder iron to go over all the possible parts. Eventually I found the culprit and was presented by a beautiful sine wave. The frequency setting worked, the vernier worked and the frequency ranges worked as well.
With that result, I can now investigate and test the output amplifier and that's next on the list.
Wired-up all the required parts to make the amplifier functional, and eventually got it all working.
Oops!
I found one serious issue that I didn't see when using the prototype. I never tested the counter and then also looked at the sinewave distortion. In addition, I also used a slightly different pick-up point to tap the output frequency for the counter. That's a mistake, the 1K series resistor loads the feed-back loop of the output amplifier way too much due to the clamping of the diodes on the other side. I even tried 10K and that's still not good enough. Higher values result in no signal at the diodes.
The fix is rather easy and only involved a single trace cut from RV2 to the 1K of the squarer circuit and connect it now via a jumper wire to the Sine Out test point. I will fix this in the schematic and layout of course.
Tuning the highest range
While it is still lying on my desk and easily accessible, I decided to tune the X10K range because the frequency was a little too high compared to the lower ranges. I replaced the 100pF capacitors for C16 and C26 to 140pF. I didn't have that value, so I used a 150pF probably an X-version. That resulted in a frequency of 105KHz instead of 100KHz. The 140pF COG should get it closer.
Looking into the rail situation
I also investigated the fact that I could not get the positive rail up to +17V, while the -17V worked. The raw supply is also a little lower than I hoped for with the transformer I'm using, so I adjusted that output to 40.0V. With that, I adjusted the rails now to +/- 16.4V so they are equal. I don't think it will matter much. The original SG505 used +/- 15V rails, I decided to use the SG505 Option 2 rails that are +/- 17V which will give a bit more head-room for the Opamps.
I have not made any distortion measurements yet, I'll wait until everything is inside the enclosure and I have shortened all the leads that go to the front panel to the appropriate length.
Using the front panel
The next step is to mount the controls on the front panel and the PCB in the enclosure. I also need to make a few mechanical adjustments to the front panel because the holes do not match they way I designed it, and I made a mistake with the size for the main potmeter. These turned out to be a KiCad footprint issues and the result is that the holes are too small. Easy to fix but I also need to move the hole for the BNC connector a bit. Obviously, all the changes will be updated in schematics and the the Gerber files that I will publish.
Putting it in the enclosure
I finished the assembly of the front panel and put the main PCB inside the enclosure. It all works as advertised, but I had to make several changes to the front panel design.
Here is a view from the back that shows a few more details.
The power supply is still outside the enclosure as you can see, and I connected it with flying leads that still look untidy.
Now that I have the main potmeter reduction unit installed, the adjustment of the frequency is very precise and feels great. If you're in doubt of getting one, do it, you won't regret it.
Adding the frequency counter
I also fixed the counter loading problem that I mentioned earlier so I can now start to add the Arduino Nano, the opto-coupler and the OLED display.
The installation went pretty easy, also because I used tape to secure the display to the front panel.
However, making it all work was more involved than I anticipated, even though I built a prototype that (seemed) to work very well. After a few hours of struggling, I ended-up making several hardware and software changes to make it work reliably throughout the frequency range.
I eliminated the squarer circuit and replaced the BJT with a MOSFET to reduce the load on the frequency generator tapping point. I could now also use a much larger series resistor, and placed that very close to the generator output again, instead of using the output amplifier because that signal can be attenuated.
The trace that goes from the generator output to the MOSFET for the counter is very long, so I wanted to reduce the current and hence the possibility for cross-talk.
I also had to power the opto-coupler open collector output with the Arduino 3V3 instead of the 5V rail to reduce the 5V p-p hammering on the port. That made a significant improvement to the precision of the counter.
Lastly, I tried to get a bit more fancy with the frequency count display, and wanted to add decimals for frequencies below 1KHz. After trying for some time, I realized that the library I'm using is optimal for the higher frequencies, but not so much below 1KHz. For those frequencies, to get a decimal digit, I needed to select a gate time of 10s which makes the counter unresponsive for this application. Selecting a library that fixes that will not work well with the higher frequencies, and I have not figured out how to use both libraries and select them dynamically. It is what it is. The solace is that the counter is a lot better (more precise) than the frequency dial of the original SG505. If you need a higher precision, use a real counter!
The DMM shows the frequency from the SG505 output and can be compared with the counter display. Not a perfect match, but good enough!
Next step is to mount the power supply in the top half of the enclosure and create the correct length for the power interconnects. By then, it's time for some distortion measurements, some tuning/calibration and see if I need to add shielding to the inside. I think I will...
Oh boy, oh boy...
I finished with putting everything inside the enclosure, calibrated the 0dBm output level and found out that I need to make changes to the -10dBm switch circuit.. I have a new set of values that I tried and worked for the Pi attenuator but will need to take the board out to replace the resistors. That can wait.
I wanted to make a distortion measurement to see where we are:
The 50Hz mains is everywhere, I kind of expected some of it because there are two transformers in the box but was hoping some serious shielding would help, but this is out of the question. The good news is that the principle has pretty good harmonic distortion results. THD h2-12 is 0.00063%, but's it's overwhelmed by the hum.
It's abundantly clear that the power supply has to move out. There is no place for both of them in this house. Bummer.
That means going back to an earlier idea and that was to use a separate enclosure to house the power supply and keep it away from the generator. That's pretty easy to try with some longer connection leads for the power rails.
Unfortunately, even with the generator in a metal box, the hum and the AC-DC supply generated noise is still there.
Here is the result with the +/-17V connected, but without the 12V supply connected. There is no sine wave because the relays don't work. This is kind off the noise floor.
It seems that the shunt supplies are working OK, it's the 12V supply and circuits.
This is with my lab supply feeding the 12V rail, activating the relays.
And below is the same measurement but with the Arduino Nano out of it's socket. I also did a quick trimming of the H2 reduction, and that worked very well. Went from -110dB to -126dB.
The silver lining
Without the 12V AC-DC convertor, and without the Nano/LCD display, the generator works fine.
THD-N is 0.0033%, THD H2-12 is 0.00020%, with H2 at 0.000050% and H3 at 0.00014%
That's good to know and very good news! Now I need to find some solutions.
Finding the root cause
We already established that it is mainly the AC-DC 12V supply, but is there more to it? I tried it also with the Nano powered, but pulling the LCD connector. This dramatically reduces the noise so it's not the Nano itself, adding little peaks at 15KHz and 19KHz, but more the i2c signals and the power devices on the OLED board itself:
Using a 1uF blocking capacitor and using the E-MU to look at the AC-DC 12V rails, it sees this:
And without the OLED display this:
So the dominant culprit is the OLED display, and there is also seems to be some back-coupling from the generator into the 12V rail. On a hunch, I disconnected the generator output signal to the counter input circuit and presto, we have proof that the harmonics are from the Nano and counter input circuits.
When I pulled the opto-coupler, the harmonics went away. Putting it back in and removing the 3V3 for the open collector pull-up did not make a difference. Disabling the Arduino loop reading the counter did also nothing. It sure looks I need to cut the power to the Arduino and the display to make that circuit quiet.
The two part solution:
Powering the 12V section of the Arduino counter with a SPST switch, I can now eliminate the generated noise from that circuit. It works great, when I power the 12V with my lab supply. Have a look:
With the Arduino Nano circuit turned on, it looks like this:
Mind you, the noise is still below 120dB, but the root of the problem is the AC-DC 12V supply. That will need some serious filtering, or another solution.
The second part of the solution
I need to filter the AC-DC supply much better, or create a different solution. Seriously reducing that noise is going to be a challenge to force it below 120dB. I first need to profile that supply better.
The 12V supply draws 46-48mA when everything is powered.
We're looking mostly at 50Hz mains related hum, plus many harmonics in the higher frequencies.
I can try to filter the hum and noise, but the whole reason for the AC-DC convertor feeding the separate 12V supply and to avoid coupling to the generator fell flat on its face. That's not the solution.
So, when the coupling is there anyway, I might as well do away with the 12V circuit and tap the 12V rail from the main supply. I quickly added a few components to the 5V section of a bare Jung supply PCB and modified the output for 12V. It's actually 11.5V but that has no consequence. When powering the 12V rails with the new supply, we're making real progress. This is when the Nano supply is switched off:
I still want see if I can get rid of the mains related hum on the left, but the part on the right is now clean.
To give myself some peace of mind, I also tried the Jung SuperReg again for the +/-17V rails. Surprisingly, with the current configuration, it produced more harmonics. Go figure.
So, all in all, I decided to redesign the power supply by removing the AC-DC converter, and add a third rail fed by the 40V Vreg supply, to provide the 12V supply. The 12V rail does not connect to the common ground, so it stays floating from the rest.
I tried many things to reduce the mains hum and was partially successful by using more capacitance on the main supply.
The next step is to work on the grounding/shielding of the generator. Right now, the front panel is isolated from GND, and I need to change that now, and also ground the switches and potmeters on the front panel. The whole generator will continue to be isolated from earth ground.
Major changes and a departure from this version
After considerations off the issues described above, I have now decided to make a significant change to the generator, now that the power supply is no longer going to be in the same enclosure as the generator. I'm now going to use a full metal enclosure for the generator and put the noisy parts of the power supply in another enclosure.
This means that with the other changes I already had to make/want to make, I will go through a redesign of the main PCB, the Power Supply and the Front Panel.
The sponsoring agreement with PCBWay requires a new Blog for every set of PCB's that they sponsor, so I will start a new Blog for the new Version 3 of the DIY SG505 rebuild. This one was already too long, so it's a good reason to start a new one anyway.
The V3 information can be found here:
A Github repository is available here it will be updated with information during the project when I have verified the correct operation. I'm still working on it, so there is very little information there at the moment so please be patient.