Introduction: CNC Pen and Wash Portrait
This instructable explains how to create a "pen and wash" portrait using a fibre-tipped pen, a watercolor brush, and a CNC plotter with Z-axis control [1].
Downward pressure on a watercolor brush spreads the bristles causing the brush-stroke to widen. Images are possible (photo 2) if we attach a brush to the pen-lift and control its height. Software routines for achieving this are presented.
Detail is then added to this image by creating an outline as described in instructable https://www.instructables.com/id/CNC-Edge-Detectio...
The opening photo shows my first attempt [2] ... the completed brush image is shown in photo 2 ... and a partial outline is shown photo 3. The video clip shows the watercolor brush in action.
Don't expect masterpieces ... this technique, and the attached software, are purely experimental and are published in the hope that you may find them useful.
[1]
The plotter and pen-lift used for this project are described in instructables:
[2]
The brush work in this image is too light ... I should have made the initial shade darker as watercolor tends to dry lighter.
Step 1: Overview
It is assumed that "arduino" software is installed on your computer. If not then download the latest version (arduino 1.8.5) from https://www.arduino.cc/en/Main/Software
In addition the following software must be downloaded:
coreXY_plotter_2.ino
This coreXY plotter update adds:
- two brush adjustment commands to the "menu".
- and pen-lift control.
processing.exe
This software is the underlying "engine" for:
- a "draw_image_watercolor.pde" program that generates the brush gcode.
- a "sobel_outline.pde" program that generates the pen gcode.
- a "processing3_terminal.pde" program that sends the above gcode to the plotter.
image.jpg
This test image is used to create :
- the brush gcode
- the pen gcode
Instructions for installing each of the above software now follow.
Step 2: Software Installation
Install the software in this order:
Plotter update
- download "coreXY_plotter_2.ino" (file attached) [1]
- copy the contents to an arduino sketch
- save the sketch as "coreXY_plotter_2" (without the quotes)
- upload the sketch to your arduino plotter.
Processing
- download the "Processing" freeware from https://processing.org/download/
- unzip the file and place the folder somewhere you can find it ... say your desktop.
Gcode sender
- download "processing3_terminal.pde" from step 2 of instructable https://www.instructables.com/id/CNC-Gcode-Sender/ and place it in your processing folder.
- double-click "processing.exe".
- click "File|Open" and select "processing3_terminal.pde"
- you will asked if you wish to move the file into its own folder ... click "OK"
- close processing
Brush software
- download "draw_image_watercolor.pde" (file attached) and place it in your processing folder
- double-click "processing.exe".
- click "File|Open" and select "draw_image_watercolor.pde"
- you will asked if you wish to move the file into its own folder ... click "OK"
- close processing
Pen outline software
- download "sobel_outline.pde" from step 4 of instructable https://www.instructables.com/id/CNC-Edge-Detectio... and place it in your processing folder.
- double-click "processing.exe".
- click "File|Open" and select "sobel_outline.pde"
- you will asked if you wish to move the file into its own folder ... click "OK"
- close processing
Image.jpg
Download the attached test image (photo 1) and place a copy in the following processing sub-folders:
- "draw_image_watercolor"
- "sobel_outline"
Almost done ... we just need to create the gcode
[1]
22 December 2018
The file coreXY_plotter_2a fixes a compiler error in the latest version of the Arduino IDE ????
The code is identical except for the format of :
- bool DIRECTION1;
- bool DIRECTION2;
Step 3: Generating the Gcode
image.ngc
The gcode for controlling the brush is called "image.ngc".
To generate this file:
- double-click "processing.exe"'
- click "File|Open" and select "draw_image_watercolor.pde" from within the "draw_image_watercolor" subfolder. This program creates the file "image.ngc"
- Click the top-left arrow to start the program.
- Close processing when a pixelated image appears (photo 1)
- copy "image.ngc" to the "processing3_terminal" subfolder.
outline.ngc
The gcode for controlling the pen is called "outline.ngc".
To generate this file:
- double-click "processing.exe"'
- click "File|Open" and select "sobel_outline.pde" from within the "sobel_outline" subfolder. This program creates the file "outline.ngc"
- Click the top-left arrow to start the program.
- A monochrome outline will appear (photo 2).
- Close processing when the outline turns blue (photo 3).
- copy "outline.ngc" to the "processing3_terminal" subfolder.
If you get a recursion error message (photo 4) reduce the recursion depth in line 119 from 2000 to 1500.
We are now ready to go ...
Step 4: Adjust the Brush
Connect your plotter
- connect your computer to plotter with a USB cable
- apply power to the plotter
- run "processing.exe" and select "processing3_terminal.pde" from the processing3_terminal subfolder
- a menu (photo 1) should appear.
Adjust your brush
Two additional menu items, T8 & T9, have been added to the arduino menu:
T8 - Allows you to adjust your brush-height, brush-angle, and brush-width by lowering, then raising, the slider. If the brush is vertical the bristles will scrunch up. If the brush is horizontal then you will only get wide brush-strokes. An angle of 60 degrees is a good starting point.
T9 - Allows you to adjust, and test, the line-spacing [1]. It does this by painting five 100mm brush-strokes spaced 3mm apart. The width of each brush-stroke varies from 0%..100%.
Two successive "blocks" are shown in photo 2. The aim is for the brush strokes to show no paint at the left -hand edge of the "block" and to "just touch" at the right-hand end of the "block".
Notes
[1]
Different image dimensions will require changes to the "cellHeight" value in the brush software if we are to maintain a line-spacing of 3mm:
- "image.jpg" at 467pixel x 620pixels is too big for an A4 sheet of paper ... we need to scale the incoming gcode by 30%
- Assuming a one-to-one pixel versus millimeter line spacing then we need to set the "cellHeight" to 3 pixels to accommodate our 3mm brush..
- If we scale the incoming gcode by 30% then we need to increase the cellHeight" to about 9 pixels in the brush software to maintain our 3mm line-spacing.
Step 5: Paint the Image
We are now ready to paint the image:
- run "processing.exe" and select "processing3_terminal.pde" from the "processing3_terminal" subfolder.
- left-click the gray instruction box ... the updated arduino menu will appear
- type "T1" (without the quotes) and position your brush near the bottom-left corner of the paper.
- mark this point with a pencil ... we need to know where it is
- press "E" to exit
- type "T2 S0.3" to scale the incoming gcode to 30%
- now right-click the gray instruction box (nothing appears to happen but it does)
- type "image.ngc" ... the brush will move to the top of the page and gradually paint an image on its way back down
The above instruction sequence is shown in photo 1
Step 6: Draw the Outline
We are now ready to draw the outline:
- run "processing.exe" and select "processing3_terminal.pde" from the "processing3_terminal" subfolder.
- left-click the gray instruction box ... the updated arduino menu will appear
- replace the brush with a fibre-tipped pen [1]
- type "T1" (without the quotes) and position your pen over the pencil mark you made in the previous step. This ensures that the brush image and pen outline are superimposed.
- press "E" to exit
- type "T2 S0.3" to scale the incoming gcode to 30%
- right-click the gray instruction box (nothing appears to happen but it does)
- type "outline.ngc" ... the pen will move to the top of the page and gradually draw an outline on its way back down
The above instruction sequence is shown in photo 1
[1]
Two separate sliders, one for the brush and one for the pen, makes life a lot easier ;)
Click here to view my other instructables.