14 Replies Latest reply on Oct 18, 2010 7:12 AM by MikeD

    Detecting Silk screen on top of a pad

    french

      Ive written an app that will basically detect if the box for a silk screen ref des overlaps any surface mount pads but the code takes a really long time to run.  The built in silkscreen generator has a function in it that I like where it breaks the text if the silkscreen overlaps a surface mount pad that actually runs really fast, but I just want a report of the occurences of these overlaps so I can manually correct the issue.  Basically Im wondering if anyone has a better idea on how to determine if silkscreen ref des is overlaping onto a surface mount pad than taking the extrema of a silk screen and then iterating through every single pad on the board.

       

       

       

      Private Function SilkCheck()

       

      Dim silks As MGCPCB.FabricationLayerTexts

       

      Dim silk As MGCPCB.FabricationLayerText

       

      Dim pads As MGCPCB.PadstackObjects

       

      Dim pad As MGCPCB.PadstackObject

       

      Dim x, y As Integer

       

       

       

      silks = docPCB.FabricationLayerTexts(MGCPCB.EPcbFabricationType.epcbFabSilkscreen)

      pads = docPCB.PadstackObjects(MGCPCB.EPcbPadstackObjectType.epcbPadstackObjectPin)

       

       

      For Each silk In silks

           y = 0

       

           For Each pad In pads

              

                'Center of silk in pad

       

                If silk.PositionX <= pad.Extrema.MaxX And silk.PositionX >= pad.Extrema.MinX And silk.PositionY <= pad.Extrema.MaxY And silk.PositionY >= pad.Extrema.MinY Then

                     ListSilks.Items.Add(stringConv(silk.TextString, x + 1, y + 1, silk.SideName))

       

                End If

       

       

                If silk.Extrema.MinX >= pad.Extrema.MinX And silk.Extrema.MinX <= pad.Extrema.MaxX Then

       

                     'bottom left of silk in pad

       

                     If silk.Extrema.MinY >= pad.Extrema.MinY And silk.Extrema.MinY <= pad.Extrema.MaxY Then

       

       

                          ListSilks.Items.Add(stringConv(silk.TextString, x + 1, y + 1, silk.SideName))

       

                     End If

       

                     'top left of silk in pad

       

                     If silk.Extrema.MaxY >= pad.Extrema.MinY And silk.Extrema.MaxY <= pad.Extrema.MaxY Then

       

       

                          ListSilks.Items.Add(stringConv(silk.TextString, x + 1, y + 1, silk.SideName))

       

                     End If

       

                End If

       

       

                If silk.Extrema.MaxX >= pad.Extrema.MinX And silk.Extrema.MaxX <= pad.Extrema.MaxX Then

       

                     'bottom right of silk in pad

       

                     If silk.Extrema.MinY >= pad.Extrema.MinY And silk.Extrema.MinY <= pad.Extrema.MaxY Then

       

       

                          ListSilks.Items.Add(stringConv(silk.TextString, x + 1, y + 1, silk.SideName))

       

                     End If

       

                     'top right of silk in pad

       

                     If silk.Extrema.MaxY >= pad.Extrema.MinY And silk.Extrema.MaxY <= pad.Extrema.MaxY Then

       

       

                          ListSilks.Items.Add(stringConv(silk.TextString, x + 1, y + 1, silk.SideName))

       

                     End If

       

                End If

       

       

                y = y + 1

       

                Next

       

       

           x = x + 1

       

           Next

      End Function

        • 1. Re: Detecting Silk screen on top of a pad
          david.barber

          Have you tired locking the server?

           

          app.Lockserver()  ' Lock server to improve performance

           

          Dave

          • 2. Re: Detecting Silk screen on top of a pad
            jim.granville

            These days, most PCB FAB houses can easily plot both polarities - so all they need to do, is

            hit the Overlay plot, with a WHITE pad copy, and BAM, any issues are simply gone.

            I believe many simply do this by default.

            • 3. Re: Detecting Silk screen on top of a pad
              fagrondin

              Hi,

               

              What tool are you using ?

               

              Regards

               

              Fred

              • 4. Re: Detecting Silk screen on top of a pad
                david.barber

                Looks like Expedition to me. Which version though? I'm not sure if 2007 has any new automation offerings in relation?

                 

                I've been thinking about this one a little bit, but don't have a solution yet.

                 

                What would be really cool is if you could run a script that automatically works out the placement of the silkscreen ref des to place it as close as possible to the associated cell, trying various orientations to get the optimal placement and not overlapping other features. (This could be a big task?!?)

                 

                I've raised this one in the Mentor Ideas forum as Automatically place silkscreen reference designators. with the hope that they'd develop an AutoSilkscreener. Similar to the way an auto router works.

                 

                I wouldn't be too worried about how fast this runs. If I could leave it running over night and come in the next day to find all the silkscreen reference designators automatically placed then I would be a happy chappy. Arranging ident is not the most enthralling design task. This could save hours of work on a large board, if you feel the same, please vote at the Mentor Ideas site, the link above may work.

                 

                :-Dave

                • 5. Re: Detecting Silk screen on top of a pad
                  french

                  David - the lock server command is called in a preceding function.

                   

                  Jim - the idea is to keep the silk intact and prevent it from being removed.

                   

                  Fagrondin - Im using expedition 2005 and the code is in vb.net

                   

                  Dont know if this is scriptable yet but Im thinking if I create a copy of all the refdes and then convert the copy into metal and then I can drc to it.  drc runs pretty quick and I eliminate the dead space the text box has around it.

                  • 6. Re: Detecting Silk screen on top of a pad
                    fagrondin

                    Bonjour,

                     

                    I can't remember in 2005 ( but it might do it too ) but in Expedition 2007.5 which I'm using the MG drc should be able to

                    do it for you.

                     

                    Batch DRC > DRC Setting ( tab ) > Advanced Element to Element Rules > and here you choose what you want for example :

                     

                    Silkscrenn Outlines to Part Pads Smd 0.5mm...

                     

                    It should work and report everything. Is it what you are looking for ?

                     

                    Regards

                     

                     

                    Fred

                    • 7. Re: Detecting Silk screen on top of a pad
                      french

                      Well thats pretty cool, somehow overlooked that part.  This does exactly what my script does but a whole lot faster.  My only gripe is that it will report if the text box is overlapping a pad and not the actual text itself is on top of a pad.  It is still possible to have the situation where the text box overlaps a pad but the actual text does not which is acceptable and rather common.  oh well cant be perfect all the time I guess.  Thank you.

                      • 9. Re: Detecting Silk screen on top of a pad
                        jim.granville

                        > Jim - the idea is to keep the silk intact and prevent it from being removed.

                         

                        Ah, ok, perhaps a combination of the two paths then ?

                         

                        Use the bounding box check to give the OK on (hopefully) most, visually fix the others,

                        and then use the white printing method, to just ensure that if you DO miss anything,

                        the consequences are not in maufacturing the PCB !

                        • 10. Re: Detecting Silk screen on top of a pad
                          ed_smith

                          To answer the original question (how to speed up the script): You can pick under the Extrema of the text to find all the things (of a specific type) in that region. This should be a couple of orders of magnitude faster than your current implementation. See the Pick method on the Document object.

                           

                          Regards, Ed

                          • 11. Re: Detecting Silk screen on top of a pad
                            patrick.cashman

                            There is another way to get through the data much faster.

                             

                            What you are doing is looking at each silk object, then looking at every pad and comparing dimensions. So you essentially have a grid of X silkscreen objects by Y pad objects, and you are going to have to do the dimensional comparison on every item in the grid.

                             

                            The faster way is basically this:

                             

                            Read all silk objects into an array, getting the x and y values you need.

                            Read all the pad objects into an array, also capturing the x and y values you need.

                            Sort both arrays by x, then by y values.

                            Count the number of elements in the pad array.

                            Divide this number by two.

                            for each silk object, compare x and y values to the element in the middle of the pad array.

                            if it is larger, take the top half of the pad array and divide it in half again, then compare the silk x and y to this element

                            if it is smaller, take the bottom half of the pad array and divide it in half, then compare the silk x and y to this element

                            repeat this process until the difference in the silk xy and the pad xy is small - you'll have to determine how small by experimentation, and by the relative size of the values in question

                            when you have a small difference, compare a few of the pad elements on either side of the one you are closest to, and you'll find any that overlap

                             

                            With this divide by 2 and check the middle value sorting method you can find the items of interest in just a few ( < 10) comparisons, no matter how many objects you are looking at.  I recently used this on a similar task in which I had two data sets of approximately 1000 items each.  Doing the search the long way took 16 minutes.  When I rewrote the code with this faster algorithm, the entire job, including writing out a text file when it was done, took less than 5 seconds.

                             

                            There are other search algorithms out there.  Some are even faster.  But for ease of coding and relative simplicity, this one is pretty slick.

                             

                            Hope this is useful,

                             

                            Patrick

                            • 12. Re: Detecting Silk screen on top of a pad
                              ed_smith

                              Patrick,

                               

                              You are absolutely correct. However, as an fyi, a method similar to that which you describe is already implemented in the Document.Pick function - you could save yourself some coding by using our out-of-the-box solution.

                               

                              Regards, Ed

                              • 13. Re: Detecting Silk screen on top of a pad
                                patrick.cashman

                                Ed,

                                 

                                Thanks, I didn't know about Document.Pick, but it sounds like it could be a lot more powerful as it can look for many kinds of objects.  I'll check it out.

                                 

                                -Patrick

                                • 14. Re: Detecting Silk screen on top of a pad
                                  MikeD

                                  Use DRC, Advanced Element to Element rules, put a value in the matrix at Part Pads SMD & Silkscreen.

                                  Done.  It shows up as a proximity violation.