Getting PC-DMIS to read a value from a CSV file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting PC-DMIS to read a value from a CSV file

    Hey there. I've been tasked with coming up with a sub-routine that can be run at the beginning of programs for new product coming thru. Essentially, when you start the program, it will check to see when was the last time the probes were calibrated. If it has been more than 24 hours, the program will stop. We have other measures in place where we do make sure to calibrate every 24 hours. We are also using the feature in the probe utilities box that gives the warning if it has been more than 24 hours since calibration, but that isn't good enough. We need to have it so the program won't run, basically brick the CMM. I've heard that there is something in newer versions of PC-DMIS that will check the calibration time and stop it if it has been past a certain time, but we are running PC-DMIS 2013 MR1, and it doesn't have that feature.

    I've been pouring around thread after thread here on the forum along with the help file and notes from my level 3 class. I've found a way to do it here on the forum. I was able to get it way to work, but I wasn't understanding all that I was typing in. It was more of a monkey see, monkey do thing. It was rather lengthy and involved code as well. I was looking for something a little more simple and straight forward. I thought that I had come up with the perfect solution, but then I got stuck.

    Below is what I came up with. I have it check the current date and time. Then I have it check the date and time of when a specific probe angle was last calibrated. I combine the current date and time and the calibration date and time to get it into a format for the CSV file. When I save it, I tell it to save the current date and time on one line and the calibration date and time on the next line. Then I have it insert the formula into the CSV file.

    I was so excited that this worked. The only issue is that I have tried several ways to get it to read the value from the CSV file, but every time that I tell it to read the file, it reads the formula, =(A1-A2)*24, instead of the result, 24.3658. I've used the readline function very little, so I'm not overly familiar with it to know what I may be doing wrong or missing. Any help would be greatly appreciated. I hope that there is something that I am missing, but I'm fearful that maybe it just isn't possible for PC-DMIS to read anything other than the =(A1-A2)*24.

    calibration_time.JPGcalibration_time_CSV.JPG

  • #2
    Originally posted by kinko View Post
    ...but I'm fearful that maybe it just isn't possible for PC-DMIS to read anything other than the =(A1-A2)*24.
    That's correct. PC-DMIS can only read the text that is actually stored in the file. But you should be able to do the subtraction in PC-DMIS, I'm almost sure there is a thread somewhere here on the forums about that.

    AndersI
    SW support - Hexagon Metrology Nordic AB

    Comment


    • #3
      If you want to do the math in PC-DMIS, I am thinking that the dates would need to change to Julian and the time would need to be converted into minutes. But run your math in a variable first then put that variable in your third write line.

      PC-DMIS is not Excel. I'm sure there's a script that would do this. Maybe Kp61dude! has one.
      Last edited by bfire85; 01-14-2020, 08:01 AM.

      Comment


      • #4
        You can look here :
        https://www.pcdmisforum.com/forum/pc...n-basic-script
        But comparing two dates is a little complex because months don't have the same length, so a calibration performed the marsh 1st could be 48 hours after the february 28th, on a bisextile year.
        You have to create assignments with arrays of days, months...
        I'll give it a try, but it's really complex !

        Comment


        • AndersI
          AndersI commented
          Editing a comment
          No need - read my comment in the thread you linked: https://www.pcdmisforum.com/forum/pc...685#post311685

          But you need a small Basic-script, date subtraction can't be done in PC-DMIS assignments.

        • kinko
          kinko commented
          Editing a comment
          Thank you for this Anders. I will definitely look at this and see what I can use. Gotta run to a meeting. Thank you!

        • kinko
          kinko commented
          Editing a comment
          Thank you Jefman as well!

      • #5
        Thank you both for your help. I did find a couple helpful threads. One was "Code for comparing calibration times between probes" by Evan.Smith. The other one was "Parameter set AutoCal" by Rookie. Both were very helpful and seem to work fine. I just thought and hoped that I was on to something that would make this simple and straight forward. If @Kp61dude or someone else has something, awesome. Otherwise, I can go with the suggestions in the two threads that I found and make myself more familiar with that coding.

        Comment


        • #6
          Here are the two threads if anyone else is interested.
          https://www.pcdmisforum.com/forum/pc...between-probes

          https://www.pcdmisforum.com/forum/pc...er-set-autocal

          Comment


          • #7
            This is what I did to make sure the fixture I am using is within calibration, which is on a 6 month (182 day) cycle. I pulled this off the forums here:

            https://www.pcdmisforum.com/forum/pc...om-system-date

            Code:
            ASSIGN/DAY=SYSTEMDATE("dd")
            ASSIGN/MONTH=SYSTEMDATE("MM")
            ASSIGN/YEAR=SYSTEMDATE("yy")
            ASSIGN/LY=0
            IF/YEAR==20 OR YEAR==24 OR YEAR==28 OR YEAR==32 OR YEAR==36 OR YEAR==40
            ASSIGN/LY=1
            END_IF/
            IF/MONTH==1
            ASSIGN/COUNT=0
            ASSIGN/TOTAL_DAYS=COUNT+DAY
            END_IF/
            ELSE_IF/MONTH==2
            ASSIGN/COUNT=31
            ASSIGN/TOTAL_DAYS=COUNT+DAY
            END_ELSEIF/
            ELSE_IF/MONTH==3
            ASSIGN/COUNT=59
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==4
            ASSIGN/COUNT=90
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==5
            ASSIGN/COUNT=120
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==6
            ASSIGN/COUNT=151
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==7
            ASSIGN/COUNT=181
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==8
            ASSIGN/COUNT=212
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==9
            ASSIGN/COUNT=243
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==10
            ASSIGN/COUNT=273
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==11
            ASSIGN/COUNT=304
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ELSE_IF/MONTH==12
            ASSIGN/COUNT=334
            ASSIGN/TOTAL_DAYS=COUNT+DAY+LY
            END_ELSEIF/
            ASSIGN/TODAY=STR(YEAR)+TOTAL_DAYS
            CAL_READ =FILE/OPEN,C:\Users\Public\Documents\CMM Files\Scripts\Fixture Calibration Trigger.txt,READ
            CAL_VAR =FILE/READLINE,CAL_READ,{LINE}
            ASSIGN/CAL_DATE=LINE
            FILE/CLOSE,CAL_READ,KEEP
            IF/CAL_DATE>TODAY
            GOTO/SKIP_CAL
            END_IF/
            
            --------------------------
            PROGRAM CODE
            --------------------------
            
            ASSIGN/END_YEAR=STR(YEAR)+365+LY
            ASSIGN/YR_DAYS=(365+LY)/2
            ASSIGN/MATH=END_YEAR-TODAY
            IF/MATH>=YR_DAYS
            ASSIGN/ADD_TO=TOTAL_DAYS+182
            ASSIGN/NEXT_CAL=STR(YEAR)+STR(ADD_TO)
            END_IF/
            IF/MATH<YR_DAYS
            ASSIGN/DIFF=182-MATH
            ASSIGN/ADD_YEAR=YEAR+1
            ASSIGN/NEXT_CAL=STR(ADD_YEAR)+STR(DIFF)
            END_IF/
            COMMENT/REPT,
            "NEXT CAL: "+NEXT_CAL
            WRITE_CAL =FILE/OPEN,C:\Users\Public\Documents\CMM Files\Scripts\Fixture Calibration Trigger.txt,WRITE
            FILE/WRITELINE,WRITE_CAL,NEXT_CAL
            FILE/CLOSE,WRITE_CAL,KEEP
            IF/FLAT1.OUTTOL==0 AND FLAT2.OUTTOL==0
            COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=YES,TIME DELAY=3,
            FIXTURE PASSED INSPECTION
            END_IF/
            IF/FLAT1.OUTTOL>0 OR FLAT2.OUTTOL>0
            COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
            FIXTURE FAILED INSPECTION. PLEASE SEE CMM PROGRAMMER.
            CLICK OK TO CONTINUE OR CANCEL TO STOP INSPECTION.
            END_IF/
            PRINT/REPORT,EXEC MODE=END,$
            TO_FILE=ON,AUTO=1,AUTO OPEN=OFF,$
            TO_PRINTER=OFF,COPIES=1,$
            TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
            REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
            TO_EXCEL=OFF,$
            PREVIOUS_RUNS=DELETE_INSTANCES
            
            SKIP_CAL =LABEL/
            Last edited by bfire85; 01-14-2020, 06:46 PM.

            Comment


            • kinko
              kinko commented
              Editing a comment
              YOU ARE AWESOME!!! Thank you so much for this. I've been messing around with the thread you sent earlier and focusing on what Andersl wrote. I just don't know enough about basic scripts yet to feel comfortable or even able to come up with something, but I think that this, along with some of the other things that I have read is exactly what I need to do. Thank you again for this info and for pointing me to this thread. This is one that I had not seen yet.

          • #8
            I calibrate probes every 2 months, if then bahaha! I would do it just like OP has started.

            If calibrating: output information
            Normal runs: read information and test/calc, if true prompt for fresh calibration

            If you're wanting to put it in a sub, just:
            open a new routine and save it as SubroutineLibrary or something meaningful
            paste contents in there
            encapsulate contents with Subroutine and End Subroutine (this defines a sub, you can have multiple subs in your sub library)
            fill in inputs/outputs
            viola!

            In your main routine:
            call sub routine fill in inputs/outputs.
            like this
            Code:
            L3         =CALLSUB/CREATE_POINT_PATTERN,C:\Users\Public\Documents\WAI\PC-DMIS\2015.1\Subroutines\SubroutineLibrary_AutoFeatures.PRG:1.69,-.24,-.05,0,-1,0,,
            Call from any and all routines...save yourself the haggle of copy/pasting and perhaps human error.
            PcDmis 2015.1 SP10 CAD++
            Global 7-10-7 DC800S

            Comment

            Related Topics

            Collapse

            Working...
            X