Saturday, 16 March 2019

My experience using a PCB fab service (Pcbway)

When I counted a dozen 8085 CPUs in my retro tech stash, I decided to do a SBC project with them. The goals would be to learn to order PCBs online, and several other things. Coincidentally about this time a Pcbway rep contacted me asking if I would like to sample their service and post public feedback.

The design I submitted is not mine, it's a completed 8085 SBC design published by Sergey Kiselev, see my project page for the links. This means I am confident that there are no mistakes in the placement and routing. It is not a complex design, only a handful of ICs due to the use of a GAL to replace a lot of discrete logic, two layers, 0.1 inch pitch ICs, and through hole components. One step at a time; I'll learn to use Kicad/pcbnew for my own designs later.

A personal note: A PCB fab service over the Internet is something only dreamt of back in the days when I started making PCBs, first with resist pens, then later with photoresist, while dealing with noxious chemicals like ferric chloride and xylene. Well the Internet didn't even exist then. The disadvantage of course is the turnaround time so you should be fairly sure of your circuit before you commit to PCB. The old tailor's or carpenter's adage measure twice cut once is very apt here.


Submitting the order through the website

Like many fabs, registering an account on the Pcbway site will get you starter credit.

At this point assume you have breadboarded and debugged your circuit, have laid out the PCB and are ready to generate the Gerber and drill files.

The website is attractive and the steps are easy to follow. Just click on the Quote and Order button and it will take you through the steps. There are help buttons for the various entry fields. Pcbway seems to offer a great variety of options for the boards. I accepted the defaults as I have no special requirements. Maybe one day I'll design boards requiring advanced features. Like other fabs, the magical size 100x100 mm (from the limit of the free version of Eagle EDA, Kicad EDA is always free and has no limit) has special pricing, so usually people start with 5 or 10 boards within this limit.

I noticed that Pcbway offers to upgrade you from HASL (Hot Air Solder Levelling) to the more expensive ENIG (Electroless Nickel Immersion Gold) at their discretion for no extra charge. This Pcbway page​​ explains the two technologies. Searching on those acronyms will find you more explanations. You can veto giving them discretion if you wish.

For Kicad 5 the documentation of pcbnew explains how to generate Gerber and drill files and can also be found in Pcbway's tutorial. For other EDA software there are abundant tutorials on the Internet. Package the generated files (usually 9) as a zip archive and upload to the website.

At this point Pcbway will do a review of the files. Now I uploaded on a Sunday night so either they have software doing the checks, or there are reviewers working shifts which is plausible as a big fab like Pcbway must get a continuous stream of orders from all over the world, thanks to the Internet. In any case it was finished within an hour and I was notified by email that I could go back to the website to pay to start the fabrication process.

There are many choices for postage depending on how impatient you are or how urgent the work is, and of course the faster the more expensive, and could be more than the fab charge. I took the tracked China EMS (E-packet) option which costs a bit more than the cheapest China air option.

As an amusing digression, I expect that the package of 10 PCBs (1.6 mm x 10 = 16 mm, or more) will be too thick to go through my mailbox slot. Our postal delivery workers have heavy workloads so if they can't deliver it into your mailbox, they don't ring the doorbell, but leave a card telling you to collect at the post office where you have to fret impatiently in queue with dozens of people paying their bills because they haven't learnt to pay by Internet. ☹️
Card has become a verb in this country. 😊 Funny talking about carding on forums, not so funny when you are the unfortunate recipient. Fortunately we can also have parcels delivered to a parcel locker which we can collect from 24/7 using a code sent to us, and this is the delivery address I gave.


Monitoring the fabrication steps

Once your order is paid for, the process will start. You can monitor the steps it's going through. Here is a window snapshot. I learnt something today, the order in which the steps are done. The one acronym new to me was AOI. This turns out to stand for Automated Optical Inspection. From beginning to end takes 1 to 2 days. BTW, Pcbway: this popup window doesn't work properly on my mobile (Chrome browser), most of the rest of the site does.
2019-03-27 edit: If you would like to learn more about the manufacturing process, there are lots of videos on YouTube, including some by Pcbway themselves. This one is a good start​ and here is another one by a visitor​. Be aware that more than 2 layers goes through more steps so some videos show these extra steps. What I find interesting is how much automation and yet how much manual handling are involved. Search on "PCB manufacture" for many more videos.

The wait

There was a delay of one day between the end of production and the boards being shipped. Then one more day before tracking information appeared. Beijing post office huh? Wonder which one of two PCB factories did my order.
I tracked the progress of the parcel. What was my parcel doing between 3rd and 12th of March? Standing on Beijing airport tarmac with a thumb extended to hitchhike a ride to Sydney? 😊
This goes to show that unless you are willing to pay a lot for postage, you should have several projects going so that you can occupy yourself while waiting for PCBs.


Evaluation of received boards

Finally this arrived in my parcel locker about 2 weeks after the end of fabrication. For sure nothing is going to fall out with the huge amount of packing tape they used, hahaha.
Inside there were 11 PCBs, one extra just in case I suppose, in a waterproof bubble wrap bag. So how good were the PCBs? Here is the top of the PCB.
And a closer look. Both the tracks and the screen printing are crisp and well defined. Although mine is not a demanding board, I'm sure their process can handle thinner traces.
The bottom of the PCB.
Notice the well defined dots in the legends for the jumpers.
At this point I was going to insert a picture of a partially soldered board, but that would only demonstrate my skill, or actually lack of, in soldering. So I reckon Pcbway has done an excellent job. I would not hesitate to use their service again. And the board does look like the preview later on this page, but perhaps a darker shade of green.

Apologies for the fish-eye distortion in the closeups. I had to use macro mode and put the lens really close to the board. You are viewing it perhaps double life-size on your screen.

If you have issues with the received product, be sure to contact customer service for resolution.


Other services

Pcbway hosts an online Gerber viewer which appears to be an instance of Mike Cousin's tracespace viewer, which is also available as a hosted service here. It's more responsive than other sites I've used. Go wild with it, you are not loading a remote server, the rendering is done using the SVG capabilities of your web browser. Here is Pcbway's announcement. You can use Pcbway's viewer without an account. I used the Gerber viewer in Kicad 5 but the tracespace viewer can also show you the front and back of the board as you will receive them with the silkscreens correctly oriented, not with one reversed as in the Kicad viewer. The board looks so realistic that you sit there, admire it, take selfies with it, and forget that you still have to build your board later. 😊

Conclusion


I hope that my newbie experience ordering a PCB fab job has shown you how to get started. Whichever fab house you choose to go with, in fact, whatever circuit assembly process you choose to use, I wish you much success with your projects. May you never let the magic smoke inside chips escape.

Tuesday, 29 January 2019

How to get fall through behaviour in bash case statements

As many people know C has the famous (or infamous) fall through behaviour in switch statements. Is something similar available for bash?

Indeed, just look at the man page:

Using ;& in place of ;; causes execution to continue with the list associated with the next set of patterns. Using ;;& in place of ;; causes the shell to test the next pattern list in the statement, if any, and execute any associated list on a successful match.

In other words, where you would leave out the break; in C you would write ;& instead of ;; in bash. Hope you have a good use case for it (sorry for the pun).

Wednesday, 23 January 2019

Upgrading DVD burner firmware from Linux via a VirtualBox VM

I was given a TSSTcorp SH-224DB DVD burner. This has a SATA interface. The firmware revision shown in dmesg was SB00. I decided to update this to SB01, the last available. Problem was the file was a Win32 executable. How to run this from Linux?

The drive in question is connected to my Linux machine via a USB to SATA dongle. I have a Windows XP VM so I decided to see if it could access the drive. The first time I tried connecting the drive which appeared as /dev/sr1 to the VM. The update executable said it couldn't find any suitable drive.

After some reading I tried another tack, I allowed XP to access the dongle via USB forwarding. This time running the update executable found the drive and duly updated the firmware.

The first attempt didn't work because VirtualBox was presenting a virtual DVD to the VM. But what the program wanted was access to the SATA interface, albeit via the USB layer.

This may work for other drives for which only a Windows executable is available.

Wednesday, 16 January 2019

MPLABX 5.0 IDE error: (1180) directory "build/default/production" does not exist

Posting this so that people can find the solution.

I experienced the same problem as posted here where compilation would fail with this error if the project file is on a network drive, a NFS mount in my case. Running make in the directory from the CLI got the same error. Strange to say, the fix of copying it to a local directory worked.

I don't know what the root cause is but this is another thing you could try.

Thursday, 27 December 2018

k3b, mkisofs, and hard linked files

As it's the end of the year, I decided to back up photos from my trips onto DVD. A du -sh of the directories showed that they would fit onto a standard DVD. But when I went to create the image in k3b, it wanted a double layer DVD.

I knew what the problem was, in those albums I had made heavy use of hard links to provide multiple access paths to photos without using extra disk space.

Checking the man page of mkisofs showed that there were a pair of options, --cache-inodes and the negative form. I added this option to the arguments passed by k3b to mkisofs and bingo, the space of the image halved, even though the preview claimed that it required almost 8GiB of DVD.

Looking at the verbose output of k3b on the terminal showed that --no-cache-inodes is the default, presumably to avoid problems with dumping filesystems that don't have working inodes.

Thursday, 20 December 2018

Travails installing openSUSE on Samsung 2012 Chromebook (Snow)

I have a 2012 Chromebook made by Samsung, codenamed Snow. I like this machine as it is light, has a decent sized screen, and is suited for travel. Google stopped issuing updates to ChromeOS for this Chromebook in July 2018. So I was pleased to see that openSUSE Linux developers had issued builds for this hardware. For one thing I might be able to do things on the Chromebook not possible from ChromeOS.

So I went to the wiki page that had instructions for preparing boot media for it. First thing I had to do was enable developer mode. I lost my personalisation of the Chromebook but I didn't have much anyway, and most of the config was backed up to the cloud.

Ever optimistic, I chose the Leap KDE build image. I got it to boot and then the troubles began. I needed to get a network connection to update the packages, and this needed to be set up from the desktop. But the Plasma desktop kept crashing. Most of the time it would restart by itself after a hiatus at the desktop. But sometimes the machine froze and the only to get out was by turning off the machine by holding down the power button. On power up, sometimes it wouldn't boot far enough to show kernel messages and then it was power off again. Perhaps it was trying to repair the filesystem and I should have waited longer, but I did wait a long time. Finally I managed to download all the updates, some 600 packages in all. But by this time the machine wouldn't boot up anymore. Perhaps the CPU had overheated.

After a rest for the machine and for me, I decided I was too ambitious so I tried the JeOS (Just enough OS) image. Unfortunately this turned out to be NQeOS (Not Quite enough OS) as it didn't boot to a GUI. I might have been able to configure the WLAN interface from the command line but IHeOI (I Had enough Of It).

So I decided to try booting the LXQT image, I reasoned that perhaps without Plasma the desktop would be more stable. After quite a few tries and retries with the WLAN interface, I managed to fetch all the update packages, some 570 IIRC, and I installed them with zypper up -y from the CLI.

Then there was some to and fro with NetworkManager and wickedd. I decided to go for wickedd as this works at boot rather than when the user logs in on the desktop. But both were active after install causing some clashes.

So I have a desktop of sorts which can stay up for a while. I may keep LXQT, even though I'm used to KDE on my desktop, because this is a low RAM machine (1GB) after all.

But here's the main problem: after all that work I could not locate some key packages like a web browser, e.g. Firefox. Perhaps it's in a repo I don't know about, certainly it's not in the main repos. Looks like these builds are for people who are willing to experiment and not ready for normal usage. In retrospect perhaps I should have tried a Tumbleweed image as this might have all the updates to build date rolled in. I also see there's are experimental 15.1 builds which I might try and report back.

Other approaches I could have tried are Crouton, which keeps the kernel used by ChromeOS but runs applications over it. I don't know if this can be installed on a SD card. To the openSUSE developers' credit, getting a boot image which supports all of the peripherals I needed is a fair achievement. There is Internet documentation on how to install Debian on it but there is a lot of cross compilation and manual configuration.

The main motivation for installing a Linux distro on the Chromebook is to be able to get access to things like VPN software with a decent sized desktop and multiple terminal windows. But this motivation has faded a bit as I don't need as much to connect to my home or work machines during travels. If I do, my smartphone, with its 4GB RAM, and lots of VPN apps under Android, coupled with a Bluetooth keyboard, is much more capable, with the caveat that the display is smaller, even though the resolution is higher. So that only leaves local development when on the road as a rationale for carrying a Linux enabled Chromebook.

Wednesday, 7 November 2018

sizeof operator in C and C++ should be better known

Having seen some code examples on the Internet where sizeof should be used, I thought I'd offer a short reminder of a couple of useful cases:

1. A EPROM burner program to run on Arduino where the data was embedded as a byte array in the sketch which is then compiled and downloaded to run:

What was written:

const int progSize = 1024;
const byte hexProg[progSize] = { ... };
...
for (i = 0; i < progSize; i++) {
...
}

What should have been written:

const byte hexProg[] = { ... };
...
for (i = 0; i < sizeof(hexProg); i++) {
...
}

This has the advantage of automatically adapting to the number of bytes that actually need to be programmed instead of always 1024.

2. An Arduino program to test a LCD display:

What was written:

char row1[] = "I'm Arduino";
...
for (int positionCounter1 = 0; positionCounter1 < 26; positionCou
nter1++) {


This prints junk after the greeting because it strays past the end of the string, which is also a security hazard.

What should have been written:

for (int positionCounter1 = 0; positionCounter1 < sizeof(row1) - 1; positionCounter1++) {

The - 1 is to not print the NUL byte at the end of the string. A reminder, if the string is say UTF-8, sizeof gives the number of bytes in the string, not the number of characters. But usually the number of bytes is what you want.

Also do not make this mistake:

char *row1 = "I'm Arduino";

In this case sizeof(row1) will be sizeof(char *) on the machine, not the length of the phrase I'm Arduino.

A couple of other idioms.

Getting the number of elements in an array:

int divisors[] = { 2273, 2145, 2025, 1911, ... };
const int ndivisors = sizeof(divisors)/sizeof(int);

Or even better:

const int ndivisors = sizeof(divisors)/sizeof(divisors[0]);

which means you can change the type of the divisors array to be other than an int without changing the second line.

Allocating the right amount of memory from heap:

double *readings;
...
readings = malloc(NREADINGS * sizeof(double));

And a reminder, sizeof is a compile-time operator, so there is no runtime cost to using it. If the expression provided to sizeof cannot be evaluated at compile-time, the compiler will tell you.