I am trying to combine CNC plotter with image processing. The goal is to detect the object and print on that object. My question is can we set the fully dynamic plotting area.

For example: I want to print something on hand or finger. How do I tell the machine that this is hand and you have to print only on this hand.

I plan to detect the hand using a camera and set the hand as printing area in CNC firmware and the place G-code image on th finger. How to tell the CNC firmware that this is your printing area?

I am using GRBL firmware with Arduino and use Pronterface as software.

  • $\begingroup$ Hi Tyson! I have supplemented your queastion with information from comments. Could you review my answer if it is helping you, please? Also, we are not sure about your current G-code skills - and be aware that 3d printers focus on bit different set of commands than CNC machines (arcs, where are you?). Check the answer. Btw. I love your project, please leave a reference to your blog in comment :) $\endgroup$
    – octopus8
    Feb 3, 2021 at 4:06

1 Answer 1


If the problem of "dynamic area", or even "how to avoid missing the surface and boundaries" could be translated to "where to start well-defined job" - then it sounds to me like common task, with regards to philosophy of CNC machines. (Ok, until the surface is not moving around.)

Pronterface and GRBL work in Cartesain system. GRBL does not support mesh probing. So you must think about relatively flat, plane surfaces.

In my opinion, you need to fulfill following tasks to achieve the goal:

  • Define boundaries. Hard and soft boundaries of device are supported by GRBL. You should setup them for overall safety.
  • Plan the job. Recognize ranges of planned plot or print.
  • Secure the surface. It must be appropriately stabilized. If you want to draw, the pen mount with spring will equalize variations of the surface (hand, finger, egg). 3D printing is sensitive to roughness and obliquity, we add raft/supports to overcome these - could be of use, until it doesn't mean missing your goal? (Don't print with hot filaments on fingers.)
  • Establish point of reference. You need to home your plotting or printing head somewhere in space in relation to the driving hardware. This is needed for any further actions. I envsion homing Z to the top of the frame, rather then against the target.
  • Detect surface. Camera will help with horizontal borders (X,Y). You also need to measure the Z distance. The Z probe could be mechanical (then needs vertical movement) or some distance detector (like VL53L0X ?).
  • Validate fitting. Ensure that the surface will accommodate ranges of planned job. This is actually the key point in my opinion. You need to know scope at the first place.
  • Program. I see following options to pick and mix the final solution from them:
    • G-code is generated prior to the whole procedure. You need to synchronize the starting point between the generated file and the real job range. Homing is done "manually" prior to executing the file. After surface is detected, the real starting point could be calculated and applied.
    • G-code is generated after surface is detected. Job starts with homing, and first moves go from device's zero (home position) to selected starting point on the surface. All consecutive moves are planned within boundaries over the surface. So there is no risk to work outside the safe range.
    • G-code is generated with relative positioning (incremental distance mode), having G91 in preamble. Then you just travel to the starting point and then run the commands from file.
    • G-code is generated with absolute positioning (absolute distance mode). To run the job, you need to change coordinate system using commands like G10, G54-G59.
    • For printing, if there is a needed to match some flat shape to rought surface, then you may need to dynamically generate some supports/raft below the bottom of the printed part.
  • $\begingroup$ Hey octopus8. thanks for the answer. I was thinking about that what if I place 2 g-code images on pronterface plotting area. the first image is hand which is the boundary and the other image is design to print.link this is image hope you understand $\endgroup$
    – Tyson
    Feb 3, 2021 at 17:58
  • $\begingroup$ Be aware that G-code is not an image, but a set of instructions for printer. So it is "active" part. I am not sure of your plan, but if Pronterface will send both "star" and "cross" to printer, they will be both printed. For 100% you will not avoid develop new source code to make this project. So I would propose to modify this gray square grid in the background, instead increasing complexity by adding new "active" elements. Look for "def repaint_everything(self)" in "./printrun/gviz.py" - I am pretty sure this is the right place to start. $\endgroup$
    – octopus8
    Feb 4, 2021 at 2:40
  • $\begingroup$ Hey octopus8. I hope you are fine. I just want to know that can we set the bed size in points. For Example I detect the object and place the object on graph and find all coordinate and set the coordinate as bed. I hope you understand. $\endgroup$
    – Tyson
    Feb 14, 2021 at 19:34
  • $\begingroup$ I am afraid I am not... What kind of "points" do you mean? Probably not "typography" points? So ...pixels on the screen? - then please read How to convert millimeters to pixel? and Calculating dots per..., because bed size is measured in real units, while pixels are relative to the display resolution and scaling. $\endgroup$
    – octopus8
    Feb 15, 2021 at 20:55
  • $\begingroup$ points means x and y axis points. for example I detect object and plot the object on graph and get the points. now set my bed as graph points. $\endgroup$
    – Tyson
    Feb 19, 2021 at 10:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .