Nate Holt's Blog

August 12, 2009

User enhancement to Spreadsheet-to-PLC I/O drawing tool – AutoCAD Electrical

Filed under: Electrical — nateholt @ 2:16 pm

Modifiable Source Code

The spreadsheet to PLC I/O drawing generator is impressive. Lay out your PLC I/O and connected devices in an Excel spreadsheet, launch the utility, get a cup of coffee, come back, and what awaits you is an initial set of PLC I/O drawings generated from your spreadsheet data. 

This utility is powerful out-of-the-box, but it begs to be customized. So much so that Autodesk ships this utility un-compiled format… it loads and runs from it native Lisp source ASCII text file “wdio.lsp” and its dialog definition file “wdio.dcl”!

A simple user customization

honda2009-01From time to time, a seasoned AutoCAD Electrical user needed to generate sets of PLC I/O drawings without a “ladder” hot/neutral bus. He would set the “Suppression” toggle as shown here in the utility’s “Setup” sub-dialog.

Without the vertical bus in the way, he set up his library symbols such that the wire connection for each I/O point would wrap around and tie to a second connection terminal of the I/O point pair.

 

Everything worked great except for…

honda2009-02

The user’s issue with the AutoCAD Electrical Spreadsheet to PLC I/O generator tool is that under these conditions (suppressed ladder vertical bus wires), unused I/O points could end up with unconnected

… dangling wires…

tied to the “return” connection terminals. These dangling wires would have to be manually removed after the drawings were auto-generated.

The reason why the wdio.lsp utility was not removing them was because they actually made a connection to the module, but not at an I/O address point so there was no in-line device check.

The solution seemed to be this… if an inserted wire ends up unconnected at one end (i.e. a “dangling” wire) ANYWHERE on the module, then the utility should go ahead and trim it out of the circuit.

Customizing the wdio.lsp utility

The user enlisted the help of N8 Consultants. The first task was to actually find the wdio.lsp file. A recent posting on this blog gave a software utility tool to quickly locate it.

Next, open the file with either the Visual Lisp IDE or any ASCII text editor. Looking through the lisp code, there is a function that is called to “clean up” the ladders (i.e. remove unused “rungs”). This seemed like a good place to also check and remove “dangling” wire connections.

After making sure that a backup copy of wdio.lsp was saved, a bit of experimentation began. Soon, we had a working prototype customization, the key part shown in red below. What this new “erase_if_dangling_wire” function does is process the passed line segment entity wire_en. It throws a crossing window around each end of the line segment to see if it captures any block insert instances. If so, and if only captures one at one end of the wire segment, then it goes ahead and trims out this “dangling” wire ( ! ).

(defun ladder_cleanup ( ldr_cnt / ben wire_en)
    ; Check if unused rungs can be removed from this ladder
    ; Figure out center point of upper ladder rung
; ** 04-Aug-09 NEHolt - customer issue with dangling wire
    ; -- internal function --                    
    (defun erase_if_dangling_wire ( wire_en pt3 / dangling_wire ssf ed plcblock_connection)
      (setq ed (entget wire_en))                           
      (setq dangling_wire nil)
      (setq ssf (ssget "_C"
                  (list (- (car (cdr (assoc 10 ed))) GBL_wd_trp) (- (cadr (cdr (assoc 10 ed))) GBL_wd_trp) 0.0)
                  (list (+ (car (cdr (assoc 10 ed))) GBL_wd_trp) (+ (cadr (cdr (assoc 10 ed))) GBL_wd_trp) 0.0) ))
      (if (AND ssf (= (sslength ssf) 1)) ; check if capture something other than itself (crossing
                                         ; window captures more than the line entity itself
        (progn ; the 10 end of the wire segment has nothing connected to it
          (setq dangling_wire T)
        )
      ) 
      (if (not dangling_wire)
        (progn ; check other end
          (setq ssf nil)
          (setq ssf (ssget "_C"
                       (list (- (car (cdr (assoc 11 ed))) GBL_wd_trp) (- (cadr (cdr (assoc 11 ed))) GBL_wd_trp) 0.0)
                       (list (+ (car (cdr (assoc 11 ed))) GBL_wd_trp) (+ (cadr (cdr (assoc 11 ed))) GBL_wd_trp) 0.0) ))
          (if (AND ssf (= (sslength ssf) 1))
            (progn
              (setq dangling_wire T)
            ) 
        ) )
      )
      (setq ssf nil) ; release the selection set
      (if dangling_wire
        (progn ; one end of this wire segment is unconnected
          (c:wd_trimwire wire_en pt3) ; get rid of dangling wire
    ) ) ) 
; ** 04-Aug-09 NEHolt.end 
    ; -- main subfunction begins here --
    (if Aw_debug (princ "\nIN:ladder_cleanup"))
    (cond
      ((= h_or_v_rungs "V")
        ; Erase unused rungs
        (setq xcoor (car first_ladder_XY_org))
        (setq pt3 (list xcoor
                (- (- (cadr first_ladder_XY_org) (* ldr_cnt ladder_2_ladder_dist))
                        (* ladder_width 0.5))
                0.0))            
        (setq ix ladder_rung_cnt)
        (while (> ix 0)
          (if (setq x (wd_get_nearby_line pt3))
            (progn ; hit LINE
              (setq ed (entget x))
              ; check length of LINE
              (if (equal (distance (cdr (assoc 10 ed)) (cdr (assoc 11 ed)))
                  ladder_width 0.1)
                (progn ; this LINE is same width as ladder. Erase LINE.
                  (c:wd_trimwire x pt3)
                )
; ** 04-Aug-09 NEHolt - customer issue with dangling wire
              ; ELSE
                (progn
                  (if (/= plc_keep_shorted_wire 1)
                    (progn ; flag to erase unused wires. Check this wire to see if
                           ; it is not connected at one end. If so, then go ahead and
                           ; consider erasing this dangling wire segment.
                      (erase_if_dangling_wire x pt3)
                ) ) )
; ** 04-Aug-09 NEHolt.end               
          ) ) )
          (setq ix (1- ix))
          (setq xcoor (+ xcoor rung_spacing))
          (setq pt3 (list xcoor (cadr pt3) 0.0))      
        )
       

Conclusion

 The user reports that this specific customization to his local copy of the out-of-the-box wdio.lsp utility works great!

2 Comments »

  1. […] User enhancement to Spreadsheet-to-PLC I/O drawing tool (trim dangling wires) […]

    Pingback by Automation of PLC I/O Drawings – AutoCAD Electrical « AutoCAD Electrical Etcetera — February 11, 2010 @ 10:20 am

  2. “he set up his library symbols such that the wire connection for each I/O point would wrap around and tie to a second connection terminal of the I/O point pair.”

    How was this done? I am trying to use the PLC I/O utility to generate drawings for a Thermocouple Input Card, and require wires and terminal blocks on a return loop from the instrument symbol to the return terminal.

    Comment by Ryan Wyer — February 15, 2010 @ 10:13 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 38 other followers

%d bloggers like this: