CNC Graphics Tablet V2

243

1

4

Introduction: CNC Graphics Tablet V2

About: 55+ years in electronics, computers, and teaching ... now retired.

This instructable demonstrates a major software upgrade to the graphics tablet described in https://www.instructables.com/CNC-Graphics-Tablet...

The software upgrade supports the following:

Operation is simple ... decide whether the next outline is straight / curved and touch the appropriate menu button ... or draw freehand.

The estimated cost of construction is less than $25.

Images

  • The cover image shows the image to be traced
  • Photo 2 shows the traced image outline in the Processing3 graphics window
  • Photo 3 shows the Universal Gcode Sender Visualizer view
  • Photo 4 shows the original and scaled images side by side
  • The video shows the entire process from tracing the image to plotting

Notes

[1]

The tablet is intended for use with CNC plotters ... not CNC mills.

Step 1: Parts and Construction

Parts

  • Parts are the same as for https://www.instructables.com/CNC-Graphics-Tablet-1/ apart from a paper “menu” taped to the underside of the screen.

Construction

  • Construction details for the graphics tablet are described in https://www.instructables.com/CNC-Graphics-Tablet-1/
  • Download and print the attached file “menu.jpg” (photo 4)
  • Tape the menu to the underside of the graphics tablet screen as shown in photos 2 and 3 above.

The estimated cost of construction is less than $25.

Images

  • Photo 1 shows the paper menu
  • Photo 2 shows the menu taped to the underside of the screen
  • Photo 3 shows the underside off the screen

Step 2: Software

Downloads

Download and install the following software on your computer:

Download each of the attached files

  • touchpad_sender.ino
  • touchpad_receiver_v2.pde

Arduino file installation

  • Download the attached file touchpad_sender.ino
  • Copy the file contents to a new Arduino sketch.
  • Save the sketch as “touchpad_sender” (without the quotes)
  • Compile and upload the sketch to your touchpad Arduino

Testing the Arduino software

You can test this sketch as follows:

  • Open your Arduino “Serial Monitor”
  • Set the “baud” speed to 115200

You should see a stream of “S's" flowing down your monitor screen. This is the Arduino trying to “Sync” to the Processing sketch which has yet to be loaded.

  • Send an upper-case letter “S” from the Serial Monitor ... the stream of “S”s will stop ... the arduino now thinks it has the attention of Processing 3
  • Now send another “S” while touching the touchpad with a toothpick (or similar) ... the Arduino should respond with the XY touch coordinates.

The Arduino and Processing software use two-way handshaking when data is being sent ... to see another coordinate you will have to send another “S”

Close the Arduino Serial Monitor once you have finished testing.

Processing file installation

A Processing sketch is very similar to an Arduino sketch ... the only visual difference is that the Arduino loop() is replaced with a draw() loop.

  • Download the attached file touchpad_receiver_v2.pde [2]
  • Copy the file contents to a new Processing sketch.
  • Save the sketch as “touchpad_receiver_v2” (without the quotes)
  • Your Processing installation is now complete
  • Testing the Processing software
  • Plug your Arduino touchpad into your PCs USB port
  • Launch Processing3
  • Open Processing sketch “touchpad_receiver_V2.pde”
  • Left-click the Processing “Run” button at the top-left corner of the screen
  • The display should look like look like photo 1 [3]
  • Follow the on-screen instructions

Notes

[1]

The software should work with Processing 4 Beta 1.0 which is now available.

[2]

The included software uses variations of:

  • Bresenham’s Line Drawing Algorithm
  • the Three Point Circle Algorithm and
  • an original Arc Drawing Algorithm

The formula for drawing a line through three points is derived in this Instructable.

Formulas for drawing straight lines and arcs have previously been derived in https://www.instructables.com/CNC-Drum-Plotter/:

  • Step 5: Bresenham’s Line Drawing Algorithm
  • Step11: Arc length from gcode I,J biarc values

[3]

The numbers highlighted in red in photo 2 must match ... you will get an error message if your COM port has a different number.

Replace the [0] in your setup() code to match the your COM port number if you get an error message.

Step 3: Three Points on a Circle

This step derives the touchpad formulas and may be ignored.

The formula for an offset circle is :

r^2 = (x-h)^2 + (y-k)^2 .......................................................................................... (1)

Where:

  • r = radius
  • x = absolute x position along the X-axis
  • y = absolute y position along the Y-axis.
  • h = the horizontal offset the circle center is from the (0,0) XY coordinate.
  • k = the vertical offset the circle center is from the (0,0) XYcoordinate.

In the above diagram:

r1^2 = r2^2 = r3^2 ..................................................................................................(2)

From (1) and (2) we get:

r1^2 = r2^2

Substituting all knowns:

(x1-h)^2 + (y1-k)^2 = (x2-h)^2 + (y2-k)^2 ........................................................... (3)

Expanding (3) and cancelling terms we get:

x1^2 - 2*x1*h + y1^2 – 2*y1*k = x2^2 - 2*x2*h + y2^2 – 2*y2*k ........................ (4)

Rearranging (4) so that the unknowns are on the left:

(x2 – x1)*h + (y2-y1)*k = (x2^2 - x1^2 + y2^2 - y1^2) / 2 .................................. ( 5)

Similarly for r2^2 = r3^3 we get:

(x3 – x2)*h + (y3-y2)*k = (x3^2 - x2^2 + y3^2 - y2^2) / 2 .................................. ( 6)

Let

  • x1 = 1st touchpad X coordinate
  • y1 = 1st touchpad Y coordinate
  • x2 = 2nd touchpad X coordinate
  • y2 = 2nd touchpad Y coordinate
  • x3 = 3rd touchpad X coordinate
  • y3 = 3rd touchpad Y coordinate
  • A = x2 – x1
  • B = x3 – x2
  • C =y2 – y1
  • D = y3 -y2
  • E = (x2^2 - x1^2 + y2^2 - y1^2) / 2
  • F = (x3^2 - x2^2 + y3^2 - y2^2) / 2

Equations (5) and (6) become:

A*h =C*k = E ......................................................................................................... (7)

B*h +D*k = F ..........................................................................................................(8)

Multiply (7) by D and (8) by C:

A*D*h + C*D*k = D*E ............................................................................................ (9)

B*C*h + C*D*k = C*F ............................................................................................(10)

Subtract (10) from (9) and solve for h:

h = (D*E – C*F) / (A*D – B*C) .......................................................................... ... (11)

Substitute (11) into (8)

k = (F – B*h) / D .................................................................................................... (12)

Substituting h and k into (1)

r^2 = (x1 - h)^2 + (y1 – k)^2 ................................................................................ (13)

From which

r = sqrt( (x1 - h)^2 + (y1 – k)^2) .......................................................................... (14)

We have now solved for all of the unknowns h, k, and r

But we are not quite done yet

Arc commands have the following format:

G02 X12 Y34 I56 J78 ............................................................................................ (15)

Where

  • G02 = plot a clockwise arc
  • X12 = next X cooridinate
  • Y34 = next Y coordinate
  • I56 = offset of current location from the circle center
  • J78 = offset of current location form the circle center

I and J are calculated using following formulas:

I = h - x1 ................................................................................................................ (16)

J = k - y1 ................................................................................................................(17)

Step 4: Operation

Before starting

Decide what g-code format you require

Setting the boolean GRBL flag in your header to “false” produces the code shown in photo 1

Setting the boolean GRBL flag in your header to “true” produces the code shown in photo 2. This code is suitable for use with the GRBL plotter described in:

Creating your “drawing.gcode” file

  • Touch the “*” menu button to start and follow the on-screen instructions
  • Touch any of the “mode” buttons to change modes while tracing an outline.

For example to draw a rectangle with rounded corners:

  • touch the “*” button
  • touch the “Line” button
  • touch the line start
  • touch the line end ... a continuous line will be drawn between the two points.
  • touch the “Arc1” button and follow the on-screen instructions
  • touch the “Line” button to draw the next line”
  • repeat this sequence for each corner
  • touch the “*” button to start a new outline

Touch the “Save” button once you have finished all outlines. This creates a file called “drawing.gcode” in your Processing “touchpad_receiver_v2” folder [1]

Plotting your “drawing.gcode” file

  • plug your plotter into a spare USB port
  • position the pen over the lower-left corner of the paper
  • launch “UGS” (Universal G-code Sender)
  • set the baud speed to 115200 and “connect” to your plotter
  • click “browse”.
  • find your “drawing.gcode” file, then click “open”
  • click “Visualize” to see the plot paths
  • click “Send”

Note

[1]

Be aware that the “drawing.gcode” file is overwritten whenever you touch “Save”. Rename this file if you wish to keep your gcode.

Step 5: Summary

This Instructable describes how to make a CNC graphics Tablet from an Arduino and an 8 inch 4-wire resistive touchpad.

The gcode output from the tablet is intended for use with plotters ... not CNC mills.

The software supports GRBL plotters.

The touchpad has a resolution of 600 x800 pixels which translates to a 600mm x 800mm drawing if your target resolution is 1mm/pixel.

The project comprises an Arduino sender and a Processing receiver.

The Arduino is responsible for sending each touchpad coordinate to a PC which is running Processing3.

Processing3 displays what you have traced and generates a valid g-code file called "drawing.gcode" that is compatible with most CNC plotters.

The g-code file “drawing.gcode”must be renamed if you wish to preserve your work as it is overwritten each time you click "Save".

The estimated cost of construction is less than $25.

  Click here   to view my other instructables.

Be the First to Share

    Recommendations

    • Robots Contest

      Robots Contest
    • Plastic Challenge

      Plastic Challenge
    • Sewing Challenge

      Sewing Challenge

    4 Comments

    0
    perfo
    perfo

    7 weeks ago

    Some good improvements. It seems to work well.. thanks for the instructable..

    0
    lingib
    lingib

    Reply 7 weeks ago

    And thank you for commenting :)

    0
    lingib
    lingib

    Reply 7 weeks ago

    Thanks :)