Week 16 Assignment - interface and application programming

Goals

Assignment

Simple computer controlled stepper

For my final project I'll make a CNC machine that can receive commands either from a controller card or from a computer. For week15 I did the controller card stream.I can use this week to visualize and simulates the command stream and use it for debugging later when I am building my CNC machine.

    I had time for trying two "tool options" this week:

  1. Interface Processing to motor controller
  2. Visualizing serial data with Python
  3. Testing open source GUIs

Results

Running a prototype of my final project CNC machine with PC interfaces.

Through Processing

Through Python

1. Interface Processing to motor controller

I choose to try building a graphical computer interface in Processing first since I have limited programming experience and feared that I could easily drown in work if I tried any of the more complex options. Processing is similar to Arduino so it was easy to get started in.

I reused the CNC-test bench setup I hade made for last weeks assigment but this time I sent the commands from the computer instead from another circuit board.

I connected the FTDI cable to the modified Satshakit board I had made during week15 and hooked that up to my stepper driver I made in week10. I screwed everything to a plate to make it stay still while I exerimented. I am really glad I did since it made it possible to leave everything hooked up while moving the plate around.

Image credit and more info at https://processing.org/tutorials/drawing/

Graphics in Processing is built and referenced using an X-Y coordinate system. In its simplest form you just write coordinates for everything.

I feel that if I wanted to build anything more complex I would look into importing SVG files or find a framework to simplify organizing buttons and text relative to each other.

The interface

My Processing code is based on the SimpleWrite and SerialDuplex examples that come with Processing. You find them under File-Examples.

2. Visualizing serial data with Python

Secondly I wanted to try Python since I had heard much good about it and never tried it before.

Since I did a motor control interface in Processsing I thought I could try and make a vizualizing interface in Python.

Interfacing through web browsers would be fun and interesting to know how to do but will have to be considered a "bonus" goal if I have time to implement it.

I started with setting up Python and getting it listening to the serial data stream using the same setup as I did for Processing above.

The same setup with some different wiring

My tutorial for: Reading serial data using Python 3 in Windows 10.

Problems I had,

Interface microcontroller to Python

I used this reference for simple python graphics. It uses the graphics.py library.

It seems like an easy to use and useful library where you easily could generate point and click interfaces. After playing around with it for I while I found it to be too limiting, I could for example not find a rotate function and editing everything using coordinates in text is just too slow. If I wanted to build a nice and functional interface I would want a GUI to built it in! I assume I can draw in Inkscape and use the XML data to generate python graphics?

Python code
Arduino code

UPDATE! Trying out open source GUIs with DIY CNC machines

Universal Gcode sender windows GUI

For my final project I made a CNC machine, when I had all axis working I programmed my controller with GRBL, an open source CNC motion controller. GRBL works well with a range of open source GUIs. I choose to try out Universal Gcode Sender. It has a modular front end to make it easy to customize the GUI to individual needs.

Here is a video of me running my machine programmed with GRBL via Universal Gcode sender on my windows laptop.

Octoprint web GUI

In Fab Lab Lyngen just before Fab Academy started I had the opportunity to try out Octoprint a web based CNC control interface, that Jens Dyvik was running on a Beaglebone controlling his Award-plotter CNC milling machine. It was very inspiring to see. It was possible for anyone to take control of the machine by visiting a web page on the local wi-fi on their computers or smart phones. This has huge potential for making interactive displays where bystanders can participate. I hope to use setups like it in future projects.



Top