TinyG2 (ArduinoDue+gShield) weird probing - possible solution.

TinyG2 (ArduinoDue+gShield) weird probing - possible solution.

I have played with the TinyG2 on Due again and I think I found a reason for the probing issue, which is closely related to limit switches.

By default TinyG2 requires:

  • NC (normally closed) switches wired to Xmin, Ymin and Zmax
  • NO (normally open) switch wired to Zmin acting as a probe

NC switches should be wired using pull-down resistor connected to GND, and not pull-up. This way during normal operation circuit is closed and the limit pins get +3.3V from Due Vref or VCC pin = logic HIGH. Once limit switches gets hit, it disconnects the circuit causing immediate change to a logic LOW. The pull-down resistor limits current, so we don’t fry input pins.
This is correct way to wire NC switches, as if a wire gets accidentally disconnected (broken) the machine will report LIMIT ACTION and won’t work.

The way it works with pull-down resistors means that the LIMIT ACTION should be activated (triggered) when changing from HIGH to LOW = on TRAILING EDGE. Currently it gets triggered on LEADING EDGE, so the LIMIT ACTION gets activated when the limit switch is released = circuit gets completed (closed) = LOW -> HIGH.
With the above (pull-down) connections of limit switches the PROBE pin works OK, only the limit switches gets triggered while released.

Wiring NC limit switches with pull-up resistors holds input pins in logic LOW during normal operation, when circuit is closed. After switch gets hit its logic is immediately pulled-up to VCC = logic HIGH. The processor reports LIMIT ACTION, as the change is LOW -> HIGH = LEADING EDGE. But this conflicts with the PROBE pin logical state (see my previous post for details) and on my opinion is not correct.

I tested both setups using a breadboard and motors running in the air. It works just as I explained above.

@Riley_Porter_ril3y ​​​​​ and @Alden_Hart ​​​​​ How can I change the LEADING EDGE to TRAILING EDGE for limit actions, so I could compile and test?

Thanks for the analysis. Can you tell me what firmware build you are using? Presumably 087.xx from edge? There are some differences in the answer depending.

@Alden_Hart ​​​ I use latest version from github, shows 89.02 in Chilipeppr. I can send you the $$ firmware/build part if needed when I get back home.

The hardware is ArduinoDue+gShield ver. 5b, here are the build details:
[fb] firmware build 89.02
[fbs] firmware build " build"
[fv] firmware version 0.98
[cv] configuration version 7.00
[hp] hardware platform 3.00
[hv] hardware version 0.00
[id] TinyG ID 0213-0215-d423

I copied settings_default.h to settings_test.h and modified the following part:
// Xmin on v9 board
#define* DI1_MODE NORMALLY_CLOSED*
#define* DI1_ACTION INPUT_ACTION_STOP*
#define* DI1_FUNCTION INPUT_FUNCTION_LIMIT*

// Xmax
#define* DI2_MODE INPUT_MODE_DISABLED*
#define* DI2_ACTION INPUT_ACTION_NONE*
#define* DI2_FUNCTION INPUT_FUNCTION_NONE*

// Ymin
#define* DI3_MODE NORMALLY_CLOSED*
#define* DI3_ACTION INPUT_ACTION_STOP*
#define* DI3_FUNCTION INPUT_FUNCTION_LIMIT*

// Ymax
#define* DI4_MODE INPUT_MODE_DISABLED*
#define* DI4_ACTION INPUT_ACTION_NONE*
#define* DI4_FUNCTION INPUT_FUNCTION_NONE*

// Zmin
#define* DI5_MODE INPUT_ACTIVE_LOW // Z probe*
#define* DI5_ACTION INPUT_ACTION_NONE*
#define* DI5_FUNCTION INPUT_FUNCTION_NONE*

// Zmax
#define* DI6_MODE NORMALLY_CLOSED*
#define* DI6_ACTION INPUT_ACTION_STOP*
#define* DI6_FUNCTION INPUT_FUNCTION_LIMIT*

then compiled make PLATFORM=gShield SETTINGS_FILE=settings_test.h and loaded g2/TinyG2/bin/gShield/gShield.bin firmware onto ArduinoDue using Chilipeppr Program Board’s Firmware feature and a local web server to download the file from.

I moved the above to the g2 Issue you opened. I’d rather track it all there and then be able to close it.

OK, that is great. Thanks a lot.

It looks like both NC switches wired to limit pins with pull-down resistors and NO (probe) wired to Zmin with pull-up resistor should react to HIGH->LOW transition (trailing edge) and not LOW->HIGH (leading edge) as it is now. During normal operation all pins will be kept HIGH logical state and the trigger action will connect it to GND = we will face a HIGH->LOW transition.

The only change needed in the code at this moment is to change from LOW->HIGH (leading edge) trigger action to HIGH->LOW (trailing edge) trigger action and test.

With current configuration (NC limit switches connected with pull-up resistors) it works in a way, that during normal operation circuit is closed connected to GND and when triggered (switch opened) the logic goes to HIGH thanks to pull-up resistor = LEADING EDGE. But this false triggers also the PROBE pin on ArduinoDue. We do not observe this on ArduinoUno and grbl, as Uno is using pin A5 for probing, which is not related to pin D18 (Zmin).

I will use the Issue#126 for all updates related to this problem from now.

@Alden_Hart Thanks a lot for working on this issue with me. It looks that after changing limit switches inputs mode to INPUT_ACTIVE_LOW:
ALL WORKS AS EXPECTED :):):slight_smile:

I will do a little more testing before closing the Issue #126 on github/g2.

PIN assignment in settings/settings.h related to the limit switches (NC with pull-down resistor) and Probe (NO):
// Xmin on v9 board
#define DI1_MODE INPUT_ACTIVE_LOW //NC switch wired with pull-down resistor
#define DI1_ACTION INPUT_ACTION_STOP // STOP
#define DI1_FUNCTION INPUT_FUNCTION_LIMIT // LIMIT

// Xmax
#define DI2_MODE INPUT_MODE_DISABLED
#define DI2_ACTION INPUT_ACTION_NONE
#define DI2_FUNCTION INPUT_FUNCTION_NONE

// Ymin
#define DI3_MODE INPUT_ACTIVE_LOW //NC switch wired with pull-down resistor
#define DI3_ACTION INPUT_ACTION_STOP
#define DI3_FUNCTION INPUT_FUNCTION_LIMIT

// Ymax
#define DI4_MODE INPUT_MODE_DISABLED
#define DI4_ACTION INPUT_ACTION_NONE
#define DI4_FUNCTION INPUT_FUNCTION_NONE

// Zmin
#define DI5_MODE INPUT_ACTIVE_LOW //Z probe (NO) wired with pull-up resistors
#define DI5_ACTION INPUT_ACTION_NONE
#define DI5_FUNCTION INPUT_FUNCTION_NONE

// Zmax
#define DI6_MODE INPUT_ACTIVE_LOW //NC switch wired with pull-down resistor
#define DI6_ACTION INPUT_ACTION_STOP
#define DI6_FUNCTION INPUT_FUNCTION_LIMIT

If anyone is interested with more details, please refer to: https://github.com/synthetos/g2/issues/126

@sszafran Have a look at #126, you need an improved filtering strategy.

@cmcgrath5035 I already found a bug in schematics vs. my wiring plus added filter to pull-down circuit. Will post updated schematics later.

Homing, limit switches and probing works OK.