quickstart:mycnc-quick-start:cnc-vision-setup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
quickstart:mycnc-quick-start:cnc-vision-setup [2019/07/02 13:00] – ivan | quickstart:mycnc-quick-start:cnc-vision-setup [2024/02/26 14:50] (current) – ivan | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | =====CNC Vision Setup===== | + | =====CNC Vision |
- | This manual is designed to introduce the reader to the setup process of the CNC vision | + | This manual is designed to introduce the reader to the setup process of the CNC Vision |
- | In order to set up the camera | + | The CNC Vision System is often used in the X1366V Tangential Cutting profile. The description of the X1366V GUI is available here: [[mycnc: |
+ | |||
+ | //Please note that the Vision System license for correcting the generated G-code using registration mark reading is a separate license that must be purchased in addition to the myCNC controller in order for the DACS (Digitally Aligned Cutting System) | ||
+ | |||
+ | //NOTE: The CNC Vision functionality is currently supported on **Linux systems ONLY**.// | ||
+ | |||
+ | A video with the recap of the manual below is available here: | ||
+ | |||
+ | {{youtube> | ||
+ | |||
+ | In order to set up the camera, you must go into the **CNC Settings | ||
{{: | {{: | ||
- | * **Camera Interface** allows to choose | + | * **Camera Interface** allows to choose |
- | **IP Camera Initialization line** lists the camera IP for the connection to be established. | + | |
+ | * **IP Camera Initialization line** lists the camera IP for the connection to be established. | ||
- | **Pattern size** can be set experimentally to be slightly | + | * **Pattern size** can be set experimentally to be about 30-50% |
+ | * In the case of the particular | ||
+ | * NOTE: The camera focus must be properly adjusted in order for the camera to recognize markers. | ||
{{: | {{: | ||
- | **Region of interest** (in pixels) signifies the area in which the camera is actively looking for markers, and should usually be set to be equal or slightly smaller than the actual resolution of the camera. It is set automatically in the newer software versions during the calibration process. | + | * **Region of interest** (in pixels) signifies the area in which the camera is actively looking for registration marks, and should usually be set to be equal or slightly smaller than the actual resolution of the camera. It is set automatically in the newer software versions during the calibration process |
- | **Pixel to length coefficient** is used to convert the pixels travelled into the actual physical distance moved, in mm. You are able to calibrate this for both the x- and the y-axes. In order to set up the correct coefficient for your camera, use the Calibrate button in the Camera tab, or consult the full set of manual set up instructions below. | + | * **Pixel to length coefficient** is used to convert the pixels travelled into the actual physical distance moved, in mm. You are able to calibrate this for both the x- and the y-axes. In order to set up the correct coefficient for your camera, use the Calibrate button in the Camera tab, or consult the full set of manual set up instructions below (useful for older software versions). |
- | **Camera Shift** describes the distance the machine will move by if it does not locate a marker after it has been instructed to look for one. This can happen when the marker is not fully within the region of interest, | + | * **Camera Shift** describes the distance the machine will move by if it does not locate a registration |
- | **Tool number** is usually | + | * **Tool number** is typically |
- | **Camera offset** values are used to specify the distance from the camera to the working tool in the xy-plane. | + | * **Camera offset** values are used to specify the distance from the camera to the working tool in the xy-plane. |
- | **Camera tool length** value is used to specify the distance from the camera to the working tool tip in the z-axis. | + | * **Camera tool length** value is used to specify the distance from the camera to the working tool tip in the z-axis. |
- | **Ignore decoder errors** flag is set to OFF by default. | + | * **Ignore decoder errors** flag is set to OFF by default. |
- | **Shift Speed** describes the speed with which the machine is moving during its camera shift phase while trying to find the marker. NOTE: Deprecated on the newer versions of myCNC software. | + | * **Shift Speed** describes the speed with which the machine is moving during its camera shift phase while trying to find the registration |
- | **Pattern Match Level** describes the level of parity with the original reference marker that each new marker must have for the system to recognize it. Higher numbers mean less parity (more differences between the markers), so as to avoid false positives it is advised to keep the numbers on the lower end of the scale. The graph below the Pattern Match Level indicates the parity levels during the machine search for markers, with the low points of the graph being indicative of the places where marker parity is highest (differences between new marker and reference are lowest). | + | * **Pattern Match Level** describes the level of parity with the original reference |
+ | * If the program has issues locating markers due to those markers being slightly different (due to material imperfections, | ||
+ | {{: | ||
- | **Image sensor correction** corrects for sensors with different aspect ratios. Use this if the marker | + | * **Image sensor correction** corrects for sensors with different aspect ratios. Use this if the registration mark image appears distorted or stretched when viewed through the Camera tab in myCNC software. |
+ | |||
+ | ====CNC Vision codes==== | ||
+ | |||
+ | The Vision system is controlled through a series of M-code PLCs which can be found in Settings > Config > PLC > Hardware PLC. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | The following PLC procedures are used: | ||
+ | |||
+ | * M395 - camera calibration. ++ Show M395 code | | ||
+ | < | ||
+ | #define camera_count | ||
+ | #define wait_camera | ||
+ | |||
+ | |||
+ | main() | ||
+ | { | ||
+ | camera_count=100; | ||
+ | wait_camera=100; | ||
+ | callback_address=3; | ||
+ | |||
+ | //delay after motion stopped | ||
+ | timer=300; do{timer--; | ||
+ | |||
+ | message=PLCCMD_WAIT_FOR_CAMERA; | ||
+ | timer=2; | ||
+ | |||
+ | do | ||
+ | { | ||
+ | |||
+ | if (wait_camera> | ||
+ | { | ||
+ | | ||
+ | do { code=gvarget(6060); | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | }; | ||
+ | |||
+ | }while (wait_camera> | ||
+ | |||
+ | exit(99); //normal exit | ||
+ | }; | ||
+ | </ | ||
+ | ++ | ||
+ | * M397 - start camera operations. ++ Show M397 code | | ||
+ | < | ||
+ | #include common.const.h | ||
+ | |||
+ | main() | ||
+ | { | ||
+ | message=PLCCMD_CAMERA_START; | ||
+ | texit=timer+10; | ||
+ | |||
+ | exit(99); | ||
+ | }; | ||
+ | </ | ||
+ | ++ | ||
+ | * M399 - record the image, detect the marker position and store it in a dots array. ++ Show M399 code | | ||
+ | < | ||
+ | #define callback_address | ||
+ | #define camera_count | ||
+ | #define wait_camera | ||
+ | |||
+ | main() | ||
+ | { | ||
+ | camera_count=0; | ||
+ | wait_camera=1; | ||
+ | callback_address=3; | ||
+ | |||
+ | //delay after motion stopped | ||
+ | timer=300; do{timer--; | ||
+ | |||
+ | message=PLCCMD_WAIT_FOR_CAMERA; | ||
+ | timer=2; | ||
+ | |||
+ | do | ||
+ | { | ||
+ | if (wait_camera> | ||
+ | { | ||
+ | |||
+ | | ||
+ | do { code=gvarget(6060); | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | }; | ||
+ | |||
+ | }while (wait_camera> | ||
+ | |||
+ | exit(99); //normal exit | ||
+ | }; | ||
+ | </ | ||
+ | ++ | ||
+ | * M398 - calculate rotation, offset and distortion values and make a correction accordingly for the rest of the G-code file, then run the corrected G-code. ++ Show M398 code | | ||
+ | < | ||
+ | #include src/ | ||
+ | main() | ||
+ | { | ||
+ | message=PLCCMD_CAMERA_FINISH; | ||
+ | texit=timer+10; | ||
+ | |||
+ | message=PLCCMD_MOTION_BREAK; | ||
+ | texit=timer+10; | ||
+ | |||
+ | exit(99); | ||
+ | }; | ||
+ | </ | ||
+ | ++ | ||
+ | These PLCs are added automatically into the G-code when importing a DXF file into myCNC. In order for the system to recognize the markers, the markers need to be drawn as roughly 6mm circles inside a separate layer named '' | ||
+ | |||
+ | Additionally, | ||
+ | |||
+ | ====Calibrating the CNC Vision System==== | ||
- | ====Running the calibration==== | ||
*Go to the Camera tab of myCNC software by opening the Settings panel from the main screen | *Go to the Camera tab of myCNC software by opening the Settings panel from the main screen | ||
*Select an appropriate marker (pattern) size and click the Record button | *Select an appropriate marker (pattern) size and click the Record button | ||
Line 48: | Line 184: | ||
{{: | {{: | ||
- | ====Setting up the pixel to length coefficients | + | :!: **NOTE:** A possible result for the calibration is to have a zero (0) coefficient as a result of the procedure, instead of a realistic value. This can be the result of the camera being oriented incorrectly (for instance, setting the camera up with the X and Y movement axes switching place, or having it rotated 180 degrees, etc). If the coefficient is zero, first check that the camera is oriented correctly and re-run the calibration procedure. |
+ | ====Setting up the pixel to length coefficients ==== | ||
+ | |||
+ | //Obsolete method only used on program versions older than July 2019. In all recent versions the pixel to length coefficients is calculated automatically by the program during the calibration process.// | ||
+ | |||
+ | ++++ Click to expand the instructions | | ||
+ | |||
The pixel to length coefficient is necessary for the camera to know how many millimeters it had moved after having traversed a certain number of pixel to the left/ | The pixel to length coefficient is necessary for the camera to know how many millimeters it had moved after having traversed a certain number of pixel to the left/ | ||
Line 88: | Line 230: | ||
After both axes have been calibrated, the machine will now have a proper coefficient of the number of pixels it moved by versus actual distance travelled in millimeters. | After both axes have been calibrated, the machine will now have a proper coefficient of the number of pixels it moved by versus actual distance travelled in millimeters. | ||
+ | ++++ | ||
====Using the hotkeys to move the camera==== | ====Using the hotkeys to move the camera==== | ||
- | In order to move the camera straight from the Camera tab, a set of hotkeys have been designed specifically for that purpose. Note that the hotkeys are only present in the more recent versions of myCNC software. Please update if the camera hotkeys are not present in your profile version. | + | In order to move the camera straight from the Camera tab, a set of hotkeys have been designed specifically for that purpose. Note that the hotkeys are only present in the more recent versions of myCNC software. Please update |
|HOTKEY|ACTION| | |HOTKEY|ACTION| | ||
- | | Arrow Up | Move in positive y-direction | | + | | '' |
- | | Arrow Right | Move in positive x-direction | | + | | '' |
- | | Arrow Down | Move in negative y-direction | | + | | '' |
- | | Arrow Left | Move in negative x-direction | | + | | '' |
- | | Space | Switch the step jog (00.1 through 1 mm) | | + | | '' |
- | | Hold Control and Arrow keys| Move by the selected step jog | | + | | Hold '' |
=====CNC Vision Example===== | =====CNC Vision Example===== | ||
Line 127: | Line 270: | ||
+ | =====Camera troubleshooting===== | ||
+ | |||
+ | A camera troubleshooting guide is available here: [[troubleshooting: | ||
+ | |||
+ | =====Creating the DXF files===== | ||
+ | |||
+ | A suitable DXF file can be created in an application such as Inkscape. A few rules to follow: | ||
+ | |||
+ | 1. The markers should be located outside the part contour (rather than inside of it): | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Note the way in which the contour connecting the camera markers needs to be fully outside the contour of the file being corrected in order to work properly: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | 2. The markers and the part contour should be located in different layers (such as **Layer 1** for the working part and **Camera** for the markers), for example: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | 3. If using Inkscape, make sure to export using the LWPOLYLINE option (instead of the ROBO-Master type): | ||
+ | |||
+ | {{: |
quickstart/mycnc-quick-start/cnc-vision-setup.1562086849.txt.gz · Last modified: 2019/07/02 13:00 by ivan