Issues with Movement...

This is where you talk about Plugins. How they are made and how they work, show examples.

Issues with Movement...

Postby SpillSesh » Tue Feb 27, 2024 5:58 am

Hi Guys,

I've trying to work on this for over a week now... Absolutely stumped.

I've plugin that controls a drill moving from Z0 to Z-(a variable). When I click the pause button I want it to retract 1mm (which is in the positive direction). I've managed this in two ways, neither of which are acceptable. Need help please.

The below works but requires me to click OK on a popup box. I don't like this solution because it's an extra action from the operator, and if the operator is slow or forgets, then the drill tip will rub during spindle deceleration.

UC.StopWithDeccel(); //Stops the G - code execution
double Z_Pos_Desired = UC.GetZpos() + 1;
MessageBox.Show(new Form { TopMost = true }, "Drill will be retracted by 1mm to prevent rubbing", "Drilling Operation Paused", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
UC.Code("G0 Z" + Z_Pos_Desired);

For an unknown reason, if I remove the MessageBox then it always returns to Z0 (not ideal). This happens regardless of whether I call the command from the plugin or a Macro.

UC.StopWithDeccel(); //Stops the G - code execution
double Z_Pos_Desired = UC.GetZpos() + 1;
UC.Code("G0 Z" + Z_Pos_Desired);

I have also tried the button route:

UC.StopWithDeccel(); //Stops the G - code execution
UC.Callbutton(166); // Sets the jog distance when stepping mode to 1.00 Units
UC.Callbutton(162); // Sets the jog mode to stepping.
UC.Callbutton(151); // Jogs the Z axis to positive direction 1mm (away from cut face, stops rubbing)

This works, but only once per UCCNC startup. If I press this plugin PAUSE button again and haven't restarted UCCNC, then it does nothing.

Can anyone explain what is going on? Got any ideas to achieve this without the MessageBox.Show?

Regards,

Jesse.
SpillSesh
 
Posts: 9
Joined: Sun Jan 07, 2024 2:34 am

Re: Issues with Movement...

Postby dezsoe » Tue Feb 27, 2024 3:47 pm

You try to start a new movement while the Z is decelerating. Wait for the stop to execute:

Code: Select all
                UC.StopWithDeccel(); //Stops the G - code execution
                while (UC.IsMoving())
                    Thread.Sleep(10);
                double Z_Pos_Desired = UC.GetZpos() + 1;
                UC.Code("G0 Z" + Z_Pos_Desired);
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Issues with Movement...

Postby SpillSesh » Wed Feb 28, 2024 8:47 am

Thanks dezsoe,

I tried this and it still returns to Z0, not Z_Pos_Desired.

Any other ideas?
SpillSesh
 
Posts: 9
Joined: Sun Jan 07, 2024 2:34 am

Re: Issues with Movement...

Postby dezsoe » Wed Feb 28, 2024 9:07 am

That's interesting, because I tested the code. That is why it is indented: I just copied from my test plugin. What else is in your code and which version of UCCNC did you try?
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Issues with Movement...

Postby SpillSesh » Wed Feb 28, 2024 10:43 pm

Version 1.2116
There is a lot of other stuff in my code....
(I pasted it here but deleted it because I found a solution), see post below.
Last edited by SpillSesh on Wed Feb 28, 2024 11:05 pm, edited 1 time in total.
SpillSesh
 
Posts: 9
Joined: Sun Jan 07, 2024 2:34 am

Re: Issues with Movement...

Postby SpillSesh » Wed Feb 28, 2024 10:59 pm

Yep, something weird is going on.

This stops as required.
UC.StopWithDeccel();

This stops then returns to Z0 (when it shouldn't):
UC.StopWithDeccel();
UC.Code("G91");

It seems that anything I write in UC.Code returns to Z0, regardless of what it is...
SpillSesh
 
Posts: 9
Joined: Sun Jan 07, 2024 2:34 am

Re: Issues with Movement...

Postby SpillSesh » Wed Feb 28, 2024 11:07 pm

Found a solution.

Code: Select all
                UC.StopWithDeccel();
                while (UC.IsMoving())
                    Thread.Sleep(100);
                UC.Codesync("G91");
                UC.Codesync("G0 Z1");
                UC.Codesync("G90");
                UC.StopWithDeccel();


Adding UC.StopWithDeccel() after movement is complete prevents it returning to Z0. I don't know why it does this, but it works for me now...
SpillSesh
 
Posts: 9
Joined: Sun Jan 07, 2024 2:34 am


Return to Plugins

Who is online

Users browsing this forum: No registered users and 1 guest