Silicon ChipA shirt-pocket Sized Audio DDS Oscillator - September 2020 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: 5G and the stupid Broadband Tax / Altronics catalog delay
  4. Feature: 5G Mobile Networks by Dr David Maddison
  5. Project: High Power Ultrasonic Cleaner by John Clarke
  6. Feature: The History of the Australian General Purpose Outlet (GPO) by John Hunter
  7. Project: A shirt-pocket Sized Audio DDS Oscillator by Andrew Woodfield
  8. Serviceman's Log: Troubleshooting Temperamental Tea by Dave Thompson
  9. Project: The Night Keeper Lighthouse by Andrew Woodfield
  10. Feature: Advanced Vehicle Diagnostics with OBD2 by Nenad Stojadonovic
  11. Product Showcase
  12. Project: USB SuperCodec – part two by Phil Prosser
  13. Vintage Radio: US Marine Corps TBY-8 squad radio by Ian Batty
  14. PartShop
  15. Market Centre
  16. Advertising Index
  17. Outer Back Cover

This is only a preview of the September 2020 issue of Silicon Chip.

You can view 36 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "High Power Ultrasonic Cleaner":
  • High Power Ultrasonic Cleaner main PCB [04105201] (AUD $7.50)
  • High Power Ultrasonic Cleaner front panel PCB [04105202] (AUD $5.00)
  • PIC16F1459-I/P programmed for the High Power Ultrasonic Cleaner [0410520A.HEX] (Programmed Microcontroller, AUD $10.00)
  • One 40kHz 50W ultrasonic transducer (Component, AUD $55.00)
  • ETD29 transformer components (AUD $15.00)
  • Hard-to-get parts for the High Power Ultrasonic Cleaner (Component, AUD $35.00)
  • High Power Ultrasonic Cleaner main PCB patterns (PDF download) [04105201-2] (Free)
  • High Power Ultrasonic Cleaner lid panel artwork & drilling diagram (PDF download) (Free)
  • Firmware and source code for the High Power Ultrasonic Cleaner [0410520A] (Software, Free)
Articles in this series:
  • High Power Ultrasonic Cleaner (September 2020)
  • High Power Ultrasonic Cleaner (September 2020)
  • High Power Ultrasonic Cleaner – part two (October 2020)
  • High Power Ultrasonic Cleaner – part two (October 2020)
Items relevant to "A shirt-pocket Sized Audio DDS Oscillator":
  • Shirt Pocket Audio Oscillator PCB [01110201] (AUD $2.50)
  • 8-pin ATtiny Programming Adaptor Board [01110202] (PCB, AUD $1.50)
  • ATtiny85V-10PU programmed for the Shirt Pocket Audio Oscillator [0111020A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Pulse-type rotary encoder with pushbutton and 18t spline shaft (Component, AUD $3.00)
  • 64x32 white OLED screen (0.49-inch, 1.25cm diagonal) (Component, AUD $10.00)
  • Firmware and 3D printing files for the Shirt-pocket Sized Audio DDS Oscillator (Software, Free)
  • Shirt Pocket Audio Oscillator PCB pattern (PDF download) [01110201] (Free)
  • 8-pin ATtiny Programming Adaptor Board PCB pattern (PDF download) [01110202] (Free)
  • Shirt Pocket Oscillator front panel artwork (PDF download) (Free)
Items relevant to "The Night Keeper Lighthouse":
  • Night Keeper Lighthouse PCB [08110201] (AUD $5.00)
  • Night Keeper Lighthouse PCB pattern (PDF download) [08110201] (Free)
Items relevant to "USB SuperCodec – part two":
  • USB SuperCodec PCB [01106201] (AUD $12.50)
  • USB SuperCodec Balanced Input Attenuator add-on PCB [01106202] (AUD $7.50)
  • Parts source grid for the USB SuperCodec (Software, Free)
  • USB SuperCodec PCB pattern (PDF download) [01106201] (Free)
  • USB SuperCodec Balanced Input Attenuator add-on PCB pattern (PDF download) [01106202] (Free)
  • USB SuperCodec front panel artwork (PDF download) (Free)
  • Drilling and cutting diagrams for the USB SuperCodec Balanced Input Attenuator (PDF download) (Panel Artwork, Free)
Articles in this series:
  • USB SuperCodec (August 2020)
  • USB SuperCodec (August 2020)
  • USB SuperCodec – part two (September 2020)
  • USB SuperCodec – part two (September 2020)
  • USB SuperCodec – part three (October 2020)
  • USB SuperCodec – part three (October 2020)
  • Balanced Input Attenuator for the USB SuperCodec (November 2020)
  • Balanced Input Attenuator for the USB SuperCodec (November 2020)
  • Balanced Input Attenuator for the USB SuperCodec, Part 2 (December 2020)
  • Balanced Input Attenuator for the USB SuperCodec, Part 2 (December 2020)

Purchase a printed copy of this issue for $10.00.

by Andrew Woodfield Using fewer than twenty inexpensive parts, this compact little audio oscillator can fit into your shirt pocket, yet it delivers a super-accurate sinewave when and where you need it. It even fits into a snazzy 3D-printed case! A Shirt-Pocket Crystal-locked Audio DDS Oscillator C ing tested. That can be handy in some ler, a rotary encoder with integrated ompact, battery-powered test audio test setups. push switch for output frequency segear is really useful if you have lection, a compact I2C OLED display to travel a lot. It can be invaluCircuit description to show the selected frequency, and a able for some professional tasks in reThe complete circuit of the audio crystal for accurate timing. mote places, or you can use it to work oscillator is shown in Fig.1. It uses an A few other passive components on your own projects while out and Atmel ATtiny85 8-pin microcontrolcomplete the design. about, should the opportunity arise. The ATtiny85 micro (IC1) forms This equipment must be small, the heart of the design. Its main clock light, and inexpensive. It’s all too is generated using a standard 8MHz easy for equipment to be damcrystal with two 15pF ceramic load aged or lost. capacitors, and its internal oscillaThis oscillator is equally usetor amplifier. ful around the workbench. It deThe small 64x32 pixel OLED dislivers very accurate audio tones, play is used to show the selected just like much larger and more audio output frequency. A customexpensive equipment. designed font provides excellent disBeing battery-powered and in a play clarity. It connects to the small plastic case, it’s easy to Actual size of the case (including knobs) is 75 x 30 x isolate it from the circuit be- 50mm so it will easily fit in your pocket (as shown above). ATtiny85 via a two-wire I2C 42 Silicon Chip Australia’s electronics magazine siliconchip.com.au bus (SDA for data and SCL for clock). Two I2C bus pull-up resistors are typically connected to each of these I2C bus lines. Here, these resistors are inside the OLED display module, reducing the parts count. Compatible OLED screens are made by several vendors; most data sheets give 3.3V as the maximum supply voltage. A few suppliers suggest they can run off 5V, but we’re keeping it under 3.3V for wider compatibility. A standard ATtiny85 chip will operate from 2.7V to 5.5V, according to the Atmel/Microchip data sheet, with a maximum clock speed of 4MHz at 2.7V. However, I bench tested more than 30 devices from multiple batches and found that they will cheerfully operate down to 1.65V using either the internal or external 8MHz clock. Therefore, I thought it reasonable to power the device directly from a battery of two regular AAA cells in series. It’s a simple solution supplying a nominal 3V for the modest load current of 10mA. The battery life will vary depending on specific requirements. The oscillator, including display, will successfully operate down to the typical end-of-life voltage of the pair of AAA batteries, around 1.8V. Given this, you can expect about six months of intermittent use, ie, an hour or so of use every couple of days. Rotary encoder The rotary encoder selects the re- Features & specifications • Frequency range: 1-9999Hz in 1, 10, 100 or 1000Hz steps (user selectable) • Frequency accuracy: crystal-locked to within 0.002% at 1kHz • Output level: 0 – 1.5V peak-to-peak (0 - 530mV RMS) sinewave (3V supply) • Total harmonic distortion (THD): less than 3% • Display: 0.49in (12.5mm) 64x32 pixel OLED • Power supply: 2 x AAA cells <at> 10mA typical • Battery life: estimated six months of intermittent use • Enclosure: 3D-printed compact clip-together PLA clamshell or standard Jiffy box • Size (in clamshell case): 75 x 30 x 34mm (excluding 3D-printed knobs)    75 x 30 x 50mm (including knobs) • Weight: 75 grams (with battery) quired output frequency and the tuning step size. The photo overleaf shows what a typical quadrature rotary encoder with pushbutton looks like. The circuit arrangement used here is unusual, detecting rotary encoder rotation and button pressing with a single I/O pin on the microcontroller! Usually, the two quadrature outputs of a rotary encoder are connected to separate pins on the microcontroller. The integrated pushbutton switch on the encoder then often demands an additional pin. That would result in the need for at least 10 pins total on the microcontroller in this application. Instead, I have used a basic threeresistor analog-to-digital converter (ADC) along with a noise-reducing 10nF capacitor to connect all three switches internal to the rotary encoder to one micro I/O pin. The component values used are important. They ensure that the closing of any of the internal three rotary encoder switches will generate a logic high-to-low ‘pin-change’ interrupt on the microcontroller. This allows the use of an event-driven interrupt handler routine to quickly and efficiently update the audio oscillator frequency within the very fast ‘direct digital synthesis’ (DDS) software loop. This DDS software method prevents the use of the commonly used periodic timer interrupt, which would introduce a regular and unacceptable pause in the sinewave output. The pinchange interrupt method also delivers an improved encoder response; there is no need to wait for a periodic timer to detect rotation or switch closure. The response to rotating the knob is immediate.     SC  SHIRT POCKET AUDIO OSCILLATOR Fig.1: the complete Audio Oscillator circuit. It is based around microcontroller IC1, an OLED display, a rotary encoder and an output filter/level control. The filter converts the 62.5kHz PWM signal from pin 6 of IC1 (which has a varying duty cycle) into a smooth sinewave by removing the higher frequency components. siliconchip.com.au  Australia’s electronics magazine  September 2020  43 Scope1: the waveform at pin 1 of IC1 when rotary encoder RE1 is rotated one step clockwise. Oscilloscope screen grabs Scope1 & Scope2 show the resulting waveforms at pin 1 of the micro, for clockwise and anticlockwise rotation respectively. The sharply falling leading edge triggers the interrupt. The two different waveforms which follow this leading edge for each direction of rotation are then detected by the software by sampling the analog voltage on that pin. The tuning step size is changed using the encoder’s integrated pushbutton. Pressing this pulls pin 1 of IC1 directly to ground, below the voltages produced by encoder rotation. This allows the micro to detect the button press and switch to the next step size (1, 10, 100 or 1000Hz). The 10nF capacitor prevents switch bounce from interfering with the process of detecting encoder rotation. Sinewave generation The audio output tone is generated using pulse-width modulation (PWM) from one of the ATtiny85’s internal counter-timers, which is fed to its dig- Fig.2: potentiometer VR1 allows the output level to be adjusted over the full range of 0-530mV RMS. However, if you want switchable ranges, they could easily be incorporated using a scheme like this. 44 Silicon Chip Scope2: the waveform at pin 1 of IC1 when rotary encoder RE1 is rotated one step anticlockwise. It is almost a mirror image of Scope1. ital output pin 6. Its 62.5kHz modulated carrier is higher than usual with an 8MHz crystal; a tradeoff resulting in 1% higher distortion. A simple passive 3-pole elliptical low pass filter comprising three capacitors and one inductor, after the 1kΩ resistor from pin 6, filters out the carrier from the wanted sinewave. This filter has a 40dB notch around 60kHz. This filter method reduces current consumption and the component count. The PWM output is matched to the filter using that 1kΩ resistor. Otherwise, the low output impedance of the microprocessor pin would cause increased waveform distortion, particularly below about 1.5kHz. The filtered sinewave output voltage level of about 1.5V peak-to-peak can be adjusted using the front panel level control potentiometer, VR1. Resistor RX is optional. It may be a simple wire link if the output range is suitable for your applications, or an extra resistor can be added to reduce the maximum level. Alternatively, a two- or three-way switch and additional resistors could be added in series with the output potentiometer to provide a range of output levels, if space permits. Fig.2 shows one possible arrangement using a three-way switch. Space has been provided for wiring this into the PCB using the connections for RX. The version described here does not implement this optional feature, making the finished oscillator as small as possible. The output does not include any DC blocking capacitor. Most equipAustralia’s electronics magazine ment you would feed the sinewave into will have an input capacitor. But if required, a suitable capacitor could be squeezed into the remaining space around VR1. Software The software is written using a mix of assembly code and BASCOM, the BASIC-like compiled language for the Atmel/Microchip AVR family. Assembly code is used for the core tone generating routine which must be very fast. Other sections, such as the interrupt handler code and the I2C and OLED routines, are written in BASIC as they are not so speed-critical. The DDS lookup table contains 256 bytes of data defining the amplitude of the sinewave over time. The frequency is precisely determined by the value of the 24-bit word used to increment the DDS cycle accumulator. One byte (eight bits) of this word is used as a pointer into the sinewave amplitude data, with the other two bytes (16 bits) represent the fractional position. The 24-bit wide accumulator ensures excellent frequency precision, along with the accurate and stable crystal-controlled processor clock. A fast interrupt subroutine handles the rotary encoder and tuning step size selection. It looks for specific voltage changes to determine the direction of rotation, the number of turns, and the selection of tuning steps. The interrupt routine unavoidably disrupts the output waveform briefly while the frequency change is being made. But the waveform is never going to be pure when the frequency is siliconchip.com.au being adjusted anyway. Screen updates for the ultra-compact 64 x 32-pixel OLED display are sent via the I2C serial bus. The display’s integrated SSD1306 controller requires careful initialisation to deliver correct operation. Its parameter settings differ significantly from those needed for the larger and more common 128x32 or 128x64 OLED displays, despite using an identical controller. The display software also makes use of a purpose-designed character font for this display, shown in Screen1. It aims to maximise character clarity and visibility despite its size. The resulting four-digit display largely determines the frequency range of the oscillator. Displaying frequencies of 10kHz or above accurately would require five digits. That would reduce display clarity beyond acceptable levels, particularly for those of us with reduced visual ability. Note that smaller 0.42in (diagonal) 72x40 pixel OLED displays are available but oddly, they are built on a larger PCB than the 0.49” 64x32 pixel OLED display I chose! So there is little benefit in using one, but if you have one, it will work. The software is also compatible with some, but not all, 0.96in 128x64 OLED displays using SSD1306 controllers. A few of these have extremely slow (faulty) I2C reset performance and will not operate correctly with this software. The software will not work with any OLED displays fitted with an alternative “compatible” SH1106 controller. Rotary encoder selection The rotary encoder used in this design is critical. It must be a pulse-type rotary encoder. Unfortunately, these are visually indistinguishable from level-type encoders; worse, most suppliers will not tell you which type they are selling! Electrically, however, they are quite different. The two outputs on leveltype encoders change at the ‘click’ or detent as the shaft is rotated, with the two encoder output pins remain fixed in one of the encoder’s four quadrature output states when the shaft is stationary. In contrast, pulse-type rotary encoders produce a pair of short quadrature pulses mid-click, with both encoder output pins resting open circuit. These encoders are the most commonly supsiliconchip.com.au Parts list – Audio DDS Oscillator 1 PCB coded 01110201, 65.5 x 24.25mm 1 8MHz low-profile crystal (X1) [Altronics V1249A] 1 ATtiny85 8-bit microcontroller, DIP-8, programmed with 0111020A.hex [Jaycar ZZ8721 or Altronics Z5105] 1 8-pin DIL IC socket 1 pulse-type rotary encoder with integrated pushbutton switch (RE1) [see text] 1 DPDT slide switch (S1) [Jaycar SS0852, Altronics S2010] 1 0.49in 64 x 32 I2C OLED display module [eBay, AliExpress etc] 1 15mH molded radial choke (L1) [eg, Murata 17156C (Digi-Key) or Murata 22R156C (RS)] 2 2-pin headers and matching sockets (CON1 & CON2; optional) 1 4-pin SIL header socket, ideally a low-profile type (CON3) 1 4-pin header (plugs into CON3; may come with OLED screen) 2 knobs to suit RE1 & VR1 [3D printed or Altronics H6016] 1 2 x AAA side-by-side cell holder (optional; see text) [Jaycar PH9226, Altronics S5052] 1 pair of small alligator clips [Jaycar HM3020, Altronics P0101+P0102] 1 3D-printed plastic enclosure, assembled size 75 x 30m x 34mm (or a UB5 Jiffy box – see text) 1 300mm length of light- or medium-duty two-core cable 1 100mm length of red light-duty hookup wire 1 100mm length of black light-duty hookup wire 1 20mm length of insulated solid-core wire (eg, bell wire or breadboard jumper wire) Capacitors 1 4.7µF 50V electrolytic 1 100nF ceramic 2 33nF MKT or greencap 1 10nF MKT or greencap 1 470pF ceramic 2 15pF ceramic Resistors (all 1/4W 1% metal film) 1 10k 1 3.9k 1 1.8k 1 1k 1 1k linear 9mm potentiometer (VR1) [Jaycar RP8504, Altronics R1986] Programming Adaptor Board (optional) 1 PCB coded 01110202, 25.5 x 22mm 1 8-pin DIL IC socket 1 3x2 pin header (CON4) 1 3mm red LED (LED1) 1 100nF ceramic capacitor 1 1k 1/4W resistor plied at low cost from Asian sources. This open-circuit condition at the rest position is critical for generating the desired encoder interrupt waveforms A mugshot of the troublesome rotary encoder. Unfortunately, level-type encoders are externally indistinguishable from the pulse-type encoders that we need. You just have to take an educated guess about which one to order, then test it when it arrives, using the procedure described in the text. Australia’s electronics magazine used in this design. These two encoder types can be quickly and easily distinguished with a continuity tester. An encoder can be tested using an ohm-meter or even an arrangement as simple as a series LED, resistor and battery as follows: 1. Connect one lead of the continuity meter to the centre pin of the three (ignore the two on the opposite side). 2. Connect the other lead to one pin on either side of the centre pin; it doesn’t matter which. 3. Rotate the shaft one click. 4. Measure the continuity while the encoder is at rest. 5. Repeat steps 3 and 4 several times. September 2020  45 Fig.3: the components mounted on the PCB, with matching photos to assist assembly. Don’t fit CON1 & CON2 when using the printed case. The wire link (shown in red) is not needed on  commercially-made double-sided boards. The OLED screen     (not shown in the photo at right)       plugs into CON3 after the other components have If the encoder is a pulse type, the been fitted. meter should show an open circuit     (very high resistance) at all rest positions. You should see a brief period of continuity (low resistance) while rotating the encoder. If the encoder is a level type, the meter will show continuity on every second detent position and an open circuit on the other detent positions. So my suggestion is to order an encoder from a website like ebay, AliExpress or Banggood and then verify that it is the pulse type using the above method before proceeding with construction. Construction The Pocket Crystal Audio Oscillator is built on a PCB coded 01110201 which measures 65.5 x 24.25mm. I etched mine at home, but the commercially-made version available in the SILICON CHIP ONLINE SHOP only costs a couple of dollars. Refer to the PCB overlay diagram, Fig.3, to see which parts go where. For those making this single-sided PCB at home, the board may be left square if it will be fitted into a Jiffy box, or trimmed carefully along the curved PCB outline if using the 3Dprinted enclosure. Construction should begin by fitting the resistors and then the capacitors. The single electrolytic capacitor is the only polarised one; its longer lead goes into the pad nearest the edge of the board, marked with a + symbol. Also, space the 4.7µF electro off the board by about 1.5mm to allow it to be bent over when inserted later into the 3D printed case. Next, solder the crystal onto the PCB, followed by the 8-pin IC socket. Ensure that the pin 1 notch on the socket faces in the direction shown. If you’ve etched the board yourself, you need to fit one insulated wire link, shown in red on Fig.3. The commercial board should have a top layer track joining these points, so you won’t need to install a link. Next, mount the four-way header socket for the display (CON3), then the 15mH moulded inductor. Follow with the rotary encoder and potentiometer. Depending on the type of 9mm potentiometer you purchase, it may either mount directly onto the PCB or use component lead off-cuts to extend its leads to allow vertical mounting. If doing that, it would also be a good idea to glue the pot body to the board (eg, using neutral-cure silicone) as horizontal pots lack the mounting tabs of the vertical types. Next, fit a pair of thin, 50mmlong red and black insulated stranded wires to CON1 for power. You can use a header and socket or, as I did, simply solder the wires to the PCB pads. Similarly, connect the 300mm output twin lead to CON2. If you don’t have twin lead, you could use heatshrink tubing on a pair of individual light- or medium-duty hookup wires. Do not fit anything to the other end of these wires just yet. Programming IC1 If you have a blank micro, program it as per the box labelled “Programming the ATtiny85”. After programming (or if you purchased a preprogrammed micro), plug it into the socket, ensuring that its pin 1 dot lines up with the notch on the socket. You may need to straighten its leads to fit into the socket. Be careful not to allow any of the leads to fold up under the chip body during insertion. Next, plug the OLED display into its socket on the PCB. The screen is usually supplied with a four-way 0.1inpitch header. If it has not already been fitted to the display PCB, solder it now. Next, if you’re using a standardheight header socket for CON3, use Audio DDS Oscillator Hz TUNE LEVEL Fig.4: this artwork can be printed, laminated, cut out and attached to the front panel of the unit using glue or double-sided tape. You can also download this as a PDF from the SILICON CHIP website. 46 Silicon Chip Fig.5: renderings of the 3D printed front and rear panels that form the custom case, along with the 3Dprinted knobs. The associated STL files can be downloaded from our website, or you can purchase these pre-made. The back panel has an integrated battery holder, but you need to fabricate or acquire the spring terminals and clips (eg, as part of the SILICON CHIP kit), as described in the text. Australia’s electronics magazine siliconchip.com.au Programming the ATtiny85 If you haven’t purchased a preprogrammed ATtiny85, you will need to program your blank chip before you can use it. You can use an AVR ISP programmer such as the USBasp (See www.fischl.de/usbasp/). It can be purchased online from many suppliers, often for less than $3, including delivery! Such programmers are used with a PC or laptop; suitable software is available for Windows, Linux and macOS. This description will focus on the Windows platform. The drivers for the chosen programmer must be installed before using it. The drivers for the USBasp can be obtained from the link above. Programming software is also required. (Freeware) software for Windows includes eXtreme Burner (siliconchip.com.au/link/ ab3m), AVRDUDESS (siliconchip.com.au/link/ab3n) and Khazama (http://khazama.com/project/programmer/). There are many websites and YouTube videos describing the setup and use of these programs. Here is a summary of the procedure required to program the ATtiny85 for this project: 1) Load the USBasp drivers. 2) Plug in and complete the installation of the USBasp programmer. If the option is present on the USBasp programmer, and some boards support this feature, select 5V operation rather than 3.3V for programming the ATtiny85. 3) Download the programming software and install it. 4) Open the programming software and select ATtiny85 as the target device. 5) Download the HEX file for the audio DDS generator and select it as the file to be used to program the ATtiny85. 6) Plug the six-pin connector from the USBasp programmer into CON4 on the Programming Adaptor Board (more on this below). 7) Select “Write FLASH buffer to chip” or “Write – Flash” to program the ATtiny85 with the HEX file. The LEDs on the USBasp will blink furiously for about a minute while the HEX file is being   The ATtiny85 Programming Adaptor circuit just connects the micro pins to the 6-pin programming header, with a small power supply bypass capacitor. a spudger or a sharp-edged blade to carefully slide off the plastic pin separator from the pin header. Then trim the four pins shorter by about 2mm. This allows the display to fit as closely as possible to the top of the ATtiny85 chip. See the side view photo for an idea of how it plugs together. If you were able to get a low-profile header socket for CON3, that should not be necessary. It should just plug straight in, although you may still have to trim the header pins a little. The PCB can now be tested. Before you connect the 3V supply, carefully siliconchip.com.au programmed. A bar graph may be displayed to show progress. 8) Program the ATtiny85’s internal ‘fuses’. These memory locations configure the operating characteristics of the ATtiny85 to suit the software being run on the device. To do this, type in the following settings into the relevant Fuse page/section of the programming software, then click on “Write” to send the data to the fuses: Low: 0xEF High: 0x5F Extended: 0xFF (unchanged) Lock: 0xFF (unchanged) 8) Assuming the programmer reports the programming has been successful, remove the programming cable from the adapter board and transfer the ATtiny85 from the programming adapter board to its socket on the audio DDS oscillator PCB. Programming Adaptor Board There is no programming connector for the ATtiny85 on the oscillator PCB. I program my ATtiny85 chips using a separate adaptor built from a scrap of prototyping board with an 8-pin IC socket, the Atmel-standard 6-pin programming pin header and a couple of supporting components. The circuit diagram for my adaptor and the equivalent PCB are shown below. For those wanting to make a little PCB for this programming adaptor, if you don’t want to make it on veroboard, you can order this board when you order your main PCB (and possibly case), for just a couple of dollars more. The resistor and LED are optional. They show when power is applied to the Programming Adaptor Board from the USBasp programmer. The ATtiny85 to be programmed is plugged into the 8-pin IC socket; make sure it is orientated correctly, with its pin 1 dot near the notch. The USBasp programmer plugs into CON4, with its pin 1 towards the IC socket. Power for the programming adapter board comes from the USBasp. If your USBasp or similar programmer has a selection of programming voltages available, it’s best to select ‘5V’ for reliable programming of the ATtiny85. Fit the components as shown here; the two wire links can be made from component lead off-cuts. Pins 1 of both the IC and CON4 are at upper left. check all of your soldering for shorts or missed connections. If it looks OK, connect up a 3V supply (important: no more than 3.3V!) and check that the Oscillator operates as expected. Making the enclosure The enclosure should now be prepared and assembled with the battery holder and power switch. You can purchase a small Jiffy box enclosure from the usual suppliers if you wish. Alternately, you can get the 3D printed custom enclosure parts from the SILICON CHIP ONLINE SHOP, or Australia’s electronics magazine make them yourself if you have a 3D printer – see Fig.5. There are two files required to print the enclosure; the first is for the front panel half of the enclosure, the second is for the rear half with its integrated battery holder. These are available for download in the standard STL format. These can be 3D printed using standard PLA filament in any colour. The prototype enclosure was printed using grey filament with 50% fill and a 0.2mm layer thickness, although these parameters are not critical. Each half requires about 2g of filament. If you September 2020  47 One half of the custom case houses the PCB while the batteries fit neatly into the other half. The alternative would be to build the Audio Oscillator into a small jiffy box (or similar) but you probably won’t be able to fit it into your pocket! do not have your own 3D printer, it is also possible to go to a Jaycar maker hub and do it there. The two halves of the enclosure clip together firmly without the need for additional screws. The rear section’s integrated battery holder is dimensioned for two AAA cells. It requires the addition of battery contacts, wiring, and a battery joiner. The battery contacts can be made by cutting 4mm and 3mm diameter circles from thin tinplate. A scrap piece of 0.2mm-thick tinplate was used for the prototype. It is possible to recycle a domestic tin can; Milo tin lids are nice and flat. These handmade battery contacts should approximately match the divots provided inside the battery holder at the switch end. Solder a 10mm length of thin red multi-stranded insulated wire to the centre of the smaller circle and a similar length of black wire towards one edge of the larger circle. The wire should then be fed through the switch end of the battery holder, and the metal circles glued in place using epoxy. Once the glue has set, test-fit a pair of AAA batteries. These should clip firmly into place side-by-side, but they will likely slide back and forth in the holder by about 1-1.5mm. Bend the battery joiner to take up that space. There is a slot provided for this foldScreen1: despite being quite tiny (at around 12mm diagonal – it’s shown here about twice life size), the currently selected frequency is clear due to the bold font, with its four digits occupying the entire width of the screen. 48 Silicon Chip ed joiner to be inserted into one end of the battery compartment. To make this, cut a 60mm x 8mm strip of tinplate. Trim and bend it approximately into a flattened C shape to fit the available space. When folded correctly, the batteries will fit snuggly into the battery holder. Along with the PLA plastic of the case, the arrangement will also provide a little tension to maintain good battery contact. A useful accessory during this process is a voltmeter clipped to the black and red wire. This allows all of the connections to be checked for reliability during final assembly. Completing construction The wiring to the slide power switch can now be completed. Begin by connecting the short red and black wires from the PCB to the switch. They should be about 50mm long. Make sure the power switch is off and the batteries are removed from the holder before soldering the power wiring in place. The switch can now be mounted on the rear panel using a little hot melt glue or neutral-cure silicone sealant. If your slide switch has mounting tabs, trim these off first using a pair of side-cutters. Mount the PCB in the front half of the enclosure, first feeding the output wires through the hole provided. The PCB assembly is mounted using the nuts and washers supplied with the rotary encoder and potentiometer. Vertical-mount potentiometers may not have nuts; in this case, it will just be the rotary encoder boss and nut holding in the board. The small alligator clips may now be fitted to the output wires. Alternately, if you are using a Jiffy box, you may prefer to use a small output connector mounted on one end of the box. Options include a panel mounted RCA socket (eg, Jaycar Cat PS0270 or Altronics Cat P0161 etc), or a 3.5mm audio socket (eg, Altronics Cat P0093 or Jaycar Cat PS0122 etc). Print the front panel artwork (Fig.4) and attach it to the front of the enclosure. The artwork can be printed using a colour laser or inkjet printer. Trim the artwork to size and cover it with self-adhesive transparent film. This panel artwork can then be glued Australia’s electronics magazine to the front of the enclosure. Doublesided adhesive tape can be used quite successfully. If using glue, it is desirable to cover the rear of the artwork first with another piece of self-adhesive film to prevent the glue bleeding through the printed artwork. The two knobs can now be fitted to the control shafts. The prototype used two knobs specifically designed for the unit which were 3D-printed (see Fig.5). These STL files are also available for downloading, or if you purchase the 3D printed case, it will come with the knobs. These slide firmly onto the respective control shafts. Alternately, see the parts list for commercially-made alternatives. The final step is to install the battery. Then clip the case together, and the oscillator is ready for use. Operation It couldn’t be easier. Switch it on, select the frequency you want with the tuning knob, set the desired output level with the level control, and you are in business. Press the tuning knob to step through the various frequency step options: 1Hz, 10Hz, 100Hz, 1kHz and then back to 1Hz again. Despite its simplicity, this compact little audio oscillator is surprisingly useful. I hope one of these finds a home in your shirt pocket too. SC OBTAINING THE PARTS Because of the difficulty in sourcing the pulse-type rotary encoders used in this project with any certainty, the SILICON CHIP ONLINE SHOP will be stocking and selling them (Cat SC5601). We will check each batch to make sure they are the right type! This part can also be used in some of our previous projects, such as the AM/FM/CW Scanning HF/VHF RF Signal Generator and the DIY Solder Reflow Oven. We have also decided to offer an (almost) complete kit for this project, Cat SC5622. It will include the programmed micro, PCB, all onboard parts, and 3D-printed case. The case has been tweaked to accommodate pre-made AAA battery clips, which will also come in the kit. We’ll be supplying standard knobs with the case (not 3D printed). The only parts not included are the wires and battery. See our Online Shop on pages 104 & 105 for more details. siliconchip.com.au