<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
  <style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
  margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
  </style>
  <link rel="stylesheet" href="styles.css" type="text/css" />
</head>
<body>
<h1 id="electronics-production">Electronics Production</h1>
<h2 id="introduction">Introduction</h2>
<p>I have worked with a CNC milling machine for my graduation project, at that time my instructor told me about using the CNC machine to produce a PCB since that I was curious about it. In this day I have learned about the PCB milling machine.</p>
<h2 id="design-and-milling">Design and milling</h2>
<h4 id="machine-set-up">Machine set up</h4>
<p>The day started by the design of the programmer. I have not designed it instead, I have downloaded it as a png picture. This website <a href="http://fabmodules.org/">fabmodules</a> is where the picture is converted to <code>.rml</code> format.</p>
<p>After the picture has been converter to the required format, I have started to set up the machine which is the SRM-20 machine.</p>
<p>The following images show the process of setting up the machine and preparing the spindle.</p>
<div class="figure">
<img src="images/1.jpg" />

</div>
<div class="figure">
<img src="images/2.jpg" />

</div>
<p>FR1 paper is used to produce the PCB, for the programmer one side paper is used, but for more complicated designs double side paper could be used. There are other types of paper like the FR4, but it is not recommended. When I was preparing the paper, I have hold it in the wrong way. My fingerprint can be seen in the following image, this may cause a short circuit if any design is produced over it.</p>
<p>The following photo also shows a number of milling bits. For the traces 1/64&quot; bit will be used whereas 1/32&quot; bit for the cover both are two flutes with the spindle diameter of 3.175mm. The cutting part of the bit must not too tall so that it does not break during the operation especially the traces bit.</p>
<div class="figure">
<img src="images/3.jpg" />

</div>
<p>The following image shows a rigid box of foam, this box is placed inside the machine because the bit can not go down in the z-axis and reach the paper. The following pictures show the process of placing the paper on the foam with a double face tape. During this process, I have checked several time for any bubbles. These bubbles will cause the surface to be uneven and may cause the bit to break.</p>
<div class="figure">
<img src="images/4.jpg" />

</div>
<p>Next step was to place the milling bit, this process is very sensitive, so the first thing to do was placing a sheet of cartoon over the FR1 paper to protect the bit if it falls down during the installation process. I have used two fingers also as shown in the following image to make sure the bit does not fall. I have fixed bit so that at least 20% of the spindle is visible for the purpose of setting up the zero z-axis.</p>
<div class="figure">
<img src="images/5.jpg" />

</div>
<h4 id="downloading-the-software">Downloading the software</h4>
<p>After setting up the SRM-20, I have downloaded the software starting from <a href="startup.rolanddg.com">this link</a>, I have opened an account on roland support to be able to download the software.</p>
<h4 id="producing-the-design">Producing the design</h4>
<p>Now the machine is connected to the computer. Before doing anything or starting any operation, the origin should be set. There are two coordinates, user and machine coordinated. User coordinate system should be zero in all directions then the milling operation can be started.</p>
<p>Last step is to remove the programmer from the FR1 paper, this can be done using a screw driver. The programmer must be removed easily otherwise start the operation again with a deeper z-axis. Fortunately the programmer is removed from the first time.</p>
<div class="figure">
<img src="images/6.jpg" />

</div>
<h4 id="problem-with-the-design">Problem with the design</h4>
<p>The first programmer had a short circuit, the problem is that the picture of the design is 600dpi so to solve this problem I have downloaded another picture for the same design, but with higher dpi. It was 1000 dpi.</p>
<h4 id="increase-usb-thickness">Increase USB thickness</h4>
<h2 id="soldering-and-testing">Soldering and testing</h2>
<p>ِAfter I have produced the PCB, I have started soldering the components. All the components are surface mounted which means that the component will not fit inside a hole, instead it will soldered on the PCB surface directly.</p>
<p>To start soldering, frist thing I did is preparing the soldering station. I have a solder station which needs a 110V input so I needed a transformer to covert the 220v output to the needed 110v.</p>
<div class="figure">
<img src="images/7.jpg" />

</div>
<p>Next, I have prepared the parts:</p>
<ol style="list-style-type: decimal">
<li>x1 ATiny 45 micro controller.</li>
<li>x2 1K ohm resistors.</li>
<li>x2 500 ohm resistors.</li>
<li>x2 50 ohm resistors.</li>
<li>x2 3.3v Zener diode.</li>
<li>x1 Red LED.</li>
<li>x1 Green LED, I have used Blue since I don't have Green.</li>
<li>x1 100nF Capacitor.</li>
<li>x1 2x3 Connector.</li>
</ol>
<h4 id="soldering">Soldering</h4>
<p>It not my first time to solder parts, actually I have soldered through hole components before, but this is my first time to solder surface mounted devices (SMD). The following image shows SMD soldering procedure.</p>
<div class="figure">
<img src="images/10.jpg" />

</div>
<p>One of the major differences I have found between through hole and SMD is that the component legs in the SMD is very small. I tired to use the magnifying glasses, but I found it difficult to solder so I relied on my naked eyes.</p>
<div class="figure">
<img src="images/9.jpg" />

</div>
<p>After I have soldered the components, I have tested the functionality by inspecting a short circuit and if the circuit is closed or not using a multimeter. The multimeter will make a beep sound if the circuit is closed.</p>
<p>I had four soldering defects, all in which the components were not soldered properly. The following images shows the defects.</p>
<p>500 ohm and the second leg of the micro controller were not soldered properly.</p>
<div class="figure">
<img src="images/11.jpg" />

</div>
<p>The diode and the 50 ohm resistor were also not soldered properly.</p>
<div class="figure">
<img src="images/12.jpg" />

</div>
<p>Another check I have did is to plug the usb to a USB port, the Red LED was illuminated.</p>
<h4 id="programming">Programming</h4>
<p>Now that my programmer is ready to be programmed,</p>
<div class="figure">
<img src="images/13.jpg" />

</div>
<p>I have installed the toolchain and the firmware using the following steps. First run the command <code>sudo apt install avrdude gcc-avr avr-libc make</code>, then I have downloaded the firmware from <a href="http://fab.cba.mit.edu/classes/863.16/doc/projects/ftsmin/fts_firmware_bdm_v1.zip">this link</a>, after that, I have opened the firmware directory using the command <code>cd &quot;directory&quot;</code> then I have executed the following command <code>make</code> to make the .hex file which will be uploaded to the miro controller.</p>
<p>To upload the .hex file, I will use atmelice so I have opened the <strong>Makefile</strong> using atom and changed the <strong>PROGRAMMER</strong> to atmelice then I have executed the following commands <code>make flash</code>, <code>make fuses</code>, <code>make rstdisbl</code>, <code>make rstdisbl</code>.</p>
<div class="figure">
<img src="images/14.jpg" />

</div>
<p>During this process, I have faced a problem which states that there is a problem with the connection, I have looked for a solution and found it in <a href="http://archive.fabacademy.org/2017/fablabspinderihallerne/students/63/week4.html">this link</a>. The solution was to change the <strong>PROGRAMMER</strong> to atmelice_isp instead of atmelice.</p>
<h4 id="testing">Testing</h4>
<p>My board is now a programmer, to the functionality of it, my classmates boards have used it to program their boards. They have followed the same procedure, but the <strong>PROGRAMMER</strong> was changed from atmelice_isp to usbtiny.</p>
<p>The following images show the procedure of making the connector cable so that my programmer could be used to program other boards.</p>
<div class="figure">
<img src="images/15.jpg" />

</div>
<p>One end of the cable must be twisted then inserted as shown in the following below.</p>
<div class="figure">
<img src="images/16.jpg" />

</div>
<h4 id="desolder-the-components">Desolder the components</h4>
<p>A heat gun is used to remove the soldered components, this gun heats air up to 400 degreed celius. The component should be holded by a tweezers during the process. The heat gun should be switched to cold air before shutting it down so that all the heat inside the gun is removed.</p>
<div class="figure">
<img src="images/17.jpg" />

</div>
<h2 id="design-a-pcb">Design a PCB</h2>
<p>The programmer was a pre-designed circuit, but now it is time to design and produce my own circuit. The PCB has a very simple design, a LED controlled by a button.</p>
<p>The components are:</p>
<ol style="list-style-type: decimal">
<li>ATtiny 44</li>
<li>10K ohm resistor</li>
<li>1uf Capacitor</li>
<li>Red LED</li>
<li>100 ohm resistor</li>
<li>Button</li>
<li>FTDI connector</li>
<li>2x3 connector</li>
</ol>
<h4 id="kokopelli">Kokopelli</h4>
<p>Kokopelli is the software to design a PCB using python. I have not designed the circuit from scratch because it will take me a lot of time, instead I have modified a previous design.</p>
<p>I have downloaded the software from this <a href="https://github.com/TheBeachLab/kokoretro">link</a>, and then used the command <code>make fab</code> to compile all the files and then opened the bin folder by the command <code>cd bin</code> and finally started the software using the command <code>./kokopelli -r</code></p>
<div class="figure">
<img src="images/koko.png" />

</div>
<p>The source code of the original design can be found in this <a href="http://academy.cba.mit.edu/classes/embedded_programming/hello.ftdi.44.cad">link</a>.</p>
<div class="sourceCode"><pre class="sourceCode python"><code class="sourceCode python">BU1 <span class="op">=</span> button_6mm(<span class="st">&#39;BU1&#39;</span>)<span class="op">;</span>
pcb <span class="op">=</span> BU1.add(pcb,XTAL1.x<span class="fl">+0.02</span>,J1.y<span class="fl">+0.1</span>,z,<span class="dv">90</span>)<span class="op">;</span>
pcb <span class="op">=</span> wire(pcb,w,IC1.pad[<span class="dv">5</span>],BU1.pad[<span class="dv">4</span>])
pcb <span class="op">=</span> wire(pcb,w,J1.pad[<span class="dv">6</span>],BU1.pad[<span class="dv">2</span>])

LED1 <span class="op">=</span> LED_1206(<span class="st">&#39;LED&#39;</span>)<span class="op">;</span>
pcb <span class="op">=</span> LED1.add(pcb,IC1.x<span class="fl">+0.3</span>,IC1.pad[<span class="dv">10</span>].y,z,<span class="dv">180</span>)

R2 <span class="op">=</span> R_1206(<span class="st">&#39;R2&#39;</span>)<span class="op">;</span>
pcb <span class="op">=</span> R2.add(pcb, LED1.x<span class="fl">+0.06</span>,LED1.y<span class="fl">-0.2</span>,z,<span class="dv">90</span>)
pcb <span class="op">=</span> wire(pcb,w,IC1.pad[<span class="dv">10</span>],LED1.pad[<span class="dv">2</span>])
pcb <span class="op">=</span> wire(pcb,w,LED1.pad[<span class="dv">1</span>],R2.pad[<span class="dv">2</span>])
pcb <span class="op">=</span> wire(pcb,w,J1.pad[<span class="dv">2</span>],R2.pad[<span class="dv">1</span>])</code></pre></div>
<p>I have added my parts which they are the LED, 100ohm resistor and the button as shown inside the square in the following image.</p>
<div class="figure">
<img src="images/koko-code.png" />

</div>
<p>The idea is to switch on the LED when the button is pressed. The LED is connected to the 5v trace and the button is connected to GND trace.</p>
<p>The final design is shown in the following image</p>
<div class="figure">
<img src="images/pcb.png" />

</div>
<p>The best image quality is 40 pixels/mm which corresponds to 1000dpi.</p>
<h4 id="producing-my-first-board">Producing my first board</h4>
<p>Now that the design is ready, I have produced the PCB using the SRM-20 machine and started soldering the components. After I have finished soldering the micro controller I have found that it is not soldered in the correct orientation ! I had to desolder it using the heat gun and remove the solder by the wick then solder it again.</p>
<h4 id="programming-1">Programming</h4>
<p>Programming in C is explained in the <a href="http://preacademy.fabcloud.io/preacademy2018/participants/fares.ahmad/C-programming/C-programming.html">programming documentation</a></p>
<p>My board is ready to be programmed, the program is written in <strong>C</strong> and the programmer which I milled previously will be used as the interface between my computer and the board.</p>
<p>The code is shown bellow</p>
<div class="sourceCode"><pre class="sourceCode c"><code class="sourceCode c">
<span class="ot">#define F_CPU 1000000UL</span>
<span class="ot">#include &lt;avr/io.h&gt;</span>
<span class="ot">#include &lt;util/delay.h&gt;</span>

<span class="dt">int</span> main (<span class="dt">void</span>)
{

 DDRA = <span class="bn">0b00001000</span>; <span class="co">// set PA3 as output in DDRB.</span>
 DDRB = <span class="bn">0b00000000</span>; <span class="co">// set PB2 as input in DDRB.</span>
 PORTB = <span class="bn">0b00000100</span>; <span class="co">// activate pull up resistor.</span>

 <span class="kw">while</span>(<span class="dv">1</span>) {

   <span class="kw">if</span>(PINB == <span class="bn">0b00000000</span>){ <span class="co">// if the button is pressed the micro controller will read 0 on PB2</span>

     PORTA = <span class="bn">0b00000000</span>; <span class="co">// Write 0 on PA3 to switch on the LED</span>
   }<span class="kw">else</span>{
     PORTA = <span class="bn">0b00001000</span>; <span class="co">// Write 1 on PA3 to switch off the plugged</span>
   }
}
}</code></pre></div>
<p>To upload the code I have connected the board with the programmer and plugged the programmer into a USB port then I have executed the commands <code>make flash</code> then <code>make program</code>.</p>
<p>The LED now will be switched on when the button is pressed. <strong>Attach links for CAD and original images of the traces and cut</strong> <strong>Talk about the makefile modification</strong> <strong>PUT VIDEO</strong> <strong>Talk about why pull up resistor</strong></p>
<p><strong>Oscilloscope, talk about button and bouncing</strong></p>
</body>
</html>