Page 1 of 1

"Reset" keypress

PostPosted: Sun Nov 15, 2020 9:38 am
by summat
I'm developing a plugin for a personal project of developing a special-to-type pendant for my CNC mill. This communicates over ethernet using ModBus, and is intended to give a 80/20 capability at the mill without keyboard/mouse or much of a monitor (apart from a 4" TFT).

One of the essentials is to recover the machine from E-Stop. Once E-STop is de-asserted the machine is in reset-mode, and requires the operator to clear reset by pressing the reset-button on screen. I've tried to emulate this with my plugin with limited success, using either the Keypress for the ToggleReset button, or to explicitly set the Reset button. Two examples below.

(Note: Dyntag/Trailtag used to validate a coherent message update... the "Cmd" holds a unique integer code that represents a command from the pendant - '1' = Clear Reset).

Code: Select all
                UC.GetModbusregister(100, out Dyntag);
                UC.GetModbusregister(101, out Cmd);
                UC.GetModbusregister(149, out Trailtag);

                if ((last_dyntag != Dyntag) && (Dyntag == Trailtag))
                {
                    if (Cmd != 0)
                    {
                        UC.AddStatusmessage("Command " + Dyntag + "   ->  " + Cmd);

                        switch (Cmd)
                        {
                            case 1:
                                // Reset Button
                                UC.Callbutton(144);



Code: Select all
                UC.GetModbusregister(100, out Dyntag);
                UC.GetModbusregister(101, out Cmd);
                UC.GetModbusregister(149, out Trailtag);

                if ((last_dyntag != Dyntag) && (Dyntag == Trailtag))
                {
                    if (Cmd != 0)
                    {
                        UC.AddStatusmessage("Command " + Dyntag + "   ->  " + Cmd);

                        switch (Cmd)
                        {
                            case 1:
                                // Reset Button
                                resetstate = UC.GetLED(25);   // Reset LED State
                                if (resetstate == true)
                                    UC.Callbutton(513);        // Reset Off
                                else
                                    UC.Callbutton(512);        // Reset On
*/


Both methods work... 80% of the time. But testing on a demo-installation of UCCNC (it's warmer in the toyroom than going out to the shed to develop), even on start-up of the demo mode UCCNC, or similarly by clicking 'Reset' to trigger the reset condition, the above code(s) will fail roughly 1-in-4 or 1-in-5 times with the dialogue box "The reset logic of the software is active! Remove the reset condition with pressing the blinking reset button on the screen."

But, of course, with either the default reset-on-startup, or the manually presented reset by clicking the button, there is no reset condition to clear - and a second (or third) presentation of the Cmd will clear the reset (though leave the dialogue on screen).

So my question is: What is the fool-proof way to clear the reset condition?

I'm also mindful of, if simulating a keypress with UC.Callbutton() fails occasionally on "Reset"... is there a process here where other keypresses events similarly be affected?

(p.s. came across the 'AddLinearMoveRel' command yesterday.... thanks for that!, that works beautifully).

Re: "Reset" keypress *** FIXED ***

PostPosted: Sun Nov 15, 2020 2:05 pm
by summat
Please ignore the above.

It turns out that the with having the "Reset" pressed over two successive cycles in the pendant, resulting in two successive calls within the plugin to Callbuttion() resulted in the popup dialogue.

Simple guard code in the plugin to avoid repeated calls to Callbutton() resolved this problem.