2nd Weather Balloon (from 2010)

Back in 2010 I was part of a team that sent up a couple of weather balloons on a NC spacegrant. I posted about the first one (which flew straight into a thunderstorm) a long time ago, but with the recent weather balloons in the news, I decided to go back and look up my old photos from the second balloon.  In the pic above the yellow balloon was the first one, the green plot is of this second balloon.

We launched from Monroe Airport in NC and the path of the balloon followed the path of HWY 74, which is the main road in the area. There are a couple of good pics of Wadesboro, NC and Lake Tillery as well.

This one went about 75k ft. in elevation. You can *just* make out the curvature of the earth in some of the photos. We launched on a beautiful clear day and we were able to visually track the balloon’s full ascent AND descent. Fun times! Luckily it didn’t freeze on the ascent so we got some better pics. We stocked this one with a bunch of candy like last time and it was fun eating space candy again!

DIY Soldermask Showdown

banner

Once you fabricate a PCB, it pretty much instantly begins to oxidize. PCBs created in industry are coated with a couple of things to protect them from this oxidation and short circuits. The first is called a soldermask, which is a type of epoxy that literally coats the entire circuit board. If you’ve ever seen a circuit board, you’ve seen the soldermask. It is typically GREEN but can be different colors. For example, official arduinos typically have a Teal BLUE soldermask. Sparkfun uses RED. OSHPark uses Purple.

You can see below just how badly the copper oxidizes after being touched an exposed over time.

unprotected

There are multiple ways to add a soldermask to a PCB. My new favorite method is using Kapton tape (explained at the end of this page), but I have tried and compared a lot of different solutions below.

Epoxy-based:
In industry, they use a specially designed paint or epoxy that is cured with ultraviolet light. This allows them to cover all the traces (the wires) but leave the pads visible so you can solder components on the board. Some folks have tutorials out there showing how to do this, but it is messy and uses nasty chemicals.

Dry-Film Soldermask:
You can also buy sheets of “dry film soldermask” which has the epoxy deposited as a flexible sheet that you adhere to the PCB, then use a photolithography method to harden it with UV light.  This allows you to remove the softer material on the pads you will solder the components to. This material is not readily available, but you can find it from electronics suppliers online. Here’s an excellent tutorial on how to do this process at home.

Tinning Traces:
Another option to protect the traces from oxidizing is to tin them. Tin doesn’t oxidize as badly as copper. Essentially you can deposit tin on all the copper surfaces using a chemical deposition (electroless). This is actually done to the solder pads on commercial PCBs, but it can be done to the entire PCB. The biggest issue with this method is that it doesn’t prevent short circuits because it doesn’t add a layer of insulation to the traces. Again, it uses nasty chemicals.

Conformal Coating:
There is a conformal coating that can be painted or sprayed on a PCB after soldering the components.  It coats everything. While it has been formulated for electrical characteristics, etc. I personally don’t like this option. There are Acrylic, polyurethane, and silicone based products, which you can solder through, but it only comes in clear (you though you can see it in UV light).

DIY – Nail Polish:
When I did FabAcademy in 2014, I milled a ton of PCBs. They always oxidized really badly. Some would be useless within a month.  I began painting finished boards with fingernail polish. I only painted the traces in case I needed to resolder the components. (The soldered areas do not oxidize like the copper traces). This option isn’t great because fingernail polish isn’t designed for electronics, or being touched with a soldering iron, but it works and I have boards that are almost 10 years old that look brand new. This is probably one of the easiest solutions due to availability and color selection.

Lacquer:
Another thing I tried more recently was to spray the PCB with colored lacquer, then using either a laser to etch off the lacquer on the solder pads with a laser, or to just solder it directly (the lacquer melts only when touched with a soldering iron).  I don’t really know the chemistry here so when you laser it or solder it, I don’t know how safe it is. I don’t see how much different it can be from the conformal coating you can buy. A bonus with Lacquer is that you can get lots of colors, though I recommend avoiding anything with glitter, pearl, or metal flakes in it.

Both nail polish and lacquer do allow multiple colors, but neither are designed for electronics. Here you can see the left board is almost 8 years old but has had its traces painted with clear nail polish for protection. The red board is from my previous article in 2021.

paint and lacquer

 

The best solution I’ve come up with is to mill or etch a circuit board, then export the pads layer of the design to an SVG. From here it can be cut by a laser or a vinyl cutting machine into Kapton tape. Once cut, the tape can be applied to the PCB and pressed down hard. Since kapton tape is heat resistant, it can withhold under a bit of soldering. It also has excellent electrical properties (resistance, capacitance, and inductance).  It is actually used for a substrate material for flexible electrical circuits.

UV Curable Dry Film Conformal Coating Nail Polish Lacquer Kapton Tape
Cheap

Availability

Safety

Designed for
Electronics

Ease of Use

Clean

Speed

Special Equipment

Ok, so Kapton tape wins. How do you cut and apply the kapton? We tried a couple of things and both worked.

Firstly, I told Garrett (who is taking FabAcademy in our lab this semester) about my idea and asked if he’d play with the kapton tape and the laser to find out what settings to use. He set about finding the best settings. He first used it to make a solderpaste stencil for his own project. Apparently on a 120 watt epilog, for the size holes we needed, about 6-7% power worked well.

We tried a couple of methods. First we placed the tape on cardboard, cut it, then peeled and stuck it to the PCB. This worked fine, but was a little tough to unstick and weed. This is likely the method I’ll use in the future though.

The second attempt we got cocky and just stuck the tape on the PCB and lasered it directly.

kapton1    kapton weeded

It is easier to line up with the cameras on the laser, but even when we placed the PCB directly under the camera (to avoid aberration of the fisheye lens) we still didn’t get the best alignment. It was good enough to solder though. You can see the finished product at the top of this page.

offset      stuffed1

SAMD11C Multi-use board

I finally got a chance to play with the SAMD11C chips FabAcademy has been recommending for a while. I also wanted to learn to use KiCAD a bit more so I made a multi-use board with the SAMD11C which can be used for UART, UPDI programmer, and as a FreeDAP board. You can find all of my files for this project, including the firmware at my FabAcademy gitlab page.

I will be making a modification of the board Quentin designed.

I designed the board in KiCAD by modifying another of Quentin’s boards, the SAMD11C dev kit with USB-A connector.

To fabricate a PCB, I’ll use the Roland SRM-20 mill as well as my shapeoko/X-carve using Fab Mods.

The steps in this project are:

  1. Download my board files, code, and hex from here.
  2. Mill the PCB with Roland or other CNC
  3. Populate (stuff) the board with components
  4. Flash firmware to the chip
  5. Use this new board as a programmer or USB/UART

Milling a board on the SRM-20 through Fab Mods:

I’ve posted a more detailed explanation of exporting from KiCAD to a milling machine in this previous post.  Be sure to check that out when you get to that part of the process.

Go to http://mods.cba.mit.edu/

Right click anywhere on the screen and select “program” then “open server program” and search for Roland→SRM-20 → PCB png. To use any other CNC (Shapeoko, Xcarve, 3018, etc.) you can select G-code→ mill 2D PCB png. This will accept in a PNG image file and generate the cut file you will send to your machine.

clip_image001

Then we’ll modify this to save a file for us.

clip_image002

 

If your X, Y, and Z, look like the GIF above, you’ll do an “air cut”.  An “air cut” is a test that runs the same code, just offset in the Z axis  (and this case X and Y as well) just to make sure everything will cut as you would expect. Then you’ll regenerate your cut file by changing the X, Y and Z defaults to 0s in mods before exporting your cutfile again.

 

Once the board is cut, it must be populated… Break out the old iron and solder up the design. If you don’t have a switch like the one I used, you can simply install some male headers and use a jumper to select the voltage. The SAMD doesn’t have a lot of external accessories which makes this part a good bit easier than say some of the older FabISP designs.

Once populated, the board needs to have firmware flashed to it. For this step, I will use the Atmel ICE programmer and a windows computer.

First download windows version of edbg which is the debugger tool we’ll use to download the firmware.

https://taradov.com/bin/edbg/

I downloaded it to my desktop.

Then download the binary of the firmware. I am using the SAMD11C arduino bootloader core firmware so I can use the chip with the Arduino IDE and libraries. (This bootloader seems to eat up a good bit of memory, even on these ARM devices).

Connect up the atmel ICE programmer to the SAMD board. I used figure 3-8 from the atmel ice manual to figure out the pinout because we are using the Serial-Wire debug (SWD) pinout.

Above you can see the specific pins for programming the firmware with the Atmel ICE. Pin 1 is Target Voltage (Vcc), pin 2 is SWDIO, pin 3 is GND, and pin 4 is SWDCLK. Pin 10 is the Reset.

Here are the pins and usage of the board:

Finally you’ll need to open the command prompt in windows, cd to the directory you downloaded these files to and run the following command (assuming you went with the 2nd firmware option above):

edbg-windows-r24.exe -bpv -e -t samd11 -f sam_ba_Generic_D11C14A_SAMD11C14A.bin

You should see:

Debugger: ATMEL Atmel-ICE CMSIS-DAP J42700050854 01.00.0021 (SJ)

Clock frequency: 16.0 MHz

Target: SAM D11C14A (Rev B)

Erasing... done.

Programming.... done.

Verification.... done.

The first time I did it I got this error:

Debugger: ATMEL Atmel-ICE CMSIS-DAP J42700050854 01.00.0021 (SJ)

Clock frequency: 16.0 MHz

Error: invalid response during transfer (count = 0/1, status = 0)

I unplugged everything, replugged it and tried again and it worked.

This firmware only allows arduino to program the chip via USB. Let’s now install the correct board info to arduino so we can do that.

In the arduino software, go to File→Preferences and click the icon next to “Additional Boards” and paste the following:

https://www.mattairtech.com/software/arduino/package_MattairTech_index.json

 

Then you need to install the SAMD boards. In Arduino go to Tools→Boards→Board manager

Search for “SAMD” and install the “MattairTech” one only.

Once this is installed (it will take a bit of time) We can write some arduino code to run on our new board. Let’s start with a blinky program. Looking at the pinout of the SAMD11C, we can choose a pin to connect an LED to on a breadboard.

(Image source: https://gitlab.fabcloud.org/pub/helloworld/index/-/tree/master/SAMDino.%20Hello%20SAMD11C14 )

 

You better make sure that you always use “INTERNAL_USB_CALIBRATED_OSCILLATOR” when you plan to keep this plugged into the USB port for power, or “INTERNAL_OSCILLATOR” when you want tit to be standalone. If you select the other two options, you’ll have to reprogram the firmware with the ICE or a DAP.  It basically bricks the chip if you tell it to use an external crystal but don’t add a xtal to your design.

Arduino file to be serial print to test. The pinout is simple. Each output uses the same pin number as the SAMD chip output. This is unlike a normal Arduino.

ATsamD11C14A Arduino pinout

   0 -------------------
  5 | A5                 A4 | 4
  8 | A8 (XIN)        A2 | 2
  9 | A9 (XOUT)   Vdd |
14 | A14             Gnd |
15 | A15             A25 | 25
28 | A28/RST     A24 | 24
30 | A30            A31 | 31
    -------------------

 

You can download this code to test your board (whether you have a working LED or not). Once this uploads, open the serial terminal and you should see “hello”

 

void setup() {
   SerialUSB.begin(0);
}

void loop() {
      SerialUSB.println("hello"); //Send stuff from USB to serial port
} //end loop

If you want to test to make sure that your board can now be programmed from the Arduino IDE, you can flash the built-in LED on pin 2 with this code:

int led = 2;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

The following Arduino file makes this board into a UPDI programmer when you add a jumper to the appropriate pins (see above). Simply take data from the USB serial port and put it on the output serial port and vice versa.

 

void setup() {
  
   SerialUSB.begin(0);
   Serial1.begin(57600, SERIAL_8E2); //Adjust baud rate and use SERIAL_8N1 for regular serial port usage
}

void loop() {
   if (SerialUSB.available()) {
      Serial1.write((char) SerialUSB.read()); //Send stuff from Serial port to USB
   }
   if (Serial1.available()) {
      SerialUSB.write((char) Serial1.read()); //Send stuff from USB to serial port
   }
} //end loop

 

Program a target board over UPDI:

Once you have downloaded the above serial code to your board, you can use it to program attiny412 or attiny1614 chips over UPDI.

  1. First, you want to get a Attiny board. Here’s a great simple board to try.
  2. Get the code from that link to blink the LED on pin 0.
  3. Most important part==>In arduino, change the chip to the attiny412!!! If you don’t do this, you’ll accidently reprogram the samd which you don’t want to do. If that happens, go back and put the serial UPDI code above back on the samd.
  4. Change the “programmer” to “SerialUPDI – SLOQ: 57600 baud, any platform…”
  5. Wire up the samd board as shown below. The white wire is the jumper described above to put the board into UPDI mode. The other wires connect to a target board.

 

To program other samd chips with this board:

If you want to use this to program other SAMD boards, you’ll need to download this Free-DAP firmware and flash it to this board using the edbg program as explained above. This now becomes a programmer for other boards (called target boards). Connect up the target board to this one correctly (follow pink pin names as shown in the explanation below) and then you can program the target SAMD board with some firmware using edbg as well.

Note that the pinout for the programmer for a target samd board.

 

FUTURE WORK:

I’d like to take a page from Adafruit’s book and make the Free-Dap project into an Arduino project. Though I I’m pretty sure you can’t flash a bootloader to a SAMD using avrdude (hence the use of edbg). Adafruit’s solution is to have you load the bootloader to an SD card connected to the target board, then the arduino project just dumps the data from the card into the target board’s FLASH. Instead, I think I’d rather take a note from how pyupdi.exe was added to the Arduino IDE and simply include edbg.exe with it instead.

I’d like to make this same board also program ISP chips like the attiny45 or bare Atmega328s, but it isn’t a priority. It should be possible to do this through the ArduinoISP file but…. meh.

 

 

How to export to a CNC from KiCAD and Fab Mods

So, while working on a new board design I decided to learn KiCAD a bit more. I’ve detailed the board design and files in an upcoming post so keep an eye out for that one. Here’s I’m just documenting the process to make a board by exporting the design from KicAD and generating cut files in Fab Mods.

I came across a LOT of different methods looking at other Fab Academy students. Some had weird scaling issues or other problems.  I’m showing how to use two different methods for producing and SVG file.  Export–>SVG and plot as an SVG.  I also show two ways of generating cut files, whether you are making Gcode for a generic CNC or you’re making an RML file for a Roland SRM-20.  Note, I’m using KiCAD 5.4 on Windows 10 here.

In the examples below I’m using Quintin’s SAMD11C board found here.

 

Method 1: Export SVG directly from KiCAD to Mods

 

Method 2: Export an SVG using the “plot” function then convert to PNG for Mods:

 

Caveats and other important details:

I have rebuilt my shapeoko V1 as a PCB mill and so the difference between this and an SRM -20 Roland PCB mill is just what program you select from mods when you are creating the cut file.

If you aren’t running the websocket for fab Mods, you’ll need to replace the “websocket” module of the Roland programs with a “file save” as shown below:

 

Once you’ve exported the file you can follow this procedure on a Roland or other CNC machine to mill the board.

 

Once you populate the board, you can program this particular one with an Atmel ICE. Here’s the connections for that:

Connect up the atmel ICE programmer to the SAMD board. I used figure 3-8 from the atmel ice manual to figure out the pinout because we are using the Serial-Wire debug (SWD) pinout.

Pin 1 is Target Voltage (Vcc), pin 2 is SWDIO, pin 3 is GND, and pin 4 is SWDCLK. Pin 10 (Reset) is the back corner you can’t see.

Basic setup for all Raspberrypi projects

This is a starting point that I do on every one of my raspberry pi projects. You can branch off from this point to any number of projects. I used to like a screen and keyboard/mouse interface, but this is how to set up a headless rpi that you only control over the network. it is much easier than it sounds.

Hardware:

  • Raaspberrypi startup kit with power cable and SD card.
  • Computer (I have windows 10 but there are guides out there for mac and linux as well)
  • Wireless network to connect to
  • Maybe a camera to format the SD card?

Software Tools required :

  • SD card formatter (I use a DLSR camera because sometimes even this tool won’t format the cards right)
  • Balena etcher to burn the raspberryPiOS to the SD card

Firstly, I downloaded and installed the latest raspberrypiOS Lite to an SD card. Once it was installed, I reinserted the SD card into my laptop and created a wpa_supplicant.conf file in the partition I was able to open in windows (one will be openable, the other won’t be). This file sets up your Wifi settings so you can control the pi remotely instead of trying to find the right HDMI or component cable an display and connecting a keyboard and mouse to it.  I can simply ssh into the Rpi and run the scripts I need. This may sound intimidating, but it isn’t too hard at all.

Open a text editor (NOT word or notepad, download something like Sublime3 or notepad++) and create a new file names wpa_supplicant.conf. Paste the following and make sure to enter your WIFI’s credentials and keep the quotation marks.

country=US
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
scan_ssid=1
ssid="Put your networks SSID here"
psk="Put your networks password here"
}

That will get the pi on the network, next we need to be able to actually control the Rpi from another computer on the network. To do so, just create a blank file with no file extension named “ssh” in the same SD card partition as wpa_supplicant.conf.  That’s it. This empty file just tells the Rpi to turn on ssh, which allows you to connect and control it remotely.

Now you can insert SD card into Rpi and plug in power to boot up.

With my older Rpi3 I give it like 5 minutes depending on the OS. Then you can check to see if your Rpi is on the network.  Open the command window in windows (windows key, then type “cmd” then enter) and type

ping raspberrypi.local

You should see a response. If it times out, then give it a little more time to install the OS and try again. If you can’t ping it (communicate with it ) after 15 minutes after you booted t up (or 30min or longer sometimes for a pi Zero w) need to start from scratch because something went wrong in your wpa_supplicant file. Triple check that the file is not saved as “wpa-supplicant.conf” or “wpa_supplicant.conf.txt” For that last one you may need to “show file extensions” in window’s explorer.

I always used putty to ssh into linux machines from windows, but Windows 10 apparently has ssh built right in, so you can just click the windows icon and type “powershell” to open a command window, then enter

 ssh pi@raspberrypi.local

We’ll use powershell instead of the Cmd window to allow us to copy and paste stuff into the window easily.

The first time you do this, it’ll give you a warning that it “can’t verify the [raspberrypi], do you want to continue”  just type “yes” and hit enter. Then you will be asked for the password. Note that as you type, you will see no letters appear in the terminal. This is normal for password entry on linux machines. The default username is “pi” and default password is “raspberry”.  When you type it and hit enter you should see a green line that says “pi@raspberry” which means you are logged into the pi.

The first order of business is to change the default password. type the following:

passwd

Enter your new password and you’re set. Now you can go off doing whatever random things you want to use the Rpi for.

To copy and paste into the SSH window you may need copy as usual form a webpage then right-click into the powershell window (maybe do this twice if you hadn’t already selected the powershell window) and it’ll automatically paste it for you.

Static IP: Next I like to set up a static IP address for my Pi so I always know where it is. This also helps things like streaming a webcam for Octoprint since the address won’t change. Android phones won’t use the mDNS entry of “raspbeypi.local” so if you want to use your phone to control or view things on the pi you need to set a static ip. Do so by issuing the following command:

sudo nano /etc/dhcpcd.conf  #this opens nano command line text editor to the IP address file...

My pi is on wifi  so I’ll adjust the wlan0, but you can replace this with “eth0” if your pi is using ethernet.

interface wlan0
static ip_address=192.168.0.100/24    
static routers=192.168.0.254
static domain_name_servers=192.168.0.254 8.8.8.8

This way I know all my raspberrypi stuff is found at 192.168.0.100. I can just type that in for ssh, or into a browser if I’m running a server on it (like octoprint, hassio, mjpg streaming video, etc.

Remote Desktop: To make it easier to connect to the pi in the future and to remote into it and control it’s graphical desktop from any other computer (such as your desktop or laptop), you can set up your pi to allow VNC. First, in your ssh terminal, we need to enable VNC.

sudo raspi-config

Then use arrow keys to select “Interface Options”.  Select “VNC” and you’ll be prompted to enable VNC the server. Then you can exit Raspi-config. On your desktop/laptop/other computer you need to install a VNC viewer which will allow you to connect. Visit https://www.realvnc.com/en/connect/download/viewer/ and install it. You should then be able to connect via the IP address of the pi, login to it and have full access and control as if you controlling it with your keyboard, mouse and monitor.

 

Remote shutdown:

Next you need to know how to shutdown and restart your rpi safely. It is a computer after all and I can’t tell if  just unplugging power will corrupt the SD card, so a safe method of shutdown is required. I use a couple. There’s a script you can add to allow shutdown by connection one of the GPIO pins to ground. This is essentially what you do on a regular computer’s power button. You tell the computer you’d like it to shutdown so it will trigger the shutdown functions. Secondly, you might want the ability to shut down or restart via ssh.

sudo shutdown -h now

or

sudo poweroff

and a restart is

sudo reboot

I’ve added a plugin and scripts to my octoprint setup to do the GPIO and I can shutdown from the web interface.

 

Now if at any point you mess up and can no longer communicate with the pi (setting the wrong IP address, etc) simply format the SD card in windows or in a digital camera and try again.

I recommend once you get all your settings correct, you backup your Rpi OS periodically. There’s a script that you can use to copy a bootable filesystem to another (can even be smaller) SD card you plug into a USB card reader on the pi.