# How to set the fully dynamic plotting area?

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 hand using camera and set the hand as printing area in CNC firmware and the place gcode image on finger. How to tell the cnc firmware that this is your printing area?

I hope you understand my question.

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

• The question could benefit from some more context to be properly answered. It is unknown what type of application is being referred to. Usually the "printing" area is constrained in the firmware or the G-code generator (e.g. slicer). Please edit your question.
– 0scar
Feb 2 '21 at 11:27
• I am final year student and my final year project is cnc plotter with image processing. so the last task of my project is that detect object and print on that object for example detect hand and print on the finger of detected hand. so I just want to know how to this task. how do I tell my cnc plotter this is hand and print on finger. Feb 2 '21 at 11:34
• Unless your CNC is aware of it's position (using endstops) it cannot, it is up to you. You should position the router at the starting point of the G-code and make sure it doesn't go outside the limits. So an answer could be to add endstops and provide limits in the firmware, if possible. But, we don't know the firmware. Furthermore you need to have some sort of sensor to detect an object and scan the contours.
– 0scar
Feb 2 '21 at 11:39
• Okay Sir. but I am thinking about that somehow if we tell the cnc firmware like pronterface that this is your printing area. detect hand using camera and set the hand as printing area in pronterface and the place gcode image on finger. is it possible? thanks Feb 2 '21 at 11:51
• Pronterface is not firmware, it is print software, without knowing where the router is (for knowing where it is you need endstops or get a defined position from a sensor) you can assign all you want in your print software, actual machine limits are not checked.
– 0scar
Feb 2 '21 at 11:57

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.
• 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 Feb 3 '21 at 17:58
• 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. Feb 4 '21 at 2:40
• 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. Feb 14 '21 at 19:34
• 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. Feb 15 '21 at 20:55
• 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. Feb 19 '21 at 10:30