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.
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*
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.
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 :):)
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