Interaction between UCCNC and Plugin dll

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

Interaction between UCCNC and Plugin dll

Postby cnesan » Sat May 27, 2017 8:13 pm

Hi everyone at the forum,
during this time I am testing the plugin example with the UCCNC software and its Plugininterface.dll function manual.

Ok,
Seeing the commands known that:
- I can get status information of the software (and hence the milling machine)
- I can associate a macro with a button or make some appear.
- I can interact with the machine every 25hz (by event)

My question is:
Is there an event as a response to a gCode command?
For example, the G31 command does the probing on an axis by storing the value in the default variable from # 2000 to # 2005. This value can be used later for further processing.

What I ask is if you can, after launching a G31 command, pass the check on the plugin to make its checks (the plugin analyzes the result then decides whether to repeat the G31 operation or go ahead with the gCode list ).

Thank you for reading, even more if you answer me
cnesan
 
Posts: 16
Joined: Sat May 20, 2017 10:55 am

Re: Interaction between UCCNC and Plugin dll

Postby cncdrive » Sat May 27, 2017 9:38 pm

Hi,

You can't do that with a g-code, but you can do that with an m-code, a macro.
You could write a macro with which you could execute a G31 probing code using the exec.Code("G31 Z-10"); code for example.
after that you could check the probed variables #5061 to #5066 for the probed axis coordinates.
You can also check the #5060 varibale value to see if the probing was successful or not. The possible values of this #var is described in the UCCNC manual.
And you could send messages to one plugin by plugin filename or to all plugins with the following functions:

Function: object Informplugin(string Pluginfilename, object Message)
Description: This function sends data to one plugin. The Pluginfilename parameter defines the name of the plugin to send the message to and the parameter is an object and the return value is also an object.
Example:
string teststr = "Hello Plugintest.dll...";
object Returnvalue = exec.Informplugin("Plugintest.dll", (object)teststr);
if (Returnvalue is string)
{
string str = Returnvalue as string;
MessageBox.Show(exec.mainform, "Return message was: " + str);
}

Function: void Informplugins(object Message)
Description: This function sends data to all plugins. The parameter is an object and there is no return value.
Example:
string teststr = "Hello to all plugins...";
exec.Informplugins((object)teststr);

The same function prototypes documentation together with the other available functions for plugins you may find in the UCCNC/Documentation folder.

With the Informplugin and Informplugins you can send a generic object to all plugins or to just your plugin and you can also pass an object back from your plugin as a return value.
Returning an object is only possible with the Informplugin function, the Informplugins function has a void return value, because that message is received by all plugins and so more may want to answer which could cause issues, so the Informplugins gives a one way communication only while the Informplugin which sends Message only to one, a named plugin that can be used to communicate 2 ways.

An object type (The message parameter) can be basicly anything, a string, a number, an array or whatever type you want to send.
You can catch the sent object in the plugin with the following function prototypes:

object Informplugin_event(object Message)
public void Informplugins_event(object Message)

And in your plugin you may check for type match of the sent object and then convert it, and the same way you can convert it in your macro, something like:

Code: Select all
public object Informplugin_event(object Message)
{
  if(Message is string)
  {
    string mystring = Message as string;
    return (object)mystring;
  }
  return null;
}
cncdrive
Site Admin
 
Posts: 4719
Joined: Tue Aug 12, 2014 11:17 pm

Re: Interaction between UCCNC and Plugin dll

Postby cnesan » Sun May 28, 2017 5:35 am

thank you for answering,

I'm using the AutolevelerCA.dll plugin for PCBs.
AutolevelerCA.dll takes the gCode PCB file and returns a file with the PCB surface probing.

As a probe, I use POGOPIN very much used in the USA.

But one of the negative sides is that contact does not always occur on the PCB surface and POGOPIN.
Therefore it is necessary to repeat the probing (G31) when it returns error or failure to read the surface.

AutolevelerCA.dll inserts the probing commands (G31) into the output gCode file and then loads it into UCCNC for execution.

Prior to your intervention, I mistakenly thought of making a new plugin that followed the process by checking the operations in the gCode file.

I was aware of the macros but I saw them as a sequence of machine-type commands and not programming language. In fact I opened the macros present in the UCCNC directory but also some found in the forum and in fact is very cool.

So returning to my problem, but also how the dll plugin and macros put it:
1) My plugin comes into operation right after AutolevelerCA.dll has generated the file.
2) Scans by replacing the G31 .... commands with the call of a specific macro (later generated by my plugin).
3) Also, based on my plugin setup, integrates the control logic and possible case resolution into the macro. Ex: For G31 = 0 Stop / Ask / Replay G31
So, my plugin can also be closed because the control logic would be managed by the macro.

I am very interested in understanding the relationship between UCCNC (gCode file) Vs Plugin.dll Vs Macro. What I wrote is to understand if I'm right.

If so, I'll go to work right away.

Thank you very much.

P.S.: Using POGOPIN, a contact between the POGOPIN and the copper surface of the PCB is generated. Also the POGOPIN has a spring tip. I've tried already but occasionally the contact does not happen and then I miss reading a certain point. My drill accepts 1 to 3mm shank. While a CNC probe has a 6mm shank.
cnesan
 
Posts: 16
Joined: Sat May 20, 2017 10:55 am

Re: Interaction between UCCNC and Plugin dll

Postby dezsoe » Sun May 28, 2017 8:19 am

Hi,

I think using Pogo pin is not the best way to probe. A small dust is enough to miss a probe. You should use the engraving tool at low feed rate to probe like I do in this video. First you need to know if the tool is on ground or insulated. If it is insulated, then connect probe's one pin to the PCB and the other to the tool. If grounded then you need some more trick to connect to the input, but it is also possible to do.
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Interaction between UCCNC and Plugin dll

Postby cnesan » Sun May 28, 2017 3:57 pm

Yes, What you say is right,
but then I would not have the opportunity to learn to develop plugins and macros !!

OK, I saw the video. It looks like you used a 0.4mm cutter (I think) and it is a very tough blade.
I would like to produce pcb for smd processors and I use V-cutters (0.2mm. 15° or 25°) to make very thin engravings and to remove only Copper between a track and another.
It took me some time to define the plane translating speed and the speed of the cutter.

Up to now, using V-bits on PCBs (PCB buy low-priced) and the cutters break through the path because they sank too much into the PCB support (seeing a microscope in the holder).

The variation of the surface of one side is 0.3 mm. +/- derived from the sum of variations in the thickness of the support.
When mounted on a basket I did, a basket variation is also added. The sum of the variations is enough to break my engraving cutter.

With AutolevelerCA and Probe, I would like to get to 0.04 mm. +/- and the cutter should not break (I think).

I have already used AutolevelerCA to test the surface variations by interrogating the variable for the Z axis and find them correct with the measurements made with the comparator.

However, using the pogopin, on 100 points, about 3 or 4 points, the return value is zero.
Repeating the probing and paying attention I have a simple problem ie there is no contact even if the tip touches, and this is where the programming comes in, moving the plan slightly and repeating the probing.
What do you think about it?

Ok, curiosity, can a macro have input parameters?
Or can the macro only use local variables?

see you soon bye
cnesan
 
Posts: 16
Joined: Sat May 20, 2017 10:55 am

Re: Interaction between UCCNC and Plugin dll

Postby dezsoe » Sun May 28, 2017 7:34 pm

I use 0.2mm 15° v-bit for engraving and for probing. I generate g-code from Eagle using pcb-gcode. Depth is 0.08mm, feed rate is 450mm/min. PCB is fixed with double-sided tape. As you can see on the video, I have a self-built machine made of wood. :) (I build a new machine, but I have not finished it yet, it takes some weeks to complete.)

I checked AutolevelerCA (I don't use it, so I started with default parameters) and it generated probe code like this:

Code: Select all
G31 Z-8 F100
#100=#5063

When using macros, you can send parameters enclosed in {} or if you send only E, H or Q then you don't need it. So, you can replace "G31 Z-8 F100" lines with "M20000 E-8 H100" and then create a macro M20000:

Code: Select all
if (Evar == null || Hvar == null)                     // Stop program if parameter missing
{
  MessageBox.Show("M20000 E<probeZ> H<feed rate>");
  exec.Stop();
  return;
}

double probeZ = Convert.ToDouble(Evar);
int feedZ = Convert.ToInt32(Hvar);
bool probeOK = false;
double currZ = exec.GetZpos();

while (!probeOK)                                      // Was probe successful?
{
  exec.Code("G31 Z" + probeZ + " F" + feedZ);         // Do the original probe code
  while(exec.IsMoving()){}
  probeOK = exec.GetLED(244);                         // Probe status: true if probed successful
  if (!probeOK)
  {
    exec.Code("G0 Z" + (currZ + 2));                  // Go above initial position
    while(exec.IsMoving()){}
    exec.Code("G1 Z" + currZ + " F" + feedZ);         // Go to initial position
    while(exec.IsMoving()){}
  }
}

This macro wil repeat probe until it is successful. (Start carefully, now I am 220km away from my machine, so I tested only in demo mode!) When the probe was successful, the LED 244 (ProbedOK) will be on. The probe result will be in #5063, so the original g-code can use it.

You should check the UCCNC\Documentation folder: there are pdfs in which you can find info about using macros.
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Interaction between UCCNC and Plugin dll

Postby dezsoe » Sun May 28, 2017 8:06 pm

I wrote about my machine, but forgot to post a photo of an SMD PCB.
Attachments
WP_20170129_13_39_27_Pro.jpg
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Interaction between UCCNC and Plugin dll

Postby A_Camera » Mon May 29, 2017 5:53 am

cnesan wrote:As a probe, I use POGOPIN very much used in the USA.
...

P.S.: Using POGOPIN, a contact between the POGOPIN and the copper surface of the PCB is generated. Also the POGOPIN has a spring tip. I've tried already but occasionally the contact does not happen and then I miss reading a certain point. My drill accepts 1 to 3mm shank. While a CNC probe has a 6mm shank.


I have never heard of anyone using pogo pins as probe and I would never do it. Those are meant to be test pins and contacts, and require a certain pressure for safe electrical contact. There is no accuracy in the contact, and also some times make contact immediately, some times needs a mm or two before contact. Very unreliable for probing. You should use something rigid and a touch plate, or a proper probe, use fairly slow feed rate (with UCCNC something between 250-450mm/min is perfectly fine) and if accuracy is really critical then retract back 0.2 mm above the surface and make a second pass at very slow speed (for example 4mm/min).
A_Camera
 
Posts: 638
Joined: Tue Sep 20, 2016 11:37 am

Re: Interaction between UCCNC and Plugin dll

Postby A_Camera » Mon May 29, 2017 6:05 am

dezsoe wrote:I use 0.2mm 15° v-bit for engraving and for probing. I generate g-code from Eagle using pcb-gcode. Depth is 0.08mm, feed rate is 450mm/min. PCB is fixed with double-sided tape. As you can see on the video, I have a self-built machine made of wood. :) (I build a new machine, but I have not finished it yet, it takes some weeks to complete.)


I am also using almost the same setup except that I now mill only to 0.06mm for contact track separation and 0.04mm for text and other markings. Using cheap eBay 0.2mm 30° V-bits, 22000 RPM and 450mm/min.
When you are ready with your new machine, which I guess will be made of aluminium and will be stiffer, more rigid, you will no longer need auto levelling for PCB. Just surface an area and mill happily with perfect accuracy without auto levelling. Saving a lot of time.
A_Camera
 
Posts: 638
Joined: Tue Sep 20, 2016 11:37 am

Re: Interaction between UCCNC and Plugin dll

Postby A_Camera » Mon May 29, 2017 6:10 am

cnesan wrote:Ok, curiosity, can a macro have input parameters?
Or can the macro only use local variables?


A macro can use input parameters also.
A_Camera
 
Posts: 638
Joined: Tue Sep 20, 2016 11:37 am

Next

Return to Plugins

Who is online

Users browsing this forum: No registered users and 1 guest