Electronic Production

PCB production

Generate the G-code

Geometrical Code most known asG-code is a widely common programming language for CNC (Computer Numerical Control), using simple line commands and XYZ position defines a queue of actions that the machine has to perform to manufacture the piece. In this case to mill the circuit board.

The G-code can be generated with a lot of tools, but for this example, I use a program for mods, a community fork of the CBA mods research project. That allows you to generate G-code from a png image, I used the file provided in the class to test the line width capability of the machine and FabTinyISP to learn the skills of electronics production.

I modify the png images using Photoshop, adding ILB (my name initials) to easily identify my circuit boards.

Adding my initials on the line test file Adding my initials to the FabTinyISP png file
Check the FabTinyISP project See the test line file

The program used can be found under the menu that can be open by right-clicking and under the menu path: programs -> open server program -> G-code -> mill 2D png

    Workflow inside mill 2D png

  1. Load a png image of the circuit, the color white represents the traces, and black the non-conductive background.
  2. Set the mill raster 2d settings, tool diameter, cut depth, max depth, offset number, direction.
  3. Set the path to G-code settings, cut speed, plunge speed, jog speed, jog height, spindle speed, and format.
  4. Press the calculate button, and save the downloaded .nc file, you can view the G-code tool path by pressing view on the module.
Mods program with the image for traces Mods program with the image for traces

Mill raster 2D settings used to generate G-code

Tool diameter Cut depth Max depth Offset number
traces 0.2 mm 0.1981 mm 0.1981 mm 3
cut 0.2 mm 0.6 mm 2.15 mm 1

G-code settings used to generate G-code

Cut Speed Plunge Speed Jog Speed Jog Height Spindle speed
traces 200 mm/s 100 mm/s 75 mm/s 2 mm 10000 RPM
cut 300 mm/s 150 mm/s 75 mm/s 6 mm 10000 RPM

G-code testing

Simulate G-code screenshot

In order to test if the G-code was generated correctly, you can use a browser application called G-Code Q'n'dirty toolpath simulator that allows you to see a visual representation of the code and check if the origin and scale are correct, you can also join the G-code from the traces and the cut in a single .txt file and preview that to ensure that is the same scale and don't intersect.

This allows me to catch a mistake on the scale of the line-test traces and cutout. I fixed it by scaling the images and making the dpi equal.

Milling the Circuit Board

In this process, the idea is to remove the conductive layer of the board. To generate the traces and pads to connect and solder the components of the circuit.

The material that will be used for milling PCB is a FR1 board. You should be aware of the material used to mill, because if it contains fiberglas it can damage the milling tool and generate harmful dust.

You have to ensure that the removed space between traces is continued and have enough space to isolate properly, but also the traces have to be tick enough to ensure electrical conductivity and reduce the chances of them peeling off.

    Using a CNC machine for milling

    Workflow

  1. Prepare the machine, load an underlay and the raw board, paste it with double side tape, as flat as possible.
  2. Ensure that the surface is clean and conductive. If needed use thin steel wool to remove coats and oxide layers from the cooper. Also, use alcohol to clean any grace from your fingers or the environment.
  3. Install the milling bit, and zero the XY axis, put auto-level sensor, use that to zero the z-axis by lowering the z of the machine by small steps.
  4. Run the auto level program (in this case some of the first steps of the G-code, depends on the machine), remove the sensor and then start the milling process.
Image of steel wool cleaning the board to mill Image of the CNC machine milling the circuit
Image of the CNC machine milling the circuit

Results

Image of the traces before the outline

After the first try the traces come out pretty good and then there was time to cut the outline to release the board, we change the mill bit to another that has a bigger angle and is more strong to avoid damaging the small tip of the one used for the traces.

But when the machine ended the G-code for cutting the board was ruined, the angle of the bit was created a bigger kerf of about 2mm does chopping of some traces and making the board unsuitable

The third try was realized width the same G-code for the traces but the cutout G-code was modified adding a larger diameter tool to compensate for the big angle of the bit.

Board with to thin traces

This attempt failed, because somehow the traces were machined too thin and, in the end, one broke and peel off. After trying aging the board comes up well but the traces were too thin to actually solder on them, as we were making the tests of the milling process on my board and the first time the G-code worked but the second didn't, so we re-generate from the original png image of the FabTinyISP without any initials, the main change was the to set the tool diameter setting to bigger value so the traces remain on a good thickness.

Before finally archive a success board we have some other issues maybe with the auto level, and we give ourselves a lunch break, while the CNC was milling we sorted the needed components and make a few practices on how to solder.

Assembling

Process of soldering the components in the correct position and orientation, after this you should have a functional board.

This process was made following the schematic and really useful tips provided inside the FabTinyISP project page, the first time I have ever solder some SMD components, due to its size SMD components are tricky to solder and place.

The basic idea is to identify the place and orientation of the component, pre-solder one of the pads, using a small tweezer put the component in place, and then with the iron melt the solder on the pad, solder the other side by preheating the to surfaces to solder and letting the solder flow. Then return to the initial point and flow a little bit more solder.

Detail of the board been solder

For me was difficult to place the first components after some time I finally can get the hang of it and start feeling more conformable soldering, I feel that can be a lot of improvement on the technique in order to be more consistent with how to solder and the amount of solder used on each joint.

Programming the FabTinyISP board

As I was at home with another FabTiny board to program the ATtiny45 on my board I try to use an Arduino UNO as ISP to get the .hex file on the ATtiny45 using the next pin-out.

ISP pins pin Led indicators pin
reset 10 Heartbeat Led 9
MOSI 11 Error Led 8
Miso 12 Programming Led 7
SCK 13

You also have to connect the VCC and ground to power up the ATtiny45, after that was connected by jumper wires, the LED's are completely optional but as it was my first time programming an ATtiny45 they help me to have more confidence.

I started installing software on my computer following the steps mentioned in this useful page about Programing the FabTinyISP. Also this page helps me to solve some issues that I step across when I was installing the needed software.

The programs needed in order to program the ATtiny45 are:

In the documentation of the FabTinyISP, they recommend the following steps to successfully program the ATtiny45 using the Makefile. And the programs installed previously via any terminal or bash that should be placed where the make file is located using cd.

make -> make flash -> make fuses -> test usb functionality -> make rstdisbl

Commands/Steps breakdown

screenshot of avrdude list of chips that can be programmed

As I was using the Arduino Uno as ISP I have to adapt these steps to make them directly on the console.

I started by displaying the list of possible target chips to be programed by avrdude using avrdude -p xyz to then choose the correct code and the set the flag -p t45 to select the ATtiny45 as the current target.

After that I make sure to know where the board was connected in this case COM4 so I set the next command to ensure that all the connections are properly made and avrdude is ready to program avrdude -c arduino -b 19200 -p t45 -P COM3 -n

Flag breakdown

screenshot of avrdude command to check the connection with the ISP programmer  and ATtiny45 chip screenshot of avrdude command to flash the .hex file

Using the previous command and changing the -n flag for a -U flash:w:file.hex, to load the .hex file to the MCU.

After that was done I try to test the USB functionally with no results because the fuses weren't set as needed for the USB protocol, so I then try to execute the make fuses without any success because the make file is not adapted to use the arduino as ISP. So there are not -b or -P flags, which default value works well for a USBTiny programmer but not for the Arduino.

bricked board + board after repair

Then I try to change the fuses manually but it didn't work because of the safe mode and how I did the command on avrdude. I decided to test and understand how to change one and then apply the knowledge to the other 2 fuses. but I choose the wrong one to test with, and I manage to write the fuse but it was the one that changes the clock signal. And after that, I wasn't able to reprogram the ATtiny45 because it needed an external clock or something like that and couldn't communicate with avrdude returning a 0x000000 as the chip signature.

After this I research and read about fuses and that help to understand how I ended up with the ATtiny45 'bricked' (a term used to describe an MCU that has a wrong fuse configuration), and also how to make a 'fuse doctor circuit' that uses 12v on the reset to force the fuses to the desired state, this was my first idea to solve the issue and reprogram my board. But Roberto suggests that I can replace the bricked ATtiny45 with a new one and try the programming again.

Once I remove the ATtiny45 and soldering a new one, using Camilo's FabTinyISP I finally manage to program the board and fuses using the Makefile and the steps described above.

screenshot of make clean followed by a make command screenshot of make flash command
screenshot of make fuses screenshot of make fuses
screenshot of make rstdisbl screenshot of make rstdisbl

And it finally works!

screenshot of the programmer working

When connected to my my Windows computer it appears on the DeviceManager, and it actually can be used to program based on the ISP protocol


Troubleshooting

In this week the amount of troubleshooting needed is big enough to make a section that will summarize the troubles that I have and how I did solve them, to make future troubleshooting easier and quick.

G-code

CNC Milling

Soldering

Programing

FabTinyISP build to learn about electronics production

FabTinyISP port view FabTinyISP LED´s view
FabTinyISP light on FabTinyISP usb fit

Group Assignment

This week was about creating the workflow and rules for PCB production inside our lab.

Click here to know more

Conclusions

This week was very useful but quite complex because I have just one day at the lab to make, and as the milling of the board took a long time taking some of the time designated to solder.

But overall the experience was great, learn how to solder SMD, was a really pleasing experience that I have never have done before. An using what was learned this week I think we will be able to create amazing things.

The programming was a really nice experience I tried to make it in a different way and even though I failed, I learn a lot about fuses and avdrude, also I'm looking forward to un-brick the ATtiny45 just to complete the experience.

Have I?


Prev Next