The following was inspired by Bruce's YouTube video
Setting up a Raspberry Pi as the USG Platform host
1. Workshops are not good places for computers, especially computers that suck air into the PC’s insides to stay cool. Most laptops do just that. The Raspberry Pi can rely on ambient cooling and so does not require a fan if adequately ventilated. The following instructions are for a basic, i.e., functional setup, where the Raspberry Pi will be connected to your control box via the USB cable and remotely operated from a PC. The Pi will need to be connected to network to setup, but if a network connection is not available after setup, you will be able to transport your Gcode via a USB stick.
2. This setup uses the following components
• Raspberry Pi 4 with 4 GB RAM
• Power supply
• 128 SD card (probably too much)
• Heat sinks (from what I have read, small fans connected to heatsinks are not effective)
• 7” touchscreen monitor (most HDMI capable monitors will work)
• Miniature Bluetooth keyboard with built in trackpad / mouse (any USB or Bluetooth keyboard will work- the mouse / trackpad can be separate or a single unit)
• HDMI to HDMI-Micro cable (my touchscreen came with the needed cables)
• For my setup the Pi mounts to the back of the touchscreen, so I did not buy a case.
3. Altogether the components cost about $200. There are many kits that contain just about everything you need, and the cost is just about the same as buying individual components. You can probably get by with a 2GB Pi, a 16 or 32 GB SD card, and running headless, i.e., without a dedicated keyboard, mouse and monitor. That setup should be below $100.
Setting up the Raspberry Pi and making it accessible from a PC
Note: Some steps are performed on a PC or Mac. The following is a summary loosely based on:
crosstalksolutions.com/getting-started-with-raspberry-pi-4/1. Install the heatsinks. You only need to worry about the CPU (large silver chip) and the USB controller which is right behind the USB connectors. Some kits include heatsinks for the Wi-Fi and RAM chips. It does not hurt to add additional heatsinks.
2. Connect a mouse and keyboard to the Pi via the USB 2.0 ports.
3. Connect a monitor via a HDMI / HDMI-Micro cable. Use the micro connector nearest the USB-C power connector.
4. If desired, connect to your network via an Ethernet cable. Not required if you have Wi-Fi but set up might go a bit faster.
5. Do not connect power yet.
6. On your PC, download Etcher:
www.balena.io/etcher/7. On your PC , download “Raspberry Pi OS (32-bit) with desktop and recommended software” onto your PC from:
www.raspberrypi.org/downloads/raspbian/8. Mount the SD card on your PC and run Etcher to transfer the image to the SD card. No formatting or other steps are required. Make sure you are flashing the right drive letter.
9. Insert the SD into the slot on the back of the Pi (it only goes one way).
10. Connect the power supply to the USB-C port on the Pi and power up the Pi. The Pi will automatically boot and start the installation. (expect a few minutes of blank screen time). It takes 15 to 20 minutes which includes a software update check at the end.
• If you are connected via Ethernet, then part way through you will see an IP address. If you plan to continue to use an Ethernet connection, take a note.
• Continue to follow the prompts to define the keyboard, the time zone, etc.
• You will be prompted to create a new password.
• You will be provided an opportunity to connect to available Wi-Fi networks.
• An automatic update should occur and then you will be prompted to restart.
• Automatic updates sometimes fail. If that happens, open Terminal and enter: sudo apt-get update and hit enter. Then enter: sudo get-apt upgrade -y. A reboot will be required.
• Now go to the tool bar and click on the Raspberry icon and in the menu, select Preferences >> Raspberry Pi Configuration >> Interfaces. Enable both SSH and VNC.
11. Set up VNC:
www.raspberrypi.org/documentation/remote-access/vnc/• Enable VNC server: In Terminal enter: sudo apt install realvnc-vnc-server.
• Find your IP address by running ifconfig in Terminal. Look for the word inet it will be followed by something like: 192.168.1.XXX.
• Download and install VNC Viewer on your PC.
• On your PC, launch VNC Viewer, click on File >> New Connection and follow the prompts.
• You should now be able operate your Pi from your PC.
Install Universal Gcode Sender Platform (UGS)
Note: You will want to have identical UGS installations on both your PC and Pi.
1. Install Universal Gcode sender Platform on your PC
• Go to
github.com/winder/Universal-G-Code-Sender#downloads and select and the appropriate build from the Downloads section. It can be run from any directory. These builds have Java built in so there is no need to install Java separately. Note that there are also Stable Build options (do not include Java yet). Nightly Build will have the latest features, while the stable build is less risky, it may take more effort to get working. If I were doing production, I would opt for the Stable Build, but in reality, if you are doing production you are probably not reading this. There is no “Installation”, therefore uninstall is manual because the OS does not know about the application.
• In the PC, the only files I could find after installing are those that are unzipped and a .ugsplatform folder created in C:\Users\YOUR USER NAME.
• For my PC I chose: C:\Program Files\UGS Platform. If you don’t have admin rights, you might need to choose another location. The executable is located in …\ugsplatform\bin.
• For Many CNC systems, the Gcode lines will exceed the default max length in UGS. If it is not changed, the code will fail. The most common maximum line length seems to be 70. Go to Tools >> Settings >> UGS to access this option. Click the Edit button for Command Length Processor. Replace 50 with 70. DO NOT EDIT/REMOVE ANY OTHER TEXT. Click Yes >> OK.
2. Preparing your Pi
A. Activate OpenGL driver: From the Terminal run sudo raspi-config. Then choose Advanced Options >> GL Driver >> GL (Fake KMS).
B. Expand the file system: Advanced Options >> Expand the file system.
C. Finish and reboot.
3. Install Universal Gcode Sender (UGS) Platform on your Pi
• Go to
github.com/winder/Universal-G-Code-Sender#downloads and select and the appropriate build from the Downloads section. Expand it to the directory of your choice, but everything that follows here assumes it is in /home/pi/ugsplatform. A startup bash script file named ugsplatform is in …\bin.
• For Many CNC systems, the Gcode lines will exceed the default max length in UGS. If it is not changed, the code will fail. The most common maximum line length seems to be 70. Go to Tools >> Settings >> UGS to access this option. Click the Edit button for Command Length Processor. Replace 50 with 70. DO NOT EDIT/REMOVE ANY OTHER TEXT. Click Yes >> OK.
• For a Universal G Code Sender Tutorial go to:
winder.github.io/ugs_website/guide/platform/4. Running UGS Platform via VNC
• If you want to run both VNC and the UGS Visualizer it takes a bit of start-up gymnastics because Raspbian comes with a proprietary video driver which is not supported by the OpenGL-library that UGS is using. The trick is to temporarily rename the proprietary driver while starting UGS Platform. 45 seconds of delay should be enough, but if not, increase the time. This is accomplished by creating a Bash script to call the USGPlatform Bash script. The following is based on David Grimm’s comments near the bottom of
cebess.wordpress.com/2019/10/14/installing-universal-g-code-sender-on-the-raspberry-pi/ • Open Accessories >> Text Editor and create a file named my_ugsplatform in the /home/pi/ugsplatform/bin/ with the following code:
#!/bin/sh
sudo mv /opt/vc /opt/vc.old
/home/pi/ugsplatform/bin/ugsplatform &
sleep 45
sudo mv /opt/vc.old /opt/vc
echo “Finished”
• Make the script executable: In Terminal navigate to the directory with the new script: cd /home/pi/ugsplatform/bin then type: sudo chmod u+x my_ugsplatform
• You can also create a desktop shortcut to call the new Bash script. To do this open Accessories >> Text Editor and create a file named ugs.desktop in the /home/pi/Desktop/ that contains the following code:
[Desktop Entry]
Name=Universal Gcode Sender
Exec=/home/pi/ugsplatform/bin/my_ugsplatform
Type=Application
Icon=/home/pi/ugsplatform/bin/ugsplatform.exe
Terminal=false
Categories=None;
StartupNotify=true
Path=/home/pi
For more technical information on .desktop files go here:
specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html