ProbeIt for UCCNC

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

ProbeIt for UCCNC

Postby eabrust » Sat Feb 08, 2020 6:46 pm

I've been back working on a few touch probing related plugins since getting UCCAM copy working. I figured that with some of the questions Keith was asking relative to digitizing ( http://www.forum.cncdrive.com/viewtopic.php?f=4&t=2383#p18893 ) made this a good opportunity to show what I'm working on despite it being no where near ready for anyone to use...

I had been wanting to port the 'ProbeIt' wizard from Mach3 code into UCCNC for some time, however almost every single probe routine in it is dependent on doing a combined X/Y G31 probe, which still isn't supported (insert sad face here :( ). But I was playing around a few weekends ago and came up with a way to create a simulated multi-axis G31 command using the 'Jog Safe Probing' feature that UCCNC has. After a little testing, came up with something to try and make it work....

Below video shows the first stages of porting ProbeIt code into UCCNC as a plugin, and running a probe calibration table for angles between 0 - 360 in increments of 10 degrees.


It has a long way to go, but it's a start! :)

In the end, I want to replicate all the features ProbeIt for Mach3 had and add a bunch more since programing in .Net is so much more powerfull than Mach3 wizard code allowed. Some things on the to-do list:
profile tracing-save direct to DXF
manual jog against part - save direct to DXF
Include DXF recording of all basic probe routines (edge, center points, sides, etc)
Incorporate 3d surface scanning (I'm pulling in the 'probecloud' plugin I started a while ago, and will build upon it)

thanks for looking,

regards,
Eric
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 348
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: ProbeIt for UCCNC

Postby eabrust » Mon Feb 10, 2020 12:57 am

Howdy all,

Well, today we got a bunch of snow throughout the day here, so I spent a lot of time working on the ProbeIt re-write for UCCNC (when not shoveling...). Was finally able to get the 2D profile tracing working satisfactorily after losing much hair... but this was the part I was hoping to get working so I'm happy :)

The below video and some pics show a test tracing of a knife scale that I originally made by doing a profile trace by the UCamCopy plugin, so it was a good opportunity to compare by measuring a copy of a copy.

Pardon the poor video and audio, I really don't know how to take decent videos in my shop ....



And here is a comparison of the geometry after import into VCarve (no edits, just raw imported DXF)
UCamCopy vs Probeit.JPG
IMG_20200209_165404427.jpg
IMG_20200209_165444680.jpg


Compare by overlaying (red is UCamCopy trace, black is test of ProbeIt code)
Overlay-UCamCopy vs ProbeIt.JPG


All things considered, to probe around a piece of wood on a rack and pinion driven CNC router, and get within ~ .010" on 3.6" dimension using a hack of a G31 probe command and with very little tweaking or calibrating shows promise. Now that the basic routines work, the rest is just a lot of cleanup of code and making a usable interface.

I really do enjoy programming in .Net for UCCNC, way better than Mach3/4.... Thanks CNCDrive!

Thanks for looking, and I hope this is of interest for what you were asking about Keith. I'll be working on it as time permits over the next few weeks.

regards,
Eric
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 348
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: ProbeIt for UCCNC

Postby beefy » Mon Feb 10, 2020 9:42 pm

That's looking fantastic Eric, you're a legend.

The accuracy looks fine for my initial needs. Personally I'm not after super high accuracy, more just reproducing profiles for plasma cutting, and see if I can make a buck here and there in my back yard.

Happy to pay for your plugin when you release it.

Cheers,

Keith
beefy
 
Posts: 449
Joined: Mon Sep 05, 2016 10:34 am

Re: ProbeIt for UCCNC

Postby cncdrive » Mon Feb 10, 2020 10:17 pm

Hi Eric,

Nice work!
cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm

Re: ProbeIt for UCCNC

Postby eabrust » Tue Feb 11, 2020 2:04 am

Thanks Balzas,

Thought it might be fun to share a little bit of the coding side of plugins, maybe it will help others, maybe someone will point out dumb things I've done and I can learn some more too. And Hopefully no real programmers reading this will puke at the sight of VB and poor coding... :lol: joking of course.

So this is what I came up with to emulate a G31 in the X/Y plane at some angle:
Code: Select all

    ''' <summary>
    ''' This routine emulates a 'G31' command by using JSP mode, but only works in X/Y currently
    ''' </summary>
    ''' <param name="x"></param>
    ''' <param name="y"></param>
    ''' <param name="frate"></param>

    Function XYJSPG31(ByVal x As Double, ByVal y As Double, ByVal frate As Double) As Int16
        ' Returns 0 for no error, 1 for error

        Dim dx, dy As Double
        Dim XSpd, YSpd As Double
        Dim angle As Double


        XYJSPG31 = 1 ' Default to 'fail' flag

        If UC.GetLED(37) Then
            MsgBox("Probe Active, aborting!")
            UC.AddStatusmessage("Probe is active!")

            abortflag = True
            thrMyProc = Nothing
            XYJSPG31 = 1 'Fault

            Exit Function
        End If


        UC.Callbutton(552) ' Enable JSP Mode

        XHit = 0 ' Clear all prior hit data!
        YHit = 0
        ZHit = 0

        jspg31Xstart = UC.GetXpos ' Note start location before move
        jspg31Ystart = UC.GetYpos

        dx = x - UC.GetXpos ' Delta X, Delta Y
        dy = y - UC.GetYpos

        jspg31distance = Math.Sqrt(dx ^ 2 + dy ^ 2) ' Total move distance

        angle = Math.Atan2(dy, dx)  ' Angle of move in X/Y coordinate system


        XSpd = frate * Math.Cos(angle) ' Calculate the X and Y feedrates to move at desired angle
        YSpd = frate * Math.Sin(angle)

        If UC.GetLED(246) = False Then ' Extra redundant check, make sure JSP is on
            MsgBox("Error, JogSafeProbe Not Enabled")

            XYJSPG31 = 1
            thrMyProc = Nothing ' Abort

            Exit Function
        Else

            UC.AddStatusmessage("Probing")

            sendVelocity(XSpd, YSpd, frate) 'Start jogging at desired feedrate, this routine uses JogOnSpeed from the API, converts frate to % spd for each axis.

        End If


        While Not IsMoving() ' Delay so the UCCNC 'is moving' LED lights up before watching 'ismoving'
            Thread.Sleep(5)
        End While


        While ProbeIsMoving() ' This custom 'IsMoving' routine causes a stop if target missed!
            Thread.Sleep(5)
        End While

        UC100.JogOnSpeed(0, True, 0) ' Stop
        UC100.JogOnSpeed(1, True, 0) ' Stop
        UC100.JogOnSpeed(2, True, 0) ' Stop

        GetHitData() 'Routine to fill current location into hit positions

        XYJSPG31 = 0 ' Set OK flag

        UC.Callbutton(553) ' Turn off JSP to move off item

        While UC.GetLED(246) ' Wait for JSP led to turn off
            Thread.Sleep(5)
        End While


    End Function



    ''' <summary>
    ''' This provides similar funcitonality to 'ISMOVING', except will also flag if distance moved exceeds set probe distance to stop
    ''' </summary>
    ''' <returns></returns>
    Private Function ProbeIsMoving() As Boolean
        ProbeCheckFlag = True ' default the flags to TRUE, as false is the triggering condition...
        DistanceFlag = True
        Dim thrIsMoving As New Thread(Sub() CheckProbeIsMoving())
        thrIsMoving.CurrentCulture = Thread.CurrentThread.CurrentCulture
        thrIsMoving.Start()
        While thrIsMoving.IsAlive
        End While
        Return ProbecheckFlag
    End Function

    Private Sub CheckProbeIsMoving()
        IsMovingFlag = UC.IsMoving ' Standard check of 'IsMoving' from internal to UCCNC
        DistanceCheck() ' Custom check to see if the specified distance is met
        If IsMovingFlag = False Or DistanceFlag = False Then
            ProbecheckFlag = False
        End If
    End Sub

    Private Sub DistanceCheck()
        Dim distance As Double
        DistanceFlag = True
        distance = ((UC.GetXpos - jspg31Xstart) ^ 2 + (UC.GetYpos - jspg31Ystart) ^ 2) ^ 0.5  'Just comparing current position to desired end position
        If distance >= jspg31distance Then  ' If current position > or = desired, stop if not already stopped by JSP hit...
            DistanceFlag = False
        End If

    End Sub



It's not real pretty, but it seems to get the job done. In my testing with jogging against parts with JSP mode on, I found that if I stayed under ~10 in/min, there was a negligible difference between where the axis stopped while jogging, and where it stopped using a true G31 move (most likely driven by my axis accel rates, so may be different for others...). Going faster obviously resulted in a greater deviation, but I figure that could potentially be calibrated out too, but on the other hand probing should not be happening at crazy speeds.

So in a nutshell, that is what the plugin is currently built upon at the lowest level. Of course there are many layers of code above that to make the actual routines, and figure out touch location by offsetting ball diameter at the traveling vector angle, etc.

As a side note, if multi-axis G31 becomes built into UCCNC and is available, I'll be able to go back through the plugin and just replace all of the calls of my 'fake' G31 routine with calls to the real version, and hopefully accuracy could be improved a little more.


regards,
Eric
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 348
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: ProbeIt for UCCNC

Postby eabrust » Sun Mar 01, 2020 8:45 pm

Hey there fellow UCCNC users.

I've been ever so slowly working on ProbeIt for UCCNC (an hour or two every night as time allows), and most of the basic functionality is now there without crashing! Figured I'd give a quick look at how it's coming along. I must admit, its taking far longer to repackage existing probe routines than I thought, as I struggle with the creation of the user interface side of things more than the back-end math routines... That and I can't seem to stop adding features as I go instead of getting a minimum set of functions completed.

This is another poorly done video that is much longer than it should be, but it gives an overview and shows some basic probing type routines working:



Functionality that is working:
[*]Calibration routine for probe tip, and correction for all routines (perimeter, basic x/y, etc)
[*]Perimeter probing in x/y, recording to a DXF and CSV file
[*]Basic XY probing (side, corner, edge, bore/pocket, ridge/slot, post), recording data to DXF and CSV
[*]G68 coordinate setup and rotation of coordinate system
[*]Jog Probing, with this on, you can just jog into edges of parts, and it records location to CSV and DXF (with tip diameter correction for velocity vector at time of hit)

Still in process:
[*]routines in X/Z and Y/Z planes
[*]Getting surface probing portion fully working again (rolling in my ProbeCloud plugin and tying together w/ ProbeIt)
[*]Issues w/ DXF when G68 rotations are on
[*]Email/Text when error, finish cycle, etc occurs
[*]Freshen up the graphics and user interface later


There is one 'gotcha' I've found with how the plugin is working that I'm not sure I can resolve on my own, and it may be a quirk that it lives with. Since all the probing is actually done by 'jogging w/ JSP' mode on, if UCCNC losses focus by user trying to multitask while a probe routine is running, the probing routines stop in their tracks. This is due to UCCNCs safety features of only allowing jogging if the app has focus, which is a good safety feature, it just messes with my 'hack' for probing. :lol:


Hopefully the video shows up correctly and isn't to awful to watch... i find that screen recording and additional web cam stuff to focus on is distracting. Testing is being done w/ a mini 'fanless' PC, on Win 10 x64. This little PC is almost pushed to its limit running UCCNC, a webcam, and screen recorder (as the screen recorder takes a little more than 50% CPU by itself). I should have gotten an i5 or i7 instead of a celeron... :roll:

I hope to fix a few more of the less critical bugs I know of, and put it out soon for general testing for anyone interested.

Thanks for looking and listen to me babble!

regards
Eric Brust
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 348
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: ProbeIt for UCCNC

Postby beefy » Mon Mar 02, 2020 12:05 pm

Hi Eric,

sounding good.

Do you have a link to the video. I don't know if it's some setting in my browser or my internet security software but I can't see any of the videos posted on this forum. There's only an empty box there.

Keith
beefy
 
Posts: 449
Joined: Mon Sep 05, 2016 10:34 am

Re: ProbeIt for UCCNC

Postby eabrust » Mon Mar 02, 2020 1:12 pm

Hi Keith,

Try this link for the video: https://youtu.be/GBWKSX1HhjM

I just did a quick check, and on both android phone or on PC using firefox I can see the videos embeded in the forum, but on chrome with both PC and phone they are blank squares.... some sort of chrome problem which is a little ironic.

After some googling, I tried following steps on this link: https://support.google.com/chrome/answer/6138475?co=GENIE.Platform%3DDesktop&hl=en, but no success....

Try firefox instead of chrome maybe? :lol:

regards,
Eric
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 348
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Re: ProbeIt for UCCNC

Postby ger21 » Mon Mar 02, 2020 2:41 pm

Works for me with Firefox.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: ProbeIt for UCCNC

Postby beefy » Mon Mar 02, 2020 9:21 pm

Thanks Eric,

nice looking screen you made. I'm personally more into bright colourful screens so I like your probing screen.

Videos show up in Internet Explorer too so it's starting to look like this might be a chrome only issue. A quick Google and some guy fixed this by un-installing chrome and re-installing. Might do that later.

Keith
beefy
 
Posts: 449
Joined: Mon Sep 05, 2016 10:34 am

Next

Return to Plugins

Who is online

Users browsing this forum: No registered users and 6 guests