# Electronic Production

Henk thought us how to use the pcb milling machine. It was a lot easier to use than the big shopbot.


## Preparing the material and machine for use
First Henk showed us how to clean and prepare the material. He first took out the platform and removed the plate that was cut from the sacrificial layer.

![alt text](image.jpg)

After that he removed the tape from the backside of the material and cleaned off the glue from the plates using `sticker remover`. 
![alt text](IMG_8970.jpg)

After that we grabbed the double sided tape and after cleaning we taped it back up and put the plate back on the sacrificial layer.
![alt text](IMG_8974.jpg)
![alt text](IMG_8975.jpg)
![alt text](IMG_8977.jpg)
Then he placed the plate precisely back on the sacrificial layer.

![alt text](IMG_8981.jpg)
![alt text](IMG_8982.jpg)
Then he cleaned it and put the plate back in and screwed it down. He told us to not screw it too tightly otherwise the plate will be uneven.



## Exporting from KiCad

File > Fabcrication output > Gerber

Then only select F.Cu and Edge.Cuts

![alt text](image-1.jpg)

gerber2img on class website.

![alt text](image-2.jpg)

convert gerber files to images. 

For the traces without `fill edge cuts`
For edge cuts with `fill edge cuts`

Then load jpg file into ModsProject.

### Exporting drill hole
Exporting drill holes is a bit weird in kicad. You need to press some other buttons to do that. In the export menu I clicked the generate drill holes button.

![alt text](image-19.jpg)

![alt text](image-20.jpg)
In there I used these settings from [this page](https://fabacademy.org/2024/labs/skylab/students/eka-prawira/assignments/week08/pcb-design). After that I could export it into gerbertoimg and then into modsproject.

## Using modsProject to use the machine
We use modsproject.org to send our designs to the machine. The website uses webserial to communicate to the device so you need chrome or any chromium based browsers to use this website. Otherwise it won't work.
![alt text](image-3.jpg)

Then we needed to select the MDX mill.

After that Henk showed us that we needed. To start the Serial communication with the machine.
![alt text](image-4.jpg)

After that we could load all the tool configurations.
![alt text](image-5.jpg)
These where our settings for making the traces and these where for cutting out the board.
![alt text](image-6.jpg)
After that we could import the file 
![alt text](image-7.jpg)
And press calculate over here
![alt text](image-8.jpg)

When it's done a new page will pop up with the toolpath. You can close that. Now you need to set the starting coordinates.
![alt text](image-9.jpg)

That can be done over here. The origin is the starting position of your job. After it's set. You can finaly click the send file button.

![alt text](image-10.jpg)

### Important for cutting out boards

Make sure your offset number is 1 otherwise the machine will do 40 loops around the cut. (Thanks Irja)
![alt text](image-21.jpg)

## Ordering from board houses
I already have expierence with board houses. I ordered assembled pcb's a year ago for another project.

My preferred manufacturer is JLCPCB because you get an instant quote and it it is cheaper than PCBway in my expierence. 

This is the homepage and you can directly upload your files there.
![alt text](image-24.png)

After you've uploaded the files you can edit the fabrication of the board.
![alt text](image-25.png)
You can change soldering paste, silkscreen color and more stuff. JLCPCB has really nice guides next to each option what it is and what it does.

At the bottom of the menu you can also order assembled pcb's with components or a stencil for easy paste soldering
![alt text](image-26.png)

When you enter your shopping basket you can select which pcb's you wanna order and order them.

![alt text](image-27.png)
## Making my first programmer
I went through the fabacademy website and looked for my first board to make. I wanted to make a programmer so I could program other Atiny's and SAMD's and get started on making small boards. 

The first board I had calibrated the Z too low and it went a bit too far into the board. It also destroyed a trace.

I read some more form the github repository and saw that these mcu's only need one pin to program. I was concerned with the 6 pin connector that it could only be attached one way but it can go both ways which is a nice design choice.

![alt text](image-11.jpg)

After soldering I realized that some traces where broken. I attempted to fix them using bypass wires. But I accidentally ripped off the voltage regulator when I was stripping the wire I already soldered to it. So for next time don't strip a wire while the other end is soldered.

![alt text](IMG_9266.jpg)

[link](https://gitlab.fabcloud.org/pub/programmers/programmer-updi-d11c)

## Making the controller
The controller needs 2 joysticks and a screen but I found out after a while that the ESP-C3 only has 3 analog inputs and I needed a minimum of 4 for the joysticks and 2 for the buttons.
![alt text](image-14.jpg)

Although the buttons can also be read using digitalRead since its either 0 or 1. But to connect all the joysticks I asked henk if i could use the esp-s3 but he said I could use a multiplexer for the same result. He gave me 2 different multiplexers. The PCA9555 and the CD74HC4067M. But after reading through the datasheets I realized I could only use the CD74HC4067M because the other one didn't have Analog inputs.

So I redid my board schematic to this.
![alt text](image-12.jpg)
I quickly figured out how the mulitplexer worked from the datasheet. You need to set a couple of pins to high and low and that way you can choose what input you want. So there are 4 control pins and 16 channels.

![alt text](image-13.jpg)

Now I need to re-do all the traces. Luckily I found a button to delete all traces at once. 

![alt text](image-15.jpg)

This nice tool makes it so you can delete something of a category all at once.

This is the end result. I decided to use bridge resistors instead os trying to do double sided. Because Henk said it's super hard to do and my peers also told me that they read other documentation on how it wen't wrong and how the writer rather would've done bridge resistors so I opted for that.

My board went from this.
![alt text](image-18.jpg)
To:
![alt text](image-16.jpg)
Because I needed more analog pins. Thus the multiplexer.

I had some issues with the DRC because the joystick wasn't made properly. The 4 holes on the back are there for stability but the copper ring was left on. The DRC was complaining that there wasn't enough space to leave a copper ring. But after changing that in the footprint editor I have 0 errors.

![alt text](image-17.jpg)

All the warnings are silkscreen warnings so I don't have to worry about that.

## Issues when milling
When milling some of the traces where too close and modsproject combined all these traces into one. Henk helped me and set the tool diameter a bit lower so these traces would get cut out. Next time in KiCad I need to increase the spacing a a bit to account for sloped traces. Because KiCad doesn't account for it well.

So I halved the the cutting image because I didn't wanna re cut everything again but then It also broke some traces that it wasn't supposed to cut.

![alt text](image-22.jpg)

You can see it's on the same line I set it to cut again.

![alt text](IMG_9287.jpg)
So if I wouldn't have made the initial mistake I would have a complete board.

### Repairing the board

![alt text](image-23.jpg)

## Final result

I decided to remove the legs because I am going to be making a case around it anyways and there is no need to use that much extra copper.

