Skip to content

Latest commit

 

History

History
executable file
·
294 lines (221 loc) · 9 KB

Draw-Vinci.adoc

File metadata and controls

executable file
·
294 lines (221 loc) · 9 KB

Draw-Vinci

Introduction

hw
Figure 1. MakeBlock XY Plotter + XMC4500

Project Description

Design and develop both a multi-threaded PC GUI application as well as an XMC RTOS application using uCOS-III to control a MakeBlock XY plotter as shown below. In either case you can select a file format (G-Code, Excellon, HPGL or SVG — see below) to determine the content that shall be drawn using the machine. As an alternative you could devise a simple drawing application to do the same. The stepper motors and the servo motor are controlled by the XMC4500 via an IO expander board and several driver boards.

Formats supported

Images

Here is the subset of SVG parameters supported and recognised when opening, importing or saving:

width

Width of display

height

Height of display

viewbox

Dimensions of view

rect

Rectangles

ellipse

Ellipses

circle

Circles

polyline

Group of lines

polygone

Polygones

path

Paths

text

Texts

transform

Just the translation matrix is supported til now

Note

Colors not supported!

G-CODE Specification

Here is the subset of G-CODE currently supported

G28

Perform homing routine

G90

Absolute mode positioning

G91

Relative mode positioning

G01

Linear interpolation

G02

Circular interpolation

Possible commands:

  1. #G28$ : Plotter will move to its (0, 0) position and stop there.

  2. #G90$ : Plotter will interprete all subsequent commands as absolute movements.

  3. #G91$ : Plotter will interprete all subsequent commands as relative to the current position.

  4. #G01:XA:YB$ : Plotter will move linearly to the point (A, B) - relative or absolute.

  5. #G01:ZK$ : Plotter’s pen will be dropped (K = 1) or lifted up (K = 0).

  6. #G02:XA:YB:IC:JD$ : Plotter will move in a circular way to the point (A, B), taking as reference the center at (A+C, B+D) - relative or absolute.

GUI

470
Figure 2. Main Window with control tab
470
Figure 3. Main Window with draw tab

Scaling & Resolution

Using baudrate of 75000 for the spi, the following mesurements were found for the various step mode:

HW-Adjustment Mode x, y-Dimension

S1=L, S2=L, S3=L

FULL_STEP

(2010, 1728)

S1=H, S2=L, S3=L

HALF_STEP

(4020, 3456)

S1=L, S2=H, S3=L

QUARTER_STEP

(8035, 6907)

S1=H, S2=H, S3=L

EIGHTH_STEP

(16061, 13806)

S1=H, S2=H, S3=H

SIXTEENTH_STEP

(32107, 27607)

The ratio of steps measured is ~1,1633, i.e. HEIGHT_STEP = ~0,86*WIDTH_STEP. The canvas where the user can draw something has the dimension: 555px X 477px, accounting for a ratio of ~1,1635.

In effect, every point (x, y) in canvas, will be scaled as follows:

  • x_to_plot = x . (WIDTH_STEP/CANVAS_WIDTH)

  • y_to_plot = y . (WIDTH_STEP/CANVAS_WIDTH)

so that for the point (0, 0) in GUI, the plotter will receive (0, 0) and for the point (555, 477), the plotter will receive (WIDTH_STEP, ~0,86*WIDTH_STEP).

Functionalities

Key Combinations

Ctrl+N

Clear canvas and start new drawing

Ctrl+O

Open a new SVG file

Ctrl+S

Save current canvas

Ctrl+Shift+S

Save current canvas with a new name

Ctrl+?

Open about dialog

Ctrl+Z

Remove last added item from canvas

Del

Remove selected item from canvas

Menus

  1. File

    1. New: clean canvas and start new project.

    2. Open: opens a svg file.

    3. Save: saves canvas to already saved file or calls save as if still not saved.

    4. Save As: saves canvas with a new name.

    5. Quit: closes app.

  2. Settings

    1. Svg Directory: define the directory to import the svg’s from when using the import tool.

    2. Step Motor: define the step resolution, according to section 'Scaling & Resolution'.

  3. Help

    1. About: basic info about this app.

Draw Tab

Drawing Tools

Eraser

Remove elements of canvas.

Freehand

Permits to draw in a free style.

Line

Used to draw lines.

Square

Used to draw squares.

Rectangle

Used to draw rectangles.

Polygone

Used to draw polygones.

Select

Permits to select items on canvas. When selected, an item can be removed clicking 'del' on the keyboard.

Magnifier

Permits zoom in using a user-defined rectangle. With the left button of the mouse, the user can define a rectangle to zoom in and with the right click of the mouse, the user can zoom out completely to the default scale.

Text

Used to write a text on canvas. Although this still cannot be plotted!

Circle

Used to draw circles.

Ellipse

Used to draw ellipses.

Import

Used to import to canvas the current image on the nextSVGButton.

Control Tab

Control Tools

Manual & Auto

The mode should be set before pressing play to start a new permanent connection with the plotter.

PromptEdit

Using the promptEdit the user can send single messages onto the XMC4500.

Mini Terminal

Terminal displays the messages sent within manual mode onto xmc4500. Besides, it always display the incoming messages from xmc4500.

Directional Buttons

The user can manually control the motors when in manual mode.

Pen Button

The user can manually control the pen position when in manual mode.

Clear Terminal

It will clear the mini terminal completely.

Mode
Manual

In this mode one can use the directional and pen buttons to control the plotter.

Auto

In this mode one can generate g-code automatically when pressing the play button. A progress bar will show the progress of the plotting. Using the pause button, the user can always pause the current plotting and use the flow control buttons to step through the g-code commands and plot the next or previous commands.

XMC4500

Servo Motor Function

Algorithm

Any time the XMC4500 receives something through its UART channel, it gets interrupted. The message is then read and forwarded onto the 'AppTaskCom' task. This task will check the message for protocol compliance and interpret the content. The 'AppTaskCom' task will finally send the interpreted message (now in the form of a structure) to the 'AppTaskPlot' task, that will execute the command received. When the 'AppTaksPlot' is done with the g-code command it will send an acknowledge message. If a '#GX:…​$' is sent, then the microcontroller will send at completion the string: '#GX:DONE$'.

Communication

The communication between GUI and the XMC4500 happens through UART, using the following scheme as protocol.

Protocol

Frame of Protocol
Figure 4. Protocol Frame

Where:

  1. #: Beginn of message;

  2. G COMMAND: One of the supported G-Code commands [vide following section];

  3. ARG{1}: a apropriate argument to the G command;

  4. ARG{2}: another apropriate argument to the G command;

  5. $: End of message;

Note

The number of arguments in a message should conform to the G command

Error Table

portErrorsTable
Figure 5. Possible errors codes by connection

Build

The software comprising this project was built and tested using the following environment:

Hardware
Plotter
  1. MakeBlock XY_Plotter

Microcontroller
  1. Infineon XMC4500

Interface
  1. UART TTL

  2. USB

Operating Systems
Linux
  1. Ubuntu 16.04

    • Desktop

  2. Ubuntu 17.04

    • Desktop

  3. Ubuntu 18.04

    • Desktop

  4. Fedora 28

    • Desktop

Framework & Tools
GUI
  1. PyQt5 + Qt

    1. Qt Designer

    2. pyuic5

Firmware
  1. Micrium

    1. uCOS III

  2. Infineon

    1. XMCLIB

Documentation
  1. Asciidoctor

    1. asciidoctor-pdf

Dependencies

Installation of dependencies:

sudo -H pip3 install pyqt5
sudo -H pip3 install pyudev

If you’re using Fedora, maybe you’ll need:

dnf install python3-pyudev-qt5

Flashing the XMC4500

Inside the project directory go to: ./xmc4500/APP/ and call 'make flash'

Running the app

Inside the project directory go to: ./gui/ and call 'python3 app.py'