Ultimate List of Tips, Tricks, and Tutorials for Fab Lab Students

This post is a not on a lot of techniques for using different types of machines and processes for making stuff. I’ve had this for years but decided to finally publish it. I’ll add to it periodically, but I figured others might find it useful as well. RIGHT-CLICK to open in new windows.

Laser Cutting:

Embedded Systems, Microcontrollers, and Arduino

Circuit Board design and Fabrication:

3D Printing:

Casting and Mould Making:

CNC:

Machines:

Mechanical:

Metal-Bending:

Miscellaneous:

 

 

================================================

My favorite Fabrication-related researchers:

Dr. Stephanie Meuller at MIT’s research group

Dr. Patrick Baudisch at Hasso Plattner Institute Human computer interaction reserach group

 

Teaching Research:

Sketchnoting basics

Graphic Recording

Sketchnote travel journal to get started

Control Theory:

Brian Douglas’s awesome youtube channel explains Control with some great examples.

Kat Kim has another great channel on Controls as well as other Electrical and Computer engineering examples and lectures

George Gillard has a great whitepaper explaining PID controls

Another great PID example is from this Reddit thread

Learning Math concepts:

MathVault – Learn higher-level (college-level) math concepts more intuitively

BetterExplained.com ADEPT model for learning math intuitively

Good sources of materials:

XXXXXXXXXXX    Todo when I’m not so busy or lazy: XXXXXXXXXXXXX

Add sections for PCL shapelock and other named plastics to ultimate FabLab list.

Also add cardboard modeling guy and nibbler tool

Add anodizing alum and titanium, bluing/blacking steel,

And interesting research I like with lasers  hydrographics and uv printers and metal hologram art

Best way to make GUIs and Executables in Python for Windows, Mac and Linux

Typically when making a program, I want users to have a familiar experience: a single .EXE file instead of some weird scripts that requires other programs to run. There are a few different ways of accomplishing this using python,. On this page I’ll explain the simplest way I’ve found to get this result, and how to debug if you run into problems with this method.

I wrote about using pySimeplGui for making dead simple GUI interfaces for python code before, and even have a simple example project,. Check those two articles out for that aspect.

As for creating the .EXE file, there are several packages that will allow you to create executables of your python scripts. The reason to do this is that you don’t want end users to have to install python  (simplified usage of your app) or you don’t want anyone seeing the actual python code. The way they work is that they create a self-extracting zip file that has your code, all associated libraries (including DLLs), and most crucially, they have a small bootloader that is a python interpreter executable. There are several available such as cx_Freeze, bbFreeze, Py2App, Py2Exe, Pyinsaller, or you can create your own from scratch  (See a chart comparing them here).

There are some problems with these tools. Several of these are not currently updated. Some don’t allow you to create a “One File” solution, meaning they require additional folders of files, etc. which in my view isn’t a true executable experience from the user perspective.  For some reason, there’s a known issue with some of these which makes the resulting executable get incorrectly flagged as a virus by virus software. There are some ways around this however.

I’ve tried out a few of these and given my recent experience with PySimuleGui, and the features I wanted, I settled on pyinstaller.

PysimpleGUI has its own interface for pysintaller to simplify things called pysinstaller-exemaker.

For some reason, my resulting executables kept getting flagged with false virus warnings on windows. I tested in Virus Total which runs multiple virus scanners at once on your file. Sure enough, lots came back with false positives.

I found two ways to fix this problem. As with most things, there’s the easy way, and then there’s the right way.

The easy way requires specific versions of python and pyinstaller on your machine.

The other way to prevent false positive virus scans is to recompile pyinstaller’s bootloader from scratch. While I did this (and explain it below), it is non-trivial.

The Easy Way: Install Correct Versions:

The easiest way to not have the virus issue is to use the correct versions of pyhton and pyinstaller as described on a no-dead link on yuriss.com.  This Completely solved the problem and is SOOO simple!  Basically you just install the correct version of python (Version 3.7.4) from python.org. If getting the windows version, make sure it is the 64-bit version, other users seem to have had issues with the 32-bit version.

Once this is installed, you can use pip on the command line to install Pyinstaller 3.4:

 pip install pyinstaller==3.4

The Right Way: Recompiling pyinstaller’s bootloader from scratch

This may be needed for future version of python or pyinstaller. Since I already went through the headache of figuring out how to do it, I’m documenting it here.

If using a version of pyinstaller that throws the virus warnings, you can’t just go to the folder PIP installed it to and compile it there. That’d be too easy of course! (This took me a long time to figure out)… If you try to do that, it’ll fail with cryptic errors.  The reason is that the file path is too long.

To overcome this, you have to perform the following steps:

  1. Clone pyinstaller’s source to a folder in your C drive, then
  2. Rebuild the bootloaders,
  3. Install pyinstaller with pip,
  4. Overwrite your pip installation with your newly built bootloader files…

Duh, obvious right?! (omgwtfwhyisthisalwayssohard!?)

Details for the steps are below:

Step 1: Open a powershell as admin and go to C:\\

cd c:\\

Download the source of pyinstaller. This will create its own folder for pyinstall:
>pre>git clone https://github.com/pyinstaller/pyinstaller

Step 2: Cd into the bootloader’s build folder:

cd .\\PyInstaller\\bootloader\\

Then run the script to reinstall. If you get an error telling you there’s no such thing as ./waf then you are in the wrong folder.

python ./waf all

Step 3: Once this is done, you can go back to vscode or wherever and install pyinstaller from pip

pip install pyinstaller

Step 4: Then navigate to python’s site packages, and copy the newly built bootloaders into the appropriate place. NOTE: PyInstaller is case sensitive here, so be careful. We’ll first make a backup of the original bootloader folder:

 mv C:\\Users\\ALaptop\\AppData\\Roaming\\Python\\Python38\\site-packages\\PyInstaller C:\\Users\\ALaptop\\AppData\\Roaming\\Python\\Python38\\site-packages\\PyInstaller.bak

Then copy in our freshly compiled bootloader:

mv C:\\PyInstaller\\bootloader C:\\Users\\ALaptop\\AppData\\Roaming\\Python\\Python38\\site-packages\\PyInstaller

Note: Now to use pysimplegui-exemaker, you must edit your computer’s %PATH environment variable to locate pyinstall. Click the windows key on the keyboard, type “environment” and click to open the first suggestion. This window will pop up that has a button towards the bottom named “Environment Variables” that you must click. In the top window pane, find “path” or “PATH” and doubleclick that line to edit it. You’ll now be able to enter a new value. You want to add the path to where pip installs its scripts.  In my case, I pasted in the following:

 C:\\Users\\ALaptop\\AppData\\Roaming\\Python\\Python38\\Scripts

Then test it out:

python -m pysimplegui-exemaker.pysimplegui-exemaker #<--If you use pysimplegui's exemaker (NOT a typo, must exactly this way) OR

pyinstall --onefile ./myProgram.py #<-- If you just use pyinstaller directly

Tada! No more virus warnings!!!!

 

Check out my other post about how to replace the default python icon in your executable files.

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.