User Tools

Site Tools


plc:plc_height_map

Getting a Height Map

Related articles:


myCNC control software has API to record Height Map log file for further height adjustment.

Height Map Settings

There is a Height Map settings widget.

The following parameters can be set up in the widget

  • Log file name,
  • Axes list to record in the log
  • Log line format - C-style format definition to print selected axes, for example, print positions as G-code linear interpolation line
    G90 G1 X%8.2f Y%8.2f Z%8.3f
  • Header line in the log file

Height Map Log API

There are 2 Global variable registers mapped to the Log API

Register Name Register Address Description
GVAR_POSITION_LOG_DATA 5730 If Logging is stopped, writing to this register does not have an effect.
If the Logging is started, writing any value to this register
will add current position
to the Log data array.
Beside of storing into the Log Array,
The Log position is stored into Global Variables 5731-5736 as well
#5731 - X, #5732 - Y, #5733 - Z
#5734 - A, #5735 - B, #5736 - C
GVAR_POSITION_LOG_CMD 5740 Begin/Eng Height Map Log
Writing “1” to this register will start logging
Writing “0” to this register will stop logging
All the collected data will be stored in a log file
with given filename and time stamp

Other options for the global variable 5740:

  • 0 = saveZMapX,
  • 100 = loadZMap,
  • ival==1, ival==101 = clearZMap
  • (ival==102) = saveZMap
  • (ival==200) = doPlateRotation()
  • (ival==201) = doPlateRotation3(0)
  • (ival==202) = doPlateRotation3(1)
  • (ival==333) = doPlateRotation3_Test
  • (ival==999) = clearHCCalibration
  • (ival==998) = saveHCCalibration

Log Handler through PLC M-functions

As an example add M80 procedure to start-stop Height Map Log file

M80.plc
main()
{
  gvarset(5740,eparam);
  exit(99);
};

The procedure will send to Register #5740 variable value “eparam” which is initialized as P-parameter from g-code line.

  • Code line to start Height Map logging would be
    M80 P1
  • Code line to stop Height Map logging and save collected data to a file -
    M80 P0

Another example - code to add the current position to the log file - code M85

M85.plc
main()
{
  gvarset(5730,0);
  exit(99);
};

This is just an example of storing position to the log.

To get a real example of Height sensing and Logging we have to

  • add probing motion down till probe sensor activated,
  • then storing current position (gvarset(5730,0)),
  • then lift up to initial height

Macro example to probe surface (double touch with fast and slow speed) and store a result in log array is shown below

M180
#10=3 (Sensor Nr)
#11=1 (Sensor Normally opened)
 
M88 P#10 L#11 (Smooth stop if sensor activated)
G91 G0 Z-30 F500 (Fast probe screen surface)
G04 P0.1
G91 G0 Z2 F500(Rebound 2mm)
M89 P#10 L#11 (Stop if sensor activated)
G91 G0 Z-30 F50 (Slow probe screen surface)
G04 P0.1 (Pause)
M85 (Save the coordinates in the log)
G90

G-code program example for getting height map log is below

A time stamp will be added to the log filename. For example, if a file name is given as “/home/sk/height.map”, then actual height map files will be stored under names

height-map-2018-09-09-17-14-36
height-map-2018-09-09-19-29-43
heights.map-2019-02-18-16-10-19
heights.map-2019-02-18-16-48-16
; height-map.nc
G90 G17 G21
G0X0Y0
M80P1 (Logging ON)
G1 X50 Y50 Z20 (Position 1)
M180 (Probe and add the result to the log)
G0 Z20 (Lift up)
G1 X60 Y50 Z20 (Position 2)
M180 (Probe and add the result to the log)
G0 Z20 (Lift up)
G1 X70 Y50 Z20 (Position 3)
M180 (Probe and add the result to the log)
G0 Z20 (Lift up)
G1 X80 Y50 Z20 (Position 4)
M180 (Probe and add the result to the log)
G0 Z20 (Lift up)
G1 X80 Y60 Z20 (Position 5)
M180 (Probe and add the result to the log)
G0 Z20 (Lift up)
G1 X70 Y60 Z20 (Position 6)
M180 (Probe and add the result to the log)
G0 Z20 (Lift up)
G0 X60 Y60 Z20 (Position 7)
M180 (Probe and add the result to the log)
G0 Z20 (Lift up)
G1 X50 Y60 Z20 (Position 8)
M180 (Probe and add the result to the log)
G0 Z20 (Lift up)
M80 P0 (Save the Log and turn logging Off)
M2

A log file example is below

G90 G1 X   50.00 Y   50.00 Z  -9.634
G90 G1 X   60.00 Y   50.00 Z  -8.125
G90 G1 X   70.00 Y   50.00 Z  -8.270
G90 G1 X   80.00 Y   50.00 Z  -9.156
G90 G1 X   80.00 Y   60.00 Z  -9.706
G90 G1 X   70.00 Y   60.00 Z  -9.741
G90 G1 X   60.00 Y   60.00 Z  -9.360
G90 G1 X   50.00 Y   60.00 Z  -9.066
plc/plc_height_map.txt · Last modified: 2023/12/07 09:55 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki