Skip to content
AKA Smoopi. A Smoothie host, running on rpi with touch screen, or on a Desktop
Branch: master
Clone or download
Latest commit e1ae943 Jul 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
img tweak icons May 1, 2019
libs/graph Initial tempo graph Oct 21, 2018
modules fix M220 in hb04 May 16, 2019
pics added goice help screen shot Mar 23, 2019
scripts add example scripts directory Apr 29, 2019
tests fix errors condtion handling when conenction is bad May 14, 2017
.gitignore
LICENSE Create LICENSE Apr 24, 2017
README.md Update README.md Jul 3, 2019
camera_screen.py Change camera viewer to pull snapshot rather than stream Sep 21, 2018
comms.py all M6 at end of line to trigger tool change (eg T0 M6\n) Apr 25, 2019
config_editor.py disable the handles and bubbles on textinputs for rpi as it causes is… Mar 24, 2019
desktop.kv Refactor the tools menu and wether the camera entries are added or not Apr 29, 2019
desktop_large.kv Refactor the tools menu and wether the camera entries are added or not Apr 29, 2019
desktop_wide.kv Refactor the tools menu and wether the camera entries are added or not Apr 29, 2019
dial-gauge.py Allow dial gauge toindicate invalid temp Apr 4, 2018
dro.kv more disbaling of selection handles etc Mar 24, 2019
extruder.kv
extruder_widget.py allow DRO input to be /2 to halve the current position Apr 30, 2019
file_dialog.py white space Apr 23, 2019
gcode_help.py Add gcode help, either the ? in the console or send ? command in comm… Mar 7, 2019
gcodes.txt Gcode help list M7 M8 M9 May 19, 2019
graph-view.py reset graph if disconnected Oct 22, 2018
input_box.py more disbaling of selection handles etc Mar 24, 2019
jogrose.kv missed one Mar 24, 2019
kbd.kv disable the handles and bubbles on textinputs for rpi as it causes is… Mar 24, 2019
macros.kv move the reprint last and view last to the tools menu Apr 3, 2019
macros_widget.py Add a macro that starts with @ that opens the following filename and … May 22, 2019
main.py fix standalone gcode viewer Jun 14, 2019
message_box.py add actionbar instead of buttons May 1, 2017
mpg.kv add a wide layout for wide screens Apr 16, 2019
mpg_knob.py
multi_input_box.py more disbaling of selection handles etc Mar 24, 2019
native_file_chooser.py setting display type drop down selection Mar 24, 2019
numeric.json allow DRO input to be /2 to halve the current position Apr 30, 2019
rpi.kv
sample-hb04.ini hbo4 start button will run last file viewed or run Apr 24, 2019
sample-macros.ini Add a macro that starts with @ that opens the following filename and … May 22, 2019
selection_box.py Fix other input and selection boxes Jan 3, 2019
spindle_camera.py allow spindle cam to run standalone again Jun 6, 2019
text_editor.py disable the handles and bubbles on textinputs for rpi as it causes is… Mar 24, 2019
tool_scripts.py lint style fixes Apr 21, 2019
viewer.py fix standalone viewer again Jun 15, 2019
web_server.py Refactor the tools menu and wether the camera entries are added or not Apr 29, 2019

README.md

Smoopi

A Smoothie host designed to run on an rpi with multitouch screen or on a desktop with a mouse and keyboard.

This is a work in progress, but is stable and ready for everyday use.

This uses python >= 3.4.3 and <= 3.6

Use an RPI-3 Model B or B+, or the RPI-3 Model A+ with RPI multitouch screen. (No XWindows, but multitouch is required if there is no keyboard or mouse). Also runs on pretty much any Linux XWindows desktop (and maybe Mac).

It will run on Windows if you install Python 3.5.2, and follow the kivy instructions for installing kivy on windows. https://kivy.org/doc/stable/installation/installation-windows.html

NOTE it currently does not run on python versions > 3.6 due to async changes.

The minimum usable resolution is 800x480.

Goal

The goal is to have a small touch screen host that can run a smoothie and is better than an LCD Panel, and almost as good as a host PC running pronterface. It is not meant to be a replacement for say Octoprint whose goals are different. A secondary goal is to have a decent smoothie aware desktop host to replace Pronterface and bCNC, that has good support for CNC tasks as well as 3D printing. The CNC goals are to allow setting of the WCS to a point on the workpiece, and move to points on the workpiece to check for placement etc.

(UPDATE there is now a desktop layout setting that makes it more usable on a regular desktop, it has been tested on various linux machines but should run anywhere that python3 and kivy will run).

An RPI with 7" touch screen is about the same price as the better LCD panels, and makes a great standalone controller for a 3D printer.

Usage

To select the port to connect to click the System menu and select Port, then select the serial port from the list, or for a network connection select Network... then enter the host or ip optionally followed by the port :23 (23 is the default if not specified), eg smoothieip or 192.168.0.2:23 (NOTE network communication is not well tested). Once you have selected a port to connect to it is saved in the ini file, and you can then click the connect menu item to connect.

The left screen is the console and displays messages from smoothie, the right screen is a selection of panels (Modes) which can be switched to using the tabs to select the panel you want, you can scroll the left screen up and down by swiping up or down.

There is a status bar at the bottom left showing status, DRO and print ETA when printing.

You can select 3d printer mode or CNC mode from the Settings menu, this can affect what Panels are available amongst other minor changes.

  • The Console panel has a keyboard for entering gcodes and if you touch the edit field a keyboard will pop up for typing commands (non gcodes). If you precede the command with ! it will be sent to the linux shell instead of smoothie. Sending ? will pop up a GCode reference screen.
  • The Extruder Panel is used to control temperatures and extuder. You can switch between gauge view and graph view by swiping left or right (or double click)
  • The Jog Panel has the usual jog controls.
  • The Macro Panel is a user configurable buttons panel to control whatever you want. (Edit the macros.ini file) There is a sample-macros.ini just copy that to macros.ini and edit as appropriate to define your own macro buttons.
  • The DRO Panel shows current MCS and WCS, and allows easy selection of the WCS to use, and allows setting of WCS. If WCS entered is /2 it will halve the current position. (Usefull for moving to the center of things)
  • The MPG Panel is a simulation of an MPG pendant, it allows control of movement and feedrate override via a simulated rotary knob. (There is an optional module to take controls from a real MPG USB pendant).
  • The config editor displays the current smoothie config in a scrollable window, values can be updated click the return key and then will update the config on sd accordingly. (reset is of course required to take effect).

There is a gcode visualizer window that shows the layers, or for CNC allows setting WPOS and moving the gantry to specific parts of the Gcode... Click the Viewer menu item, select the file to view, then the layers can be moved up or down. To set the WPOS to a point in the view click the select button, then touch the screen to move the crosshairs, when you have the point you want selected then click the set WPOS button, that point will be set as WPOS. To move the gantry to a point on the view click the select button, then touch and drag until you get the point and then click the move to button, the gantry will move to that point.

The Kivy file browser is pretty crude and buggy. To allow it to be usable on a touch panel I had to set it so directory changes require double taps on the directory. I also do not enable the Load button unless a valid file is selected by tapping the file. This allows swiping to scroll the file lists to work reliably. If running in desktop mode you can select a different native file chooser from the settings page. (You will need to install zenity or kdialog or wx for python3)

The Update System menu entry requires git to be installed and the running directory be a valid git repo pointing to github.

When running on a desktop you can jog using the keyboard up/down/left/right/pgup/pgdown keys, the default jog is 0.1mm, if ctrl key is pressed it is 0.01mm, if shift is pressed it is 1mm. pgup/pgdown move the Z axis. up/down move the Y axis and left/right move the X axis.

Macros

Macro buttons can be defined in the macros.ini file that can issue simple commands, can be toggle buttons, can be toggle buttons that monitor switches (eg fan, psu), that can issue shell commands to the host O/S, and that can run scripts on the host O/S that communicate with smoothie. Macros buttons can prompt for input and substitute the given variables. (See sample-macros.ini for examples). Simple macro buttons can be created by clicking the green New Macro button. If a simple macro starts with @ then the following characters are a file name and that file is opened and sent to smoothie. Note that ok is not checked, so it must be a fairly small file of gcodes.

CNC Support (PCB milling etc)

There are features specifically implemented to make CNC use easier.

  • Tool change can be enabled which will catch Tn/M6 commands and suspend the job allowing you to manually change the drill bit and/or tool and then return to the point it was suspended. Full jogging and resetting of Z0 is allowed while suspended. NOTE for toolchange to be caught by Smoopi the M6 must be on a line by itself or on a line and followed by at least one space, or at the end of the line... (eg M6\n or T6 M6\n)

  • Cambam tool change gcode is supported if the profile is slightly modified to output Tn followed by M6 on the next line, and will show the size of the bit required in the console window.

    <ToolChange>{$clearance}
    T{$tool.index} {$comment} T{$tool.index} : {$tool.diameter} {$endcomment}
    M6</ToolChange>
    
  • Flatcam gcode is supported but a minor postprocess on the gcode needs to be done so the comment showing the tool required is moved to before the M6 (it is currently after the M6 so you don't see it until after you resume).

M0 can be enabled and any (MSG, xxxx) is displayed in the console window. However M0 simply pauses the job until the dialog is dismissed. This presumes the tool heights are all thhe same and no jogging is required to change a tool

The viewer allows setting the WCS to any arbitrary point on the workpiece, and to move to any point on the workpiece. This allows positioning and size checking before the job is run.

Install on RPI

NOTE on the current image and all installs on raspbian you need to add this...

> sudo jove /etc/udev/rules.d/90-smoothie.rules
and add this...

SUBSYSTEM=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="6015", MODE="0666"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="6015", MODE="0666", SYMLINK+="smoothie%n"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="6015", RUN+="/bin/stty -F /dev/ttyACM%n -echo -echoe -echok"

The last line is quite important otherwise you get a whole lot of ok's echoed back to smoothie when it opens. This does not appear to be needed on a desktop probably due to the speed it is setup vs the rpi.

Image

For RPI and touch screen you can just download the image which has a fully running version smoopi with autostart, blanking etc, so no need to do anything else.

Download from http://smoothieware.org/_media/bin/smoopi.img And image it to an sdcard using for instance https://www.balena.io/etcher/

Once loaded boot into the sdcard, and then update raspbian stretch...

  • login in with username pi and password raspberry
  • sudo apt-get update
  • sudo apt-get upgrade
  • setup wifi using sudo raspi-config

smoopi is normally run on bootup, but in order to allow you to login and do the initial setup it is initially down. You will need to hook up a keyboard temporarily so you can access the login and run raspi-config etc.

Once that is done setup smoopi to run on boot by doing...

> sudo rm /home/pi/sv/smoopi/down
> sudo sv up /etc/service/smoopi

Once running use the System menu upgrade to fetch the latest smoopi. If that is successful, then quit under the System menu and smoopi will exit and then be restarted by runit.

Rasbian/Debian Stretch on RPI

(Tested on genuine RPI 7" multitouch screen and external HDMI LCD monitor).

Install the latest raspbian stretch lite... (No XWindows) https://downloads.raspberrypi.org/raspbian_lite_latest

Follow these instructions if using an rpi 3 B+ and rasbian stretch... https://kivy.org/doc/stable/installation/installation-rpi.html

But change all references to python.. to python3.. As we need kivy for python3.

For instance...

sudo apt-get update
sudo apt-get install libsdl2-dev libsdl2-image-dev \
   libsdl2-mixer-dev libsdl2-ttf-dev \
   pkg-config libgl1-mesa-dev libgles2-mesa-dev \
   python3-setuptools libgstreamer1.0-dev git-core \
   gstreamer1.0-plugins-{bad,base,good,ugly} \
   gstreamer1.0-{omx,alsa} python3-dev libmtdev-dev \
   xclip xsel
sudo apt-get install python3-pip
sudo pip3 install -U Cython==0.28.2
sudo pip3 install --upgrade git+https://github.com/kivy/kivy.git@stable-1.10.1

This installs a known working version of kivy, albeit an older one. Newer versions seem to be somewhat unstable on RPI.

On an rpi3b+ it seems the double tap time needs to be increased to be usable..

# in file ~/.kivy/config.ini
[postproc]
double_tap_distance = 20
double_tap_time = 400 # <-- increase this from the 200 default
triple_tap_distance = 20
triple_tap_time = 600 # <- and this to be > than double_tap_time

Keyboard and Mouse support

Kivy uses a module called the HIDInput for an external (USB) Mouse and keyboard. This HIDInput is broken in all the releases of Kivy older than 1.11.0. If using an older version of kivy you will need to replace the KIVYINSTALLDIR/kivy/input/providers/hidinput.py with this version: https://github.com/wolfmanjm/kivy/blob/master/kivy/input/providers/hidinput.py

You will also need to add the following line to your ~/.kivy/config.ini file under the [input] section:-

[input]
%(name)s = probesysfs,provider=hidinput

and the following line under the [modules] section:-

[modules]
cursor = 1

Common setup

It is recommended to do this:-

> sudo apt-get update
> sudo apt-get upgrade

Install some smoopi dependencies...

> pip3 install pyserial pyserial-asyncio aiofiles

Install Smoopi itself

> mkdir smoopi
> cd smoopi
> git clone https://github.com/wolfmanjm/kivy-smoothie-host.git .

Run with...

> python3 main.py

NOTE make sure the ~/.kivy/config.ini has the following set so the virtual keyboard works in a usable fashion on an RRI touch screen...

[kivy]
keyboard_mode = systemanddock
desktop = 0

If your ~/.kivy/config.ini is empty or not setup for the touch display then here is an example that works for the RPI official 7" touch screen:- https://gist.github.com/4f9c23c7e66f391b8c2d32c01e8a8d14

To allow the program to shutdown the RPI when the shutdown menu entry is selected you need to do the following, unless smoopi is running as root/superuser.

Use policykit (make sure policykit-1 is installed).

Create as root /etc/polkit-1/localauthority/50-local.d/all_all_users_to_shutdown_reboot.pkla with the 
following content:

[Allow all users to shutdown and reboot]
Identity=unix-user:*
Action=org.freedesktop.login1.power-off;org.freedesktop.login1.power-off-multiple-sessions;org.freedesktop.login1.reboot;org.freedesktop.login1.reboot-multiple-sessions
ResultAny=yes

Autostart Smoopi (Optional)

To autostart smoopi on boot but run as the pi user follow these directions. (Assuming you are using stretch)...

  1. Install runit (sudo apt-get install runit). On Raspbian Stretch also do sudo apt-get install runit-systemd
  2. in the /home/pi directory run tar xvf ./smoopi/runit-setup-stretch.tar (presuming you checked out the smoopi source into /home/pi/smoopi)
  3. sudo ln -s /home/pi/sv/smoopi /etc/service

To allow Smoopi to connect to the smoothie when auto start by runit you need to do this...

sudo jove /etc/udev/rules.d/90-smoothie.rules
and add this...

SUBSYSTEM=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="6015", MODE="0666"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="6015", MODE="0666", SYMLINK+="smoothie%n"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="6015", RUN+="/bin/stty -F /dev/ttyACM%n -echo -echoe -echok"

smoopi is now managed by runit. (This has the side effect of restarting smoopi if it crashes).

The smoopi app will start, and will also start on boot. (To stop it you type sudo sv stop /etc/service/smoopi)

Shutdown and Startup button for RPI (Optional)

Optionally to add a button to boot and to shutdown the rpi install a NORMALLY OPEN push button on pins 5 and 6 on the header, then you need to add the shutdown script to autostart... sudo ln -s /home/pi/sv/shutdown /etc/service. NOTE you may need a capacitor across the button to stop noise shutting down the system.

Backlight on RPI

To allow Smoopi to turn on/off the backlight you need to do this...

sudo nano /etc/udev/rules.d/backlight-permissions.rules
and add this...
SUBSYSTEM=="backlight",RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"

NOTE the default is for no blanking, there is a setting under the settings menu that allows you to set the timeout for blanking the screen, it is initially set to 0 which is no blanking. If it blanks then touching the screen will unblank it.

Builtin webserver and optional camera

In Settings you can turn on the webserver which will simply allow you to get current progress from any web browser, nothing fancy. Also in Settings you can enable the video option which uses mjpg-streamer (which needs to be built and installed, See https://github.com/jacksonliam/mjpg-streamer.git for instructions on that). If enabled and running then the video will show up in the progress web page. There is also a camera option in the system menu which allows a preview of the camera view, the url for this is also in the settings, and should be the url which gets a snapshot single jpeg frame from the camera.

On linux Desktop (and maybe windows/macos)

Install on recent Linux and python >= 3.5 using the fast wheels installation...

python3 -m pip install --user --upgrade kivy

See https://kivy.org/doc/stable/installation/installation-linux.html#using-wheels

If that does not work then install from source...

sudo apt-get update
sudo apt-get install libsdl2-dev libsdl2-image-dev \
   libsdl2-mixer-dev libsdl2-ttf-dev \
   pkg-config libgl1-mesa-dev libgles2-mesa-dev \
   python3-setuptools libgstreamer1.0-dev git-core \
   gstreamer1.0-plugins-{bad,base,good,ugly} \
   gstreamer1.0-{omx,alsa} python3-dev libmtdev-dev \
   xclip xsel
sudo apt-get install python3-pip
sudo pip3 install -U Cython==0.28.2
sudo pip3 install --upgrade git+https://github.com/kivy/kivy.git@stable

stable seems to work ok so long as it is v1.10.1.

Install some dependencies we need...

sudo pip3 install pyserial pyserial-asyncio aiofiles

Run as

> cd kivy-smoothie-host
> python3 main.py

In settings set the desktop layout to Small Desktop or Large Desktop and restart. The large desktop layout can also have a size specified by editing the smoothiehost.ini file and changing eg screen_size = 1024x900 under the [UI] section.

NOTE all the files are coded UTF-8 so make sure your locale (LANG=en_US.utf8 or even LANG=C.UTF-8) is set to a UTF-8 variety otherwise you will get weird errors from deep within python/kivy.

Smoothie version required

This requires the latest FirmwareBin/firmware-latest.bin from Smoothie github, (or FirmwareBin/firmware-cnc-latest.bin).

NOTE to use the T0 and T1 buttons in the Extruder panel the temperature controls need to have the following designators 'T' and 'T1'. The temperature for the currently selected tool will show, and the set temp will apply to that tool.

Spindle Camera

There is support for a spindle camera (or just a regular camera). On a rpi if you are using the rpi camera you need to install a couple of extra modules...

pip3 install --user picamera numpy

and remember to enable the camera in raspi-config.

To use a USB camera it should just work.

Usage

There are various buttons in the spindle camera screen as well as a cross hair in the center.

zero will set the X and Y WPOS to zero at the current position

capture will create a PNG of the current camera screen in the current directory

jog Enters touch jog mode

invert Inverts the jog movement

back Exits the spindle camera window

To jog and focus you need to use multitouch on an RPI screen. Once the jog mode button is pressed one finger slid left or right will jog in the X axis by 0.001mm, two fingers will jog by 0.01mm, three fingers will jog by 0.1mm. Slide up and down will move in Y. Four finger slides up/down will move the Z axis up/down to focus the camera. NOTE that only the first finger to touch is tracked so if that is lifted it will no longer jog until all fingers are lifted. If four fingers touch then it enters z jog mode and will stay in that mode until all fingers are lifted.

If using one of the desktop layouts you will have access to the jog screen for jogging, or you can use the pendant.

Pendants

There is support for a home made MPG pendant using a Teensy as a rawhid device. Also the LHB04 Mach3 pendant.

Home made

Project here...

Then you need to do the following on the rpi...

  • sudo apt-get install libffi-dev

  • sudo apt-get install libhidapi-libusb0

  • git clone https://github.com/ahtn/python-easyhid

  • cd python-easyhid

  • sudo python3 setup.py install

  • add to the smoothiehost.ini file...

    [modules] mpg_rawhid = 0x16C0:0x0486

  • create a file /etc/udev/rules.d/49-teensy.rules and add the following...

    ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", ENV{ID_MM_DEVICE_IGNORE}="1" ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789A]?", ENV{MTP_NO_PROBE}="1" SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789ABCD]?", MODE:="0666" KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", MODE:="0666"

Then you will have the MPG/Pendant controller available for jogging etc.

(NOTE you need the latest version of smoothieware dated greater than 1 October 2018 to support the $J command)

HB04 wired USB

Support for the wired LHB04 MACH3 USB pendant is now available. add the following to the smoothiehost.ini file...

[modules]
hb04 = 0x10ce:0xeb70

The button functions can be defined in the hb04.ini file (see the sample-hb04.ini file)...

[macros]
# user defined macro buttons
macro1 = G0 X20 Y20
macro2 = G0 {axis}0
#macro7 = 
#macro3 = 
#macro6 = 
#rewind = 
# predefined buttons can be overriden
#start = runs last file viewed or run
#safez = G91 G0 Z20 G90
#origin = G90 G0 X0 Y0
#probez = G38.3 Z-25
#zero = G10 L20 P0 {axis}0
#home = $H
#spindle = M3 or M5 depending on whether spindle switch is on or off
#half = "G90 G0 {}{}".format(axis, self.app.wpos[axis-88]/2)

Python Easyhid needs to be installed...

then add this to /etc/udev/rules.d/50-HB04.rules...

SUBSYSTEMS=="usb", ATTRS{idVendor}=="10ce", ATTRS{idProduct}=="eb70", MODE:="0666"

Plug in the HB04 and turn it on, then run smoopi.

Many of the buttons have default actions, but can be redefined in the [macros] section of the hb04.ini file. NOTE that if {axis} appears in the macro it will be replaced by the currently selected axis.

The hard coded buttons are the step button which increases the move multiplier, and the MPG button next to it which decreases the multiplier. at x1 each encoder click moves 0.001mm, at x10 it moves 0.01mm, at x100 it moves 0.1mm etc.

The Stop button will send a kill/halt (control X) to smoothie and the reset will send $X to unkill.

The move to origin and home buttons do as you would expect. The =0 button sets the WCS of the selected axis to 0. The spindle button will toggle the spindle switch on and off (if one is defined) The =1/2 button will set the WCS of the currently selected axis to half the current position. (eg if WCS is set to 0 at left edge and spindle is at right edge it would set the WCS X to half the current value so then going to G0 X0 it would move the spindle to the center X position)

Screen shots

Extruder screens

Extruder Screen Temp Graph

DRO screen

DRO Screen

Command screen

Command Screen

Jog screen

Jog Screen

Macro screen

Macro Screen

MPG screen

MPG Screen

Config Editor

Config editor

GCode viewer

Gcode Viewer Screen Selection in Gcode Viewer Screen

Settings

Settings

GCode help screen

GCode Help Screen

Desktop mode

Desktop Screen

You can’t perform that action at this time.