Getting Started with (Git) Version Control and Fab Cloud

Fab Cloud is the Git repository for all Fab Academy and FabLab sites. The first thing you have to do as part of Fab Academy is set up your own repository here for your website. Git very powerful tool used to synchronize multiple versions of files and folders that multiple coders are working on in the same project. Don’t let that scare you though, in the beginning we’ll just be using it to update the webpages on Fab Cloud.

I recommend you learn about using Git in the command line, but that’s a bit scary for some folks. Luckily, the simple basic  stuff doesn’t require it (of course, unless you mess something up, then you’ll be learning all about those advanced functions in the command line tool).

Head over to Git for Windows download and install it.

While this downloads and installs, login to your Fab Cloud account. Recall that you’ll login using your FabLabs.io credentials, in fact the two sites are linked. Just click the button to pull in your FabLabs.io login and you’re good to go.

Once in, you’ll be at your dashboard. https://gitlab.fabcloud.org/dashboard/projects . Then click the big green “New Project” button at the top right of the screen. Name this project whatever you want and you can choose whether or not to have a Readme.md file in there. Go ahead and create the Readme.md file. This file is automatically rendered from markdown to html when you visit the directory in your repository it resides in. It’ll start off blank, but we’ll add something to it later.

Now we need to connect the web server and your computer in an encrypted way to transfer files back and forth.

Open Git GUI by clicking your windows start menu button and typing “Git GUI” click the icon when it appears. Since this is the first time you’ll have used the software, it’ll ask you what you’d like to do. Select “Clone Existing Repository” as we will be making a local copy of the one from the web. The local copy will be the one you edit and update and when you are ready, you can upload all your changes to the web.

 

It is at this point that we have 2 options. If you are on Central Piedmont’s campus, you CANNOT use ssh. You can only use the https method of accessing your gitlab site.

If you are using HTTPS:

Step 1: Visit your gitlab repository’s page and click the blue “Clone” button. You’ll need to select the “Clone with HTTPS” link.

Step 2: Open GitGui on your windows machine by clicking the windows icon and searching for it.

Step 3: Click “Clone Existing Repository”

Step 4a:  Paste in your https link in the top box as shown below

Step 4b: Set a target directory on your computer for where you want the files copied to. I created a folder in my Documents named GitGUI. Then you must type in a slash and the name of the folder you want to create. You can’t select a folder that already exists… Here I manually added “/base” after selecting my GitGUI folder.

Step 5: Click “Clone” and it will ask you to login to gitlab.fabcloud.org. If you forget this, simply visit your gitlab.fabcloud page, login via fablabs.io, then look at your account info.

Save your progress locally:

You can now edit the files in that folder, and when you are ready to save your progress locally. You may think “I already saved the files I edited” but you want to make sure to save your progress on the entire repository in gitLab in case you ever need to revert back to this saved point. Think of it like a spawn point in a video game. You WILL break something eventually and need to go back to this save point.

To save your local progress, open gitGUI and open this repo. Then you can click the “scan” button. you’ll see a number of files in the top left pane. These are unsaved changes.

Step 1: Click “ReScan” to scan the folder for changes

Step 2: “Stage Changed” will setup the changes to be committed to your local repository (folder)

Step 3: “Commit” documents this as a save point for the future. You need to enter a comment in the “Commit message” window describing what works and what doesn’t at this point.

Step 4: “Push” Synchronizes these changes with the gitlab.fabcloud server. You’ll likely be asked to login and here you’ll again use your fabcloud credentials.

 

If you can use SSH use these instructions:

Before we can clone anything, we need to generate an SSH key for our computer. SSH is a encrypted (secure) method for communicating between different machines (be they computers or servers). Only devices with the “key” files can unencrypt the messages sent between the machines. We must generate a key pair on your machine. We need to generate what is called “Asymmetrical encryption” key pair. This consists of a private key (the file which stays on your computer and is not shared) and the public key (which you send to the other machines). Basically, the public key can encrypt messages and send them to your computer which can be decrypted by the private key. More info here.

To generate the keys, Go to Help—> Show SSH Key

In the new window click “Generate Key.” It will ask you to enter a password twice. Make sure to enter the same thing. Next, it will fill out the text box with what looks like gibberish. This is good! That’s the public key. You need to copy this to your clipboard so we can paste it into the website.

image

Add the SSH key to your gitlab.fabcloud.org account.

Login to your gitlab.fabcloud.org account (remember that it uses fablabs.io login credentials, don’t make a new account, be sure to click the button regarding FabLabs.io and login there.)

Click on your profile icon at the top right of the screen and visit “settings”

In the left column, click “SSH keys”

Paste your public key into the textbox labeled “key.” When you paste it, it should bring up the name of your computer. You have to then click the “Add key” button at the bottom to save this.

Once you do this, you can close the “Generate Key” window and you’re back to the “Clone Existing Repository” window.

The next window asks for two locations. “Source Location” refers to the one on the web server and “Target Directory” is the folder on your local machine you want to store it in.

To get the source location visit that new project you started earlier at and at https://gitlab.fabcloud.org/. At the top right click the blue “clone” button and copy what it says in the SSH window: Example:

git@gitlab.fabcloud.org:acharris/base.git

My username is acharris and I named my repository “base.”

The important thing here is that the folder you want to put it in cannot already exist. So I typed in “base” at the end of the line. Git GUI will create the “base” folder, then store my “base” project in there.

image

It’ll ask you for your login, so go ahead and type it as many times as it asks for it.

image

Once it is finished, it will open up the regular Git GUI interface window. It has now created a local branch. (Local means your computer, remote means the gitlab.fabcloud.org server)

image

In the future, you won’t need to clone this again, You can just “Open from Existing” at the first screen and it’ll bring you right to this window.

This can look intimidating, but it is really simple. First, take a look at the folder we created on your machine. Go to “Repository—> Explore Working Copy” This is the local copy (local branch) of the folder from the server (remote branch). We can add/delete/change any files or folders in this folder while we are working, then upload them all to the server when we reach a good stopping point for the day and it’ll merge the files with anyone else’s who has been working on the same project.

Let’s do a simply workflow.

Let’s change the README.md file. Open it in a text editor (such as sublime or notepad++) and put some text in there. Something like:

I did it!

Save and close the file. Now go into the Git GUI window and notice the buttons. Each time you want to upload files to the server. We will always click these buttons in order from top to bottom, starting with “Rescan” This will magically detect all changes in the project folder. you’ll see the file names in the left Pink panel and the file contents in the right Yellow panel.  For now you should just see your txt in green with a + sign in front of it. This pane shows any added or removed text from what is on the server.  imageimage

The next button “Stage Changed” will move the files from the top pink pane to the bottom green one. If you only want some of the files and not others, then you can click the icon next to the file name to change its location.

Slight detour… Warning: LF will be changes…

At this point you might get a popup on windows stating

Warning: LF will be replaced by CRLF in README.md. The file will have its original  line endings in your working directory

This helps windows and linux compatibility, but in some cases (such as EagleCAD board files) it can break stuff. First we need to unstage the file we just staged by clicking at the top menu bar Commit –> Unstage from Commit then we need to turn that feature off by opening the file base/.git/config and adding autocrlf=false after ignorecase – true line and clicking save. If you can’t see the folder named “.git” it’s because windows is hiding it from you. In the windows file browser, click “view” and check “Hidden items” and “File Name Extensions” and you should be able to see it.

Now you can stage without the issue. This change only affects this one project now, but if you don’t want Git to change ANY files in this manner you can go to a command line, cd into a git project directory and enter the following:

git config core.autocrlf false

Back on track, Sign Off:

Next you want to add text to the comment box:

GIT GUI recommends:

First line : Describe in one sentence what you did.
Second line: Blank
Remaining Lines: Describe why this change is good
Sign Off.

Type your comment, then click the next button in the list to “Sign off” on the changes. It’ll paste a template in the “Comments” textbox. This says that you in particular were the person who uploaded stuff. This is helpful later when something breaks and you want to find out who to yell at.

image

The next button it “Commit” which will add this to the local branch of the Git repository file. When you click this, the files disappear in the Green pane. This does not mean it it available on the web however.

I hear you asking “Well I just copied the file into that folder, isn’t it already there?”…

The answer is yes and no. It’s on your computer, but it isn’t part of the project from the project. You need to tell Git this new version is what you want to use.

You need to click the last button to “Push”  to upload these changes to the server. This will synchronize the entire folder, changes, comments and all to the remote branch (server).   A window will pop up and just click “Push” again. You’ll be asked for the password again.

image

Now what happens if you screwed something up?  Well…. don’t.  You have plenty of opportunity to check things out before actually Staging, Committing, and Pushing. That’s the hope at least. In practice when stuff gets screwed up somehow or another.

You can fix the error quickly, then push a new copy to the server or you can try to rewrite history. This can get really messy and I do not recommend anyone mess with this unless you know what you are doing with Git already (which I assume is not the audience of this tutorial.)

Customizations:

The base version of Git GUI won’t help much as it is too limited. You have to end up using git commands. There’s two ways to do this. One is to go to you’ll have to get into the Git Bash screen (accessible from the “Repository” menu item at the top of the screen.)  Another is to add the commands to Git GUI’s menu. (Wait.. What!?)

Click on Tools –> Add  and you’ll be asked for a name you want to add, and the command. Check this one out for instance. Before you push, this will revert the file back to the version from the remote branch (the server):

image

AtTiny412 General Purpose Blinky Board and UPDI Programming

In the 2020 season of Fab Academy, we are encouraged to use new chips (as opposed to the Attiny 84/85 chips). The new chips the lab got were AtTiny 412. This is a tiny 8-pin chip is pretty neat. Here’s my old design which was an EagleCAD Board file. It is based on Neil’s design for the AtTiny412 (Go here), ctrl+f for Attiny412 and look at his “board” link) board but I moved the LED to Digital Pin 0 (which is PA6 in Atmel speak – pin 2 from the top left) of the chip. My new design used KiCAD and is available here.

Here’s the layout of my board:

BOM:

  • AtTiny412
  • LED
  • 499Ω resistor
  • 4.9kΩ resistor
  • 6-pin SMT header (FTDI)
  • 2x 2×2 SMT header (Optional, general purpose for connecting other stuff to)

Once the board was made I needed a programmer. The new chips use UPDI instead of ISP protocol. There are two easy ways of making a cheap programmer for this. One is simple software but complex hardware (Arduino-based) and the other is simple hardware and complicated software (python upload/downloader). I tried them both to see what I could simplify about them.

First, mill the board. With this, I experimented with a lacquer finish as a soldermask it came out pretty well actually.

Complex hardware, simple software (Arduino):

First I installed the megaTinyCore library into Arduino.

Followed these instructions to make a UDPI programmer out of an arduino. Here’s a board you I designed that you can fab yourself for this project. Simply download the jtag2UDPI sketch to an arduino board to make it a programmer. You’ll need to connect up a 4.7k resistor from Digital Pin 6 to go to the AtTiny412 board to program.  Additionally, if you can’t disconnect the the DTR line from the serial chip to the reset pin of the arduino, just add a large capacitor from the reset pin to ground. The capacitor acts like a tiny battery and when the DTR pin on the FTDI chip drops voltage to 0 to reset the arduino (typically how it works when using the arduino software) the capacitor will keep the voltage high so the jtag2UPDI won’t reset in the middle of trying to program the AtTiny chip.

This is a stupid simple solution that costs very very little. You can get an arduino board for $2 online and add a resistor and capacitor to make it a programmer and you’re done. This is the way to go. The issue is that Fab academy wants you to actually build your own programmer.  I’ll revisit this in another post soon…

Once you’ve built the programmer, change your chip in the Arduino software to the AtTiny412 and change the Programmer to “jtag2UPDI”  then load up Blink example and change the led_pin to pin 0 (if you are using my board design).  When you click program, all should go well.

Simple Hardware Complex Software:

This solution uses just a USB serial chip (FTDI or similar) and only 1 resistor.  No additional arudino required. Neil encouraged in week 2 Instructors meeting to build his FTDI-based UDP programmer and use PyUDPI (See under “hardware” if you search for “UPDI” here). Basically you use a simple USB to serial converter chip (FTDI chip or similar) and all the hard work is done on the software side. The setup for PyUDPI is a lot of overhead when you can just get it working directly in arduino using the jtag2UDPI linked above.

The first board Fab academy recommends is hello.serial-UPDI.FT230X assumes you have an FTDI board. This only provides a resistor and two connectors. One connector accepts the FTDI 6-pin header and the other is the 1 pin and Gnd signal to program the AtTiny. Of course this one is WAY too easy to build…

The second board under “hardware” on that page (hello.USB-UPDI.FT230X)  is an actual FTDI board, exactly like you could buy. The FTDI chip has smaller pin pitch than the ones we typically do in FabLab so he recommended using the heated desoldering iron.

The workflow will be to use Arduino (because why not?) or any other compiler to generate the hex file, then use the PyUDPI python script to send the hex file to the AtTiny chip manually.

Since this used Python 3 and the terminal, I didn’t want to mess around with windows paths and all that disastrous junk. I installed it in an osboxes.org virtualbox linux installation inside my windows machine and tunneled access to the USB device to it.

  1. First install Python 3 (NOT python 2!) if you don’t already have it. Open a terminal and check
    $ python3 --version

    If not installed, then install it:

    $ sudo apt-get update
    $ sudo apt-get install python3.6
  2. Install pip 3  (Tom Dubick says – python since version 3.2 comes with PIP)
  3. Then install the dependencies for PyUPDI with this line
    pip3 install intelhex pylint pyserial
  4. Download and unzip the pyUPDI project from here (Click the “clone or download” green button and download a zip (you need the whole thing so just unzip the whole folder).
  5. Plug in a 3.3v FTDI chip (Convert a 5v version to 3.3 volts shown here)
  6. Open Arduino and load up the blink example. Change the LED pin to 0 since that’s what my board uses. Save the file to the Desktop. Export a compiled Binary from the Sketch menu in Arduino. Sketch—?Export compiled Binary This will save the .hex file in the Arduino project folder. (You saved this to the Desktop like I told you to right?) Otherwise you’ll be digging through temp files to find it.
  7. Open a terminal window inside the pyUDPI folder (or navigate to it). Open a terminal and download to the board using the following command:
    sudo python3 pyupdi.py -d tiny412 -c /dev/ttyUSB0 -b 115200 -f Blink.ino.hex -v

Where /dev/ttyUSB* is the path to the FTDI port and Blink.ino.hex is your file’s name.

Board:

Tweaked the design of Neil’s Blinky board. I changed the pinout of his board to use Pin 0. You can see the pinouts of the new chips:

 

Image source: https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/ATtiny_x12.md

Other new chip pinouts available in uncropped image:

Tom Dubick added the following resource which is great as well: https://npk-stn.ru/2019/07/19/simple_programming_attiny414_via_updi/?lang=en

Digital Caliper Power Cable

The worse thing about digital calipers are those stupid-small batteries that don’t last 5 minutes and don’t stay in too well.  Sometimes you lose the battery cover then you’re really screwed.  To find a workable solution to this issue, I googles and saw a bunch of 3D printed solutions for data cables on these calipers.  I decided that I didn’t care much for the data part, but to 3D print a connector just for this seemed a waste of time. Sure, you can find some Dupont connectors to 3D print, but is it worth it? I set about a different way.

I happen to have a large number of servo connector cables from my quadcopters days. It just so happens that one of these female 3-pin dupont connectors fit perfectly in the caliper’s data slot. And if you used male wires, bent them backwards and shoved them in the data connector slot, it holds tight and provides a great connection for the power rails.

First, get a stabby thing and take the dupont connectors off some single-wire connectors (red and black are a good choice for colors).

tools

Capture

Take out all 3 female connectors form a servo cable and shove the male wires on the two ends of the servo connector as shown. Next you want to be careful and bend the male wires around the edge. You have to make sure your orientation is correct for the pins as they need to line up red with the (+) terminal and black with the Gnd otherwise you’ll be making a new cable—ask me how I know…   I did this in 2 stages since the pins are fragile. I slowly bent them against a tabletop to 90 degrees. Assessed their quality and angles and bent the remaining excess to 180 degrees

bend90degrees 

 

When done you should have something that looks like this:

180degrees

 

Plug it into the data port and you should have good connectivity with the power rails. It is a tight interference fit.  final Product

 

I’ve considered adding this to a AAA or AAAA battery pack I could mount on top or the back of the calipers. I’m pretty busy so that might not happen. If it does, I’ll post my janky design here though.

DIY Card Scraper From Old Credit Cards

image Credit card companies such as Chase and  American Express have been adding metal to their cards as a gimmick. I had a few old credit cards that have metal piece inside them. Sometimes when you get a new one, the card company sends you an envelope to return the old ones in for recycling, or they suggest you use tin snips to destroy them.  I found a better use.

In woodworking, many times in order to get a nice smooth surface, you might use a card scraper, which is just a thin steel card with sharp edges. You hold it roughly perpendicular to the surface of the wood and draw along the surface perpendicular to the flat side of the card.  This shaves a very thin layer off the top of the wood.

You could buy some card scrapers, but since I had these extra credit cards, I tried to make some myself. I attempted a few different methods to remove the plastic form both sides of the cards. Firstly, went in brute force and pulled the plastic off both sides. As the edges of these cards are sharp without the plastic, I gave myself a pretty good gash in my thumb. This is not a great method. 

For the second card, I attempted to melt the plastic with acetone…. which didn’t fully work and made a nasty, stinky mess.

The third attempt, I went in the garage and used a little torch to heat up the plastic on the card.  Once I saw that it could work, I stopped.  I recommend doing this completely outside with the garage door shut.  Of course use some pliers to hold the card.  This method could work well, but just be sure not to heat the metal until it changes color. You can then clean off the melted plastic blobs with a flame retardant sacrificial rag.

The end results work great!  I also punched out the tiny SIM card in mine, but you can leave it in. It is potted with clear epoxy so you can see the chip and gold connection wires on the back side if you leave it in which is pretty cool.

Simple Tissue Box DIY Christmas Presents

Each year, Jess and I make crafts as Christmas gifts for family members.  This year, our first idea was too hard (as is typical) but we had another project we had wanted to do as well that worked out great!.

Firstly, we got some wooden Tissue Box covers.

emptyBox

The next step was to get a gel stain. We reused the same stain we used for our ukulele project which goes a long way.

We then used our KNK Zing vinyl cutter to cut a vinyl sticker Jess designed as a template to help up print a design on the boxes.  We placed our clear transfer paper on the box and drew the outside dimensions to help us align the design.

 

tempalte3template

When placing this on the actual box, it helps to hold it up to the light so you can see the edge of the box well.

lightlight2

When we ran out of large pieces, we cut the designs on scrap vinyl and pieced it together on the transfer paper. Here’s an example:

tempalte 4

 

Once we had all the templates set up. We removed the clear transfer vinyl and used a dark gel stain and a foam brush to blot the stencil.

staining

This was left for about an hour to dry until tacky and then we removed the stencils.

weeding

We then left the stain to dry completely overnight.

before

We finished the boxes with a light coat of white gel stain. The trick is to paint it on with the foam brush, then wipe off excess with a nice paper towel (This brand of paper towels are best for these kinds of crafts as they don’t leave any fuzzy mess behind).  Do this technique to all sides of the box, even if they don’t have a stain design.  This gives a rustic whitewashed look that still shows the figure in the wood a bit and evens out the design overall, making it look completely finished and cohesive.

Wipe on:

afterPaint

and wipe off:

wipe