- how to build your own units of nano SwinSID b -

Introduction
This tutorial explains how to build your own units of nano SwinSID, the reduced size version of the SwinSID. 
SwinSID is a microcontroller based clone of the SID, the audio chip used in nearly all 8-bit Commodore computers in the 80's, and later in some chiptune synths like SIDStation. The original SID ( Sound Interface Device) was designed by the engineer Robert Yannes and produced by Mostek under the names MOS 6581 and MOS 8580 from the early 80’s to the early 90’s. Despite the production of the original SIDs stopped years ago, you still can find spare units of unknown origin in some internet sales sites, but they are very expensive and usually have some of their parts damaged ( it is not strange to find units with malfunctioning filters or oscillators ).
The SwinSID clone was designed by Swinkels in 2005, who made different improvements on it along the years. A user of the forum64.de, named x1541, reduced the size of the PCB of one of the spin offs of the original project named micro SwinSID. This reduced size version is known as nano SwinSID. SwinSID is not 100% compatible with the original SID but is the most popular of the few options that exists to replace the original SIDs. The current version of nano SwinSIDb does not implement the analog inputs for the paddles, does not have the audio EXT input, and in some cases may not treat the sound exactly in the same way than the SID,  but is a very good alternative to it. Swinkels explains very well in his site the advantages and limitations of the Swin SID.

nano SwinSIDb next to an original MOS6581
Despite most part of the information of the project is available in Swinkels webpage, It may not be enough to to build the nano SwinSID from scratch. I had to search on the author’s web site but also in other internet forums and pages to get all the information to build my units of the nano SwinSIDb (ie nightfallcrew , lemon , forum64). I created this page to make easier the work to those interested on building their own units of this SID clone.
Material and tools
This is the bill of materials and the tools you’ll need to build your own nano SwinSIDs:
- SwinSID Printed Circuit Board: you can make your PCBs at home ( something difficult if you don’t have experience ) or place an order to a PCBs manufacturer. To produce a PCB in a specialized manufacturer you must send him the Gerber files. Gerber files contain the layout of the copper layers, the position of the drills, the solder mask etc. and are created from the circuit schematics.

SwinSID schematics
As I couldn’t find the Gerbers of the last version of the nano SwinSID on the Internet ( the version that has two jumpers ) I decided to create them myself in Altium. I first created the schematics, and then the PCB layout. Once I had the PCB design I generated the Gerbers. As you can see, the schematics correspond to the SwinSID version that uses the Atmega88PA. It also has two jumpers, one to set the MOS6581 or MOS8580 filter emulation mode (J1), and the other to adjust the output voltage level (J2). I also added an optional LED in the bottom side of the PCB to create a cool illumination effect under the nano SwinSIDb when it is mounted on the board. This is the reason why I renamed the board with a b ( nano SwinSIDb ) to differentiate it from x1541's version of SwinSID you can find on the Internet. Removing the ground plane would have made the board more translucent and this would have increased the beauty of this effect, but I prefered to keep the plane to make the circuit more resistant to undesired EMC effects or audio corsstalk problems.

Illumination effect with the optional LED under the nano SwinSIDb
These are the recommended PCB production parameters values for the nano SwinSIDb:  
   - PCB Thickness:1.6mm
   - Surface Finish: HASL
   - Copper Thickness: 1oz
   - PCB Color: the one you prefer...

nano SwinSIDb PCBs in different colors
- Nano SwinSIDb electronic components: these are the components that must be soldered on the PCB. Pay attention to the encapsulate of the components when you place the order, most of them are SMD ( Surface Mount Technology ). Take a look to the pictures and the PCBs images before buying them to be sure that you choose the right encapsulates. These are the nano SwinSIDb components:
   - Resistors:  all 0805 SMD, R1: 1K, R2: 240K, R3: 1K, R4: 2K2, R5: 4K7
   - Capacitor: 0805 SMD, 1206 SMD, or throug-hole,  C: 100n
   - Microcontroller: 32 pins TQFP, U2: ATmega88PA
   - Oscillator:  SMD , U5: 32Mhz
   - Jumpers: throug-hole 2mm pitch, J1 , J2
   - Pin strip:  throug-hole 2.54mm pitch, 2 x 14pins. Turned pin strips are recommended to avoid problems when inserting the nano SwinSID into the SID socket.
   - Optional : 0805 SMD, R6: 330 and SMD 5V LED
- Solder Iron and other tools: to solder the SMD components you will need a solder iron with fine tip and not excessive power ( 11 W may be enough ). You will also need the tin wire and tweezers to hold the SMD components over the board while you solder them. It may be useful to have at hand desoldering wire, flux and any kind of holder to hold the small board while you work on it.

Tools
- Firmware programming tools: the microcontroller must be programmed with the SwinSID firmware. To program the firmware you’ll need:
  - a programmer with support for Atmel ISP programming protocol.
  - the special cable to connect the ISP programmer to the nano SwinSIDb board.
  - the software tool to control de the programmer.
  - a 5V power supply or a 5V adapter to power the chip when you program it.
There are different programmers with Atmel ISP protocol support. I use my chinese JTAGICE mkII clone, but there are other cheaper devices like the AVRISP that work very well. If you have to buy a new programmer, Atmel ICE is the best option. If you still have parallel port on your computer and don’t want to spend money on a new programmer you can build your own ISP programmer with a DB25 connector and some wires and resistors.

Programming cable adapter and Atmel ICE programmer.

Atmel ISP compatible programmer with the cable adapter

nano SwinSID special programming cable adapter
To send the firmware to the microcontroller you will also need the firmware file and the software tool to control the programmer. For that purpose, you can use Atmel Studio, AVR Studio, AVRDude or any other software compatible with your programmer. 

I haven't been able to find the original assembly source code of the provided .hex nano SwinSID firmware. For that reason I decided to disassemble it and try to understand how it works. Here you'll find a Microchip Studio solution with the disassemled firmware. It would be very interesting to have the original source code with the right program structure, variables and subroutines names and author's comments. So, please contact-me if you find it, and I will post it here to make it available to everybody.
Steps
These are the steps to build your own units of nano SwinSIDb:
- Get the PCBs: create them yourself or order them to a PCBs producer. The second option is the easiest option and the one that will give you more professional results. To produce the boards you’ll have to find a PCB producer first . Remember that there are some cheap prototyping producers like Itead Studio or Seed Studio, that have very reasonable prices for small series. Once you find your PCB producer, he will ask you for the Gerber files and also for the PCB production parameters ( and the money :) ).

Nano SwinSID PCBs
- Get the electronic components: probably you won’t find all the nano SwinSIDb components on your local electronic components store, so the best option is to order them to an online electronic components store like RS-Amidata, Farnell, Mouser or Digikey. Don’t forget to pay attention to the encapsulates when you place the order.

Components
- Solder the electronic components: once you have the PCBs and the components you’ll have to solder them on the board with SMD iron solder. Pay attention to not short circuit any of the pins of the microcontroller, and check the components orientation before soldering. If you decide to solder the LED, be careful with its orientation too. If it you place it in the wrong orientation it won’t bright. Check everything when you finish.

Components placement
The oscillator and the microcontroller are the most delicate parts to solder. Some oscillators have small cooper spots near the pads: avoid putting tin on them and on the encapsulate metal surface or you will have undesired short circuits on the component. Place tin and solder only the pads of the component. The next video shows all the assembly phases, including the soldering process:

Video that shows the whole assembly process

- Program the microcontroller: to program the microcontroller with the provided firmware, the nano SwinSIDb board has to be connected to the Atmel ISP programmer with the cable adapter, and then powered with 5VDC ( pin 14 to GND an pin 25 to 5VDC). I created a small board with an LM7805 regulator to power the device while programming it, but there are other simpler alternatives. One is using a standard 28 pins wide DIP socket, cutting to it all the pins less the 14-GND and 25-VCC and then connect the nano SwinSIDb with that socket to a Commodore or a SID Synth to get the 5VDC.

nano SwinSIDb optional Power Board
After having connected to the programmer and powered the nano SwinSIDb , use the programming software tool ( Atmel Studio, AVR Studio .. ) to program:
- The flash memory : with SwinSID’s application binary.
- The fuses: to set the right clock sources and values.

Get device info to check that communications between the uC and the programmer are OK.

Program the Flash memory with the provided .hex file. EEPROM does not need to be programmed.

Fuses configuration. Be careful when programming the fuses.

Don't modify the lockbits!
Be careful when programming the fuses. A wrong fuses configuration can make the  microcontroller not to work and very difficult ( or impossible ) to program again. Don’t modify the Lock Bits either.
- Test: install the nano SwinSIDb in a synth or in a Commodore and check that it sounds properly. Remember to set the jumpers in the right configuration ( a wrong jumper configuration should not damage anything ):
-J1: this jumper allows selecting between MOS6581 or MOS8580 filters emulation. ATmega's PB port bits have pull up resistors, so when the jumper is not placed, PB0 input is set to Vcc=5V ('1') and in this situation the MOS8580 filter model is enabled. When J1 is placed PB0 input is set to GND ('0') and in this situation the MOS6581 filter model is enabled. In other words: with J1, MOS6581 filter model is enabled, without J1, MOS8580 filter model is enabled.

-J2: nano SwinSID has an output resistor net which has a 1K resistor connected to ground ( R3 in the schematics ). The Commodore boards which use the MOS6581 already have a 1K resistor from the SID output to ground, and this is the reason why on this boards the 1K R3 resistor of the nanoSwinSID is not necessary. In this case you can choose between not soldering the R3 resistor or disabling it by removing the J2 jumper. Enabling R3 resistor in MOS6581 boards would be equivalent to have a 1K/2=500 resistor from the output to ground, and this would increase the voltage lost in R5 ( and R4, R1 and R2 ). This would make the output voltage lower and the nano SwinSID sound weaker. The Commodore boards that use the MOS8580 SID version don't have this 1K resistor from the output to ground, and in this situation the nano SiwnSID 1K resistor must be enabled placing the J2 jumper. So if your board uses a MOS6581 leave the jumper open, and close it if it uses a MOS8580. In case you use the nano SwinSIDb on a synth you should check the path of the audio output signal to see if it already has any resistor connected to ground.


Two nano SwinSIDb finished units

Bottom side with the optional LED
Download
Here you'll find all the files needed to build, program and test your nano SwinSIDs. All these files are provided "as is", without warranties or conditions of any kind, either express or implied, including, without limitation, any warranties or conditions of title, merchantability, fitness for a particular purpose. You are solely responsible for determining the appropriateness of using or redistributing the work and assume any risks associated with it.
These are the necessary files to build the nano SwinSIDb:
- Gerbers: the ZIP with the nano SwinSIDb PCB production files y created. These are the files the manufacturer needs to create the PCBs.
- nano SwinSID firmware for ATmega88PA (v24/5/2012): the .hex file with the binary code to load into the microcontroller's Flash. This is the latest nano SwinSID firmware version I know (24/5/2012). I got it from here. Here you'll find a Microchip Studio solution with the result disassemling this firmware version.
Other interesting files related to the project:
- Schematics and PCB design of nano SwinSIDb: this ZIP contains the DXP-Altium 14.1.15 schematics and PCB layout I desgined to create the nano SwinSIDb board. You can download it to take a look to it or to modify it.
- x1541's schematics and PCB dessign of nano SwinSID: this ZIP contains the Eagle files of the original nano SwinSID PCB designed by x1541 ( the forum64.de user ). It only has one jumper. I used it as starting point to create my Altium nano SwinSIDb files. I obtained it here.
- An older nano SwinSID firmware version (?/?/2011): this ZIP contains the firmware I used before the latest 24/5/2012 version. It is larger than the latest version but I don't know which are the differences (23.1Kb vs 17.8Kb).
- 'Lazy' fix nano SwinSID firmware by Code Killer (19/10/2014): ZIP with a modified version of Swinkels firmware that improves the performance of the nano SwinSID on some Commodore 64 games ( i.e. Lazy Jones with David Whittaker themes ). I obtained it here ( on that forum you'll find very interesting comments from "nano Swin SID gurus" ).
- nano SwinSID firmware v24/5/2012 with no "ding" on reset (v01/12/2022): This ZIP contains the .hex file generated from the disassembly of the "v24/5/2012" version, from which the "ding" sound after resetting the microcontroller has been removed.


... this page was last updated by Tolaemon on 09-2015 ...