TinyG and ContactProbeNozzle

281 views
Skip to first unread message

tony...@att.net

unread,
Dec 14, 2020, 4:21:49 PM12/14/20
to OpenPnP
I've been investigating the use of the ContactProbeNozzle with TinyG.  I believe I have found a bug in the TinyG code that makes nozzle probing unusable (for the most part).  It appears that if the rotary axis is at any angle other than zero, the probe command fails.

With the rotary axis at zero, the gcode fragment G38.2 Z-42 F800 probes correctly.  However, if the rotary axis is not at zero, the same gcode fragment is rejected by TinyG with the following error "Probing error - A axis cannot move during probing."  TinyG is mistakenly thinking we want to move the rotary axis even though no command was sent to do so.  I believe the bug is in this section of TinyG code in cycle_probing.c:

// error if the probe target requires a move along the A/B/C axes
for ( uint8_t axis=AXIS_A; axis<AXES; axis++ ) {
    if (fp_NE(pb.start_position[axis], pb.target[axis]))
        _probing_error_exit(axis);
}

I think this code needs to check to see if the rotary axis was actually specified in the command before checking to see if the start and target are not equal like this:

// error if the probe target requires a move along the A/B/C axes
for ( uint8_t axis=AXIS_A; axis<AXES; axis++ ) {
    if (fp_NOT_ZERO(pb.flags[axis]) && fp_NE(pb.start_position[axis], pb.target[axis]))
        _probing_error_exit(axis);
}


I currently don't have an environment setup for me to compile TinyG so I can't verify this for certain.  ma...@makr.zone could you compile this change?  While at it, I think this section also has the logic inverted:

// trap no axes specified
if (fp_NOT_ZERO(flags[AXIS_X]) && fp_NOT_ZERO(flags[AXIS_Y]) && fp_NOT_ZERO(flags[AXIS_Z]))
    return (STAT_GCODE_AXIS_IS_MISSING);

Should be:

// trap no axes specified
if (fp_ZERO(flags[AXIS_X]) && fp_ZERO(flags[AXIS_Y]) && fp_ZERO(flags[AXIS_Z]))
    return (STAT_GCODE_AXIS_IS_MISSING);

A potential OpenPnP workaround for the first bug is to specify the rotation as part of the probe command.  For example, if the rotary axis is at 10 degrees, the gcode fragment G38.2 Z-42 A10 F800 does probe correctly.  However, to use this would require a modification to OpenPnP to allow access to the axis variables in the ACTUATE_BOOLEAN_COMMAND.

ma...@makr.zone

unread,
Dec 15, 2020, 8:01:05 AM12/15/20
to ope...@googlegroups.com

Second try with link.

https://makr.zone/TinyG_Flash.7z

_Mark

Am 15.12.2020 um 12:06 schrieb ma...@makr.zone:

Many thanks Tony.

I have created a new firmware, see attached. Please test this and if OK I will add it for download here.

See also the Pull request:
https://github.com/synthetos/TinyG/pull/260

_Mark

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/41423fd3-2b74-495b-a6bc-a4ecbd358143n%40googlegroups.com.

tony...@att.net

unread,
Dec 15, 2020, 2:50:39 PM12/15/20
to OpenPnP
Mark,

This appears to work - can now probe with the nozzle at any arbitrary rotation.

BTW - here is my final gcode for the probe actuator:

{True:G38.2 Z-42 F800 ;probe down in absolute coordinates until zmin switch is hit}
{True:M400 ;wait for motion to stop}
{True:M114 ;report position}
{False:G91 ;change to incremental mode}
{False:G1 Z3.9 F400 ;backoff until nozzle tip is just touching}
{False:G90 ;change back to absolute mode}
{False:M400 ;wait for motion to stop}
{False:M114 ;report position}

Thanks,
Tony

ma...@makr.zone

unread,
Dec 16, 2020, 5:02:55 AM12/16/20
to ope...@googlegroups.com

Tony,

Thanks a lot!

The suggestion is added.

Just one question: you assigned -42mm to the probe command and commented "probe down in absolute coordinates".

Are you sure?

In Smoothie it is relative and I chose a small distance (-4mm) so the machine will HALT, when the target is not hit soon enough.

Note, the ContactProbeNozzle is already brought down to the nominal Z height, assuming you have captured the feeder/PCB Z slightly above contact. Probing will then only start from there.

_Mark

ma...@makr.zone

unread,
Dec 16, 2020, 8:59:30 AM12/16/20
to ope...@googlegroups.com

Tony,

just disregard the question. I was mistaken (on Smoothie too).

_Mark

ma...@makr.zone

unread,
Dec 16, 2020, 9:22:51 AM12/16/20
to ope...@googlegroups.com

OK, I was mistaken about the G38.2 command documented here (linked from Smoothieware Gcodes):

http://linuxcnc.org/docs/2.6/html/gcode/gcode.html#sec:G38-probe

The probing target is given in absolute coordinates, it seems.

But I was not mistaken regarding Smoothie, it does use a delta_move():

https://github.com/Smoothieware/Smoothieware/blob/c781f5dfc6e0e44f995c713cad48c0df729dfc55/src/modules/tools/zprobe/ZProbe.cpp#L460-L462

which clearly does as the name implies:

https://github.com/Smoothieware/Smoothieware/blob/4079123249c4b7258ffbfd3e3eb3b4be3f156608/src/modules/robot/Robot.cpp#L1435-L1442

For reference, Duet also uses absolute coordinates (and recently changed from machine coordinates to user coordinates):

https://duet3d.dozuki.com/Wiki/Gcode#Section_G38_2_to_G38_5_Straight_Probe

Marlin too:

https://marlinfw.org/docs/gcode/G038.html

Support table:

https://reprap.org/wiki/G-code#G38.x_Straight_Probe_.28CNC_specific.29

So it seems Smoothie is the outlier. That's unfortunate. A target Z variable should now be provided by the GcodeDriver. Hmmm...

_Mark

Tim Wong

unread,
Jan 3, 2021, 2:00:49 PM1/3/21
to OpenPnP
I'm new to OpenPnP and trying to get my Liteplacer to work with OpenPnP.
Been following the discussion and Mark's Gcode update on the TinyG. 
It's amazing to see the works you guys have done. 

I got homing working but cannot get contact probe working. 

While using Tony's code above, 
I'm seeing weird problem when I tried to pick a part using the pick a part button on the feeder. 
My machine will perform a probe when the camera is still on top of the part. 
Then when the probe is finished, 
it will move the nozzle to the part and pick it up. 
Do you know how I can make the machine move the nozzle first before probing and picking up a part? 

ma...@makr.zone

unread,
Jan 3, 2021, 3:54:02 PM1/3/21
to ope...@googlegroups.com

Hi Tim

Make sure you have the newest OpenPnP 2.0 version.

Then what you describe, could be the actuator's coordination options:

https://github.com/openpnp/openpnp/wiki/Motion-Planner#actuator-machine-coordination

You should have both Before Actuation and After Actuation enabled on the Probe Actuator.

_Mark

Tim Wong

unread,
Jan 4, 2021, 6:42:46 AM1/4/21
to OpenPnP
Hi Mark thanks for your reply. 
You are spot on, it's to do with the machine coordination setting. 
I misunderstood that ONLY "After Actuation" should be enabled.  
I'm feeling silly pulling my hair over this simple mistake. 

By the way I have also encountered the bug Tony has discovered with the A axis. 
I think somehow downloaded the outdated firmware flash from your website. 
It's fixed by the updated firmware above.
 
Everything seems to be working now!

Peter Chaisty

unread,
Feb 4, 2021, 4:31:02 AM2/4/21
to OpenPnP
Hi Thanks for sharing the code.
I have a strange issue where G38.2 does nothing .

From console 

tinyg [mm] ok>
> G38.2 Z-20 F200
tinyg [mm] ok>

The system is homed and I can move the Z with Jog / G0 commands etc

I assume something is missing from a setting to TinyG that makes it ignore the command ?

Any ideas ?

Peter

Peter Chaisty

unread,
Feb 4, 2021, 4:44:55 AM2/4/21
to OpenPnP
I assume its related to one of these settings or similar

I have 

$zsx=3
$zsn=0

[zsn] z switch min 0 [0=off,1=homing,2=limit,3=limit+homing]
[zsx] z switch max 1 [0=off,1=homing,2=limit,3=limit+homing]

Peter

tony...@att.net

unread,
Feb 4, 2021, 5:02:18 PM2/4/21
to OpenPnP
Hi Peter,

I don't think the switch settings would keep it from moving although I have $zsx = 3.  Your Z axis didn't happen to already be setting at -20 before you issued the command?  The G38.2 command probes in absolute machine coordinates (not incremental) so G38.2 Z-20 F200 should attempt to probe to Z=-20 and not 20 units below the current position.   G38.2 also ignores any machine offsets that may be in effect so that is why I recommend against using G92.

Tony

Peter Chaisty

unread,
Feb 5, 2021, 8:27:27 AM2/5/21
to ope...@googlegroups.com
Hi Tony


Testing in console
Ok so before move I have ..
> M114
X:68.0827 Y:22.3651 Z:0.0000 A:89.6431 B:0.0000 C:0.0000
tinyg [mm] ok>
> G38.2 Z-20 F200
tinyg [mm] ok>
> M114
X:68.0827 Y:22.3651 Z:0.0000 A:89.6431 B:0.0000 C:0.0000
tinyg [mm] ok>

So no movement
Off to investigate that issue now 

This is my home code by the way

M5
M9
G90
G28.2 X0 Z0
G28.2 Y0
G28.3 X0 Y0 Z0  
; G92 commented out replaced by G28.3 G92 X0 Y0 Z0
M114

Peter








Virus-free. www.avast.com

You received this message because you are subscribed to a topic in the Google Groups "OpenPnP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpnp/K2iajulHVys/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openpnp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/3279c9e7-310e-46c9-919e-f1b43c46f6d1n%40googlegroups.com.

Virus-free. www.avast.com

tony...@att.net

unread,
Feb 5, 2021, 10:43:48 AM2/5/21
to OpenPnP
Are you using Mark's latest TinyG firmware?  It fixes a problem with TinyG that prevented it from probing when the rotation (A) axis was at anything other than zero:
>>  X:68.0827 Y:22.3651 Z:0.0000 A:89.6431 B:0.0000 C:0.0000  

You can find it here: TinyG Firmware

Peter Chaisty

unread,
Feb 5, 2021, 11:34:25 AM2/5/21
to ope...@googlegroups.com
Yes

I'm giving up on probing for now .
I just can't get it to do anything .

Peter

Virus-free. www.avast.com

tony...@att.net

unread,
Feb 5, 2021, 12:11:23 PM2/5/21
to OpenPnP
Peter,

I don't find probing as it is currently implemented in OpenPnP to be all the useful anyway (right now it probes at every pick and place which is different than how the LitePlacer SW does it - I think Mark is working on a change for that).  Anyway, , for what it's worth, here are all my TinyG settings:

[fb]  firmware build            440.21
[fv]  firmware version            0.97
[hp]  hardware platform           1.00
[hv]  hardware version            8.00
[id]  TinyG ID                    7X2109-JGS
[ja]  junction acceleration  500000 mm
[ct]  chordal tolerance           0.0100 mm
[sl]  soft limit enable           0
[st]  switch type                 0 [0=NO,1=NC]
[mt]  motor idle timeout        300.00 Sec
[ej]  enable json mode            0 [0=text,1=JSON]
[jv]  json verbosity              3 [0=silent,1=footer,2=messages,3=configs,4=linenum,5=verbose]
[js]  json serialize style        0 [0=relaxed,1=strict]
[tv]  text verbosity              1 [0=silent,1=verbose]
[qv]  queue report verbosity      2 [0=off,1=single,2=triple]
[sv]  status report verbosity     0 [0=off,1=filtered,2=verbose]
[si]  status interval    4000000000 ms
[ec]  expand LF to CRLF on TX     0 [0=off,1=on]
[ee]  enable echo                 0 [0=off,1=on]
[ex]  enable flow control         2 [0=off,1=XON/XOFF, 2=RTS/CTS]
[baud] USB baud rate              5 [1=9600,2=19200,3=38400,4=57600,5=115200,6=230400]
[net] network mode                0 [0=master]
[gpl] default gcode plane         0 [0=G17,1=G18,2=G19]
[gun] default gcode units mode    1 [0=G20,1=G21]
[gco] default gcode coord system  1 [1-6 (G54-G59)]
[gpa] default gcode path control  0 [0=G61,1=G61.1,2=G64]
[gdi] default gcode distance mode 0 [0=G90,1=G91]
[1ma] m1 map to axis              0 [0=X,1=Y,2=Z...]
[1sa] m1 step angle               0.900 deg
[1tr] m1 travel per revolution   39.9286 mm
[1mi] m1 microsteps               8 [1,2,4,8]
[1po] m1 polarity                 0 [0=normal,1=reverse]
[1pm] m1 power management         1 [0=disabled,1=always on,2=in cycle,3=when moving]
[2ma] m2 map to axis              1 [0=X,1=Y,2=Z...]
[2sa] m2 step angle               0.900 deg
[2tr] m2 travel per revolution   39.9514 mm
[2mi] m2 microsteps               8 [1,2,4,8]
[2po] m2 polarity                 0 [0=normal,1=reverse]
[2pm] m2 power management         1 [0=disabled,1=always on,2=in cycle,3=when moving]
[3ma] m3 map to axis              2 [0=X,1=Y,2=Z...]
[3sa] m3 step angle               1.800 deg
[3tr] m3 travel per revolution    8.0000 mm
[3mi] m3 microsteps               8 [1,2,4,8]
[3po] m3 polarity                 1 [0=normal,1=reverse]
[3pm] m3 power management         1 [0=disabled,1=always on,2=in cycle,3=when moving]
[4ma] m4 map to axis              3 [0=X,1=Y,2=Z...]
[4sa] m4 step angle               0.900 deg
[4tr] m4 travel per revolution  160.0000 mm
[4mi] m4 microsteps               8 [1,2,4,8]
[4po] m4 polarity                 0 [0=normal,1=reverse]
[4pm] m4 power management         1 [0=disabled,1=always on,2=in cycle,3=when moving]
[xam] x axis mode                 1 [standard]
[xvm] x velocity maximum      10000 mm/min
[xfr] x feedrate maximum      10000 mm/min
[xtn] x travel minimum            0.000 mm
[xtm] x travel maximum          600.000 mm
[xjm] x jerk maximum            146 mm/min^3 * 1 million
[xjh] x jerk homing            2000 mm/min^3 * 1 million
[xjd] x junction deviation        0.0100 mm (larger is faster)
[xsn] x switch min                3 [0=off,1=homing,2=limit,3=limit+homing]
[xsx] x switch max                2 [0=off,1=homing,2=limit,3=limit+homing]
[xsv] x search velocity        2000 mm/min
[xlv] x latch velocity         1000 mm/min
[xlb] x latch backoff            16.000 mm
[xzb] x zero backoff              2.000 mm
[yam] y axis mode                 1 [standard]
[yvm] y velocity maximum      10000 mm/min
[yfr] y feedrate maximum      10000 mm/min
[ytn] y travel minimum            0.000 mm
[ytm] y travel maximum          400.000 mm
[yjm] y jerk maximum             41 mm/min^3 * 1 million
[yjh] y jerk homing            2000 mm/min^3 * 1 million
[yjd] y junction deviation        0.0100 mm (larger is faster)
[ysn] y switch min                3 [0=off,1=homing,2=limit,3=limit+homing]
[ysx] y switch max                2 [0=off,1=homing,2=limit,3=limit+homing]
[ysv] y search velocity        2000 mm/min
[ylv] y latch velocity         1000 mm/min
[ylb] y latch backoff            13.000 mm
[yzb] y zero backoff              2.000 mm
[zam] z axis mode                 1 [standard]
[zvm] z velocity maximum       5000 mm/min
[zfr] z feedrate maximum       2000 mm/min
[ztn] z travel minimum            0.000 mm
[ztm] z travel maximum           80.000 mm
[zjm] z jerk maximum            233 mm/min^3 * 1 million
[zjh] z jerk homing             500 mm/min^3 * 1 million
[zjd] z junction deviation        0.0100 mm (larger is faster)
[zsn] z switch min                0 [0=off,1=homing,2=limit,3=limit+homing]
[zsx] z switch max                3 [0=off,1=homing,2=limit,3=limit+homing]
[zsv] z search velocity        1000 mm/min
[zlv] z latch velocity          100 mm/min
[zlb] z latch backoff             4.000 mm
[zzb] z zero backoff              2.000 mm
[aam] a axis mode                 1 [standard]
[avm] a velocity maximum      50000 deg/min
[afr] a feedrate maximum     200000 deg/min
[atn] a travel minimum           -1.000 deg
[atm] a travel maximum          600.000 deg
[ajm] a jerk maximum           5000 deg/min^3 * 1 million
[ajh] a jerk homing            5000 deg/min^3 * 1 million
[ajd] a junction deviation        0.0100 deg (larger is faster)
[ara] a radius value              0.1990 deg
[asn] a switch min                0 [0=off,1=homing,2=limit,3=limit+homing]
[asx] a switch max                0 [0=off,1=homing,2=limit,3=limit+homing]
[asv] a search velocity         600 deg/min
[alv] a latch velocity          100 deg/min
[alb] a latch backoff             5.000 deg
[azb] a zero backoff              2.000 deg
[bam] b axis mode                 0 [disabled]
[bvm] b velocity maximum       3600 deg/min
[bfr] b feedrate maximum       3600 deg/min
[btn] b travel minimum           -1.000 deg
[btm] b travel maximum           -1.000 deg
[bjm] b jerk maximum             20 deg/min^3 * 1 million
[bjd] b junction deviation        0.0500 deg (larger is faster)
[bra] b radius value              1.0000 deg
[cam] c axis mode                 0 [disabled]
[cvm] c velocity maximum       3600 deg/min
[cfr] c feedrate maximum       3600 deg/min
[ctn] c travel minimum           -1.000 deg
[ctm] c travel maximum           -1.000 deg
[cjm] c jerk maximum             20 deg/min^3 * 1 million
[cjd] c junction deviation        0.0500 deg (larger is faster)
[cra] c radius value              1.0000 deg
[p1frq] pwm frequency               100 Hz
[p1csl] pwm cw speed lo            1000 RPM
[p1csh] pwm cw speed hi            2000 RPM
[p1cpl] pwm cw phase lo           0.125 [0..1]
[p1cph] pwm cw phase hi           0.200 [0..1]
[p1wsl] pwm ccw speed lo           1000 RPM
[p1wsh] pwm ccw speed hi           2000 RPM
[p1wpl] pwm ccw phase lo          0.125 [0..1]
[p1wph] pwm ccw phase hi          0.200 [0..1]
[p1pof] pwm phase off             0.100 [0..1]
[g54x] g54 x offset               0.000 mm
[g54y] g54 y offset               0.000 mm
[g54z] g54 z offset               0.000 mm
[g54a] g54 a offset               0.000 deg
[g54b] g54 b offset               0.000 deg
[g54c] g54 c offset               0.000 deg
[g55x] g55 x offset              75.000 mm
[g55y] g55 y offset              75.000 mm
[g55z] g55 z offset               0.000 mm
[g55a] g55 a offset               0.000 deg
[g55b] g55 b offset               0.000 deg
[g55c] g55 c offset               0.000 deg
[g56x] g56 x offset               0.000 mm
[g56y] g56 y offset               0.000 mm
[g56z] g56 z offset               0.000 mm
[g56a] g56 a offset               0.000 deg
[g56b] g56 b offset               0.000 deg
[g56c] g56 c offset               0.000 deg
[g57x] g57 x offset               0.000 mm
[g57y] g57 y offset               0.000 mm
[g57z] g57 z offset               0.000 mm
[g57a] g57 a offset               0.000 deg
[g57b] g57 b offset               0.000 deg
[g57c] g57 c offset               0.000 deg
[g58x] g58 x offset               0.000 mm
[g58y] g58 y offset               0.000 mm
[g58z] g58 z offset               0.000 mm
[g58a] g58 a offset               0.000 deg
[g58b] g58 b offset               0.000 deg
[g58c] g58 c offset               0.000 deg
[g59x] g59 x offset               0.000 mm
[g59y] g59 y offset               0.000 mm
[g59z] g59 z offset               0.000 mm
[g59a] g59 a offset               0.000 deg
[g59b] g59 b offset               0.000 deg
[g59c] g59 c offset               0.000 deg
[g92x] g92 x offset               0.000 mm
[g92y] g92 y offset               0.000 mm
[g92z] g92 z offset               0.000 mm
[g92a] g92 a offset               0.000 deg
[g92b] g92 b offset               0.000 deg
[g92c] g92 c offset               0.000 deg
[g28x] g28 x position             0.000 mm
[g28y] g28 y position             0.000 mm
[g28z] g28 z position             0.000 mm
[g28a] g28 a position             0.000 deg
[g28b] g28 b position             0.000 deg
[g28c] g28 c position             0.000 deg
[g30x] g30 x position             0.000 mm
[g30y] g30 y position             0.000 mm
[g30z] g30 z position             0.000 mm
[g30a] g30 a position             0.000 deg
[g30b] g30 b position             0.000 deg
[g30c] g30 c position             0.000 deg

And here is my HOME_COMMAND (maybe you need G92 here rather than the G28.3 after all?):
G28.2 Y0 Z0
G28.2 X0
G92 X0 Y0 Z0

And here is my probe ACTUATE_BOOLEAN_COMMAND:
{True:G38.2 Z-42 F800 ;probe down in absolute coordinates until zmin switch is hit}
{True:M400 ;wait for motion to stop}
{True:M114 ;report position}
{False:G91 ;change to incremental mode}
{False:G1 Z3.5 F400 ;backoff until nozzle tip is just touching}
{False:G90 ;change back to absolute mode}
{False:M400 ;wait for motion to stop}
{False:M114 ;report position}

Good luck,
Tony

Peter Chaisty

unread,
Feb 8, 2021, 7:07:24 AM2/8/21
to ope...@googlegroups.com
Thanks Tony

Actually it is useful, good to compare settings.

I think I will leave probing in place but not use it for now .
I don't want to change the actuator type back unless it screws something .
Thanks 

Peter




Reply all
Reply to author
Forward
0 new messages