Jump to content

PCM Variable question


---
 Share

Recommended Posts

Hello, all I am new to working with PCM and I have a question on how or if it is possible to do this. Basically I have parts that have been in service, and have a measurement that needs to be compared to the initial manufactured value. The values are sorted by part serial number in a parametric file. Basically I want have the operator input the S/n then have calypso search for the that S/n in the list and pull the value. Then in put the value into a formula to find the difference. I cant seem to figure out how to get the imputed value to be used as the value to search the external file, or be be defined as a parameter. 

Thanks. 

Link to comment
Share on other sites

Yes this is possible with PCM,

 

Instead I would  personally suggest recalling original measurement and output to excel, then run part as it is now and output to excel an do a comparison there.

Link to comment
Share on other sites

Hi Chris, 

I don't have access to the original measurement plan just the final results from the inspection, how would you recommend I out put the results to excel I have only ever outputted through piweb.

 

Thanks

-Borg

Link to comment
Share on other sites

 

This should work Ryan.

 

Presettings

Part_Size = inquireList("Which size part would you like to run?", "Diameter_.1234", "Diameter_.0123")
selectCase Part_Size
    case "Diameter_.1234"
     
OD="CMM Diameter_.1234 (dimension 1)"

    case "Diameter_.0123"
     
OD="CMM Diameter_.0123 (dimension 1)"

endSelect

*****************************************************************************************************

Postsettings

filePath = "M:\Measurement Equipment Results\Zeiss Calypso\CMM Results\"+OD+"\"
ext = ".csv"
 

Edited
Link to comment
Share on other sites

Hi Clarke,

I had originally thought to use a list, but the problem is a would be looking at a list that is several thousand serial numbers long, and I feel like  to find the correct serial number would be close to impossible.  Or cause calypso to run slow. 

My line of thinking was something similar to what you suggested, but the data is stored in an external para file. But instead of inquire list I was hoping there would be a way for the operator to type in the serial number and it search for it that way. Essentially something kind of like this. 

Pre settings

Part_Serial=getRecordHead("partnbLong")

readPcmFile("Prerun_Lengths.PARA") { inside this file the length values would be listed as Part serial number = 1.234" for example"}

 

then it takes the value if finds in the list and sets it to another variable to be used in a result element. but that is were I get stuck.

 

Thanks 

-Borg

Link to comment
Share on other sites

Hello, 

Attached is the example of what I trying to do. u_PSN in a custom record head for part number serial numbers 

Pre settings

runPCMFile("Prerun_Lengths.PARA")

below is the file Prerun_Lengths

 //variable definition
// value for result element out put
a=0 
// used for condition loop if value Part S/n not found in list
insp=0
// the part serial number inputted into the value for select case 
PSN=getRecordHead("u_PSN")
// select case based off of the part serial number defining the out put for the result element
selectCase PSN
    case Psn1
        a=1
    case Psn2
        a=2
    case Psn3
        a=3
    caseElse 
        message("no Serial number found")
            insp=1
            endInspection()
endSelect
    

When I run this I keep getting the error saying parameter not defined and it reports out the directory path to the parameter file. 

Link to comment
Share on other sites

Hello Ryan,

I don´t think it works this way, you need to use a loop, and readListFile("Prerun_Lengths.PARA"). But to give you a proper example how to do this, I need an example of your Prerun_Lengths-file.

Link to comment
Share on other sites

Hello,

So I was able to get this to work using the select case with a shorten version of the Pre-run lengths file I was using for prototyping. What I have found is that this method does not scale well. To the point that it has increased the measurement run time by over 15 minutes when I use the full file before I force close the measurement. I can format the data any way I need to.  As of right now it is formatted as a PARA file that calypso references at specific point in the measurement. My guess is calypso is running through each line of the file and is getting overloaded. Unfortunately I cant post the file do to  company policy's but below is the basic lay out of what I have set up. 

The file is laid out as follows

//Varible Definition
DM=0 // used for DM Production value
insp=0// used to skip DM calculation if DM production value not found
PSN=getRecordHead("u_psn")// gets part serial number from user input at beginning of run
// Select case for PS/N
selectCase PSN

case "12345abc"
    DM=1.12345
// supplier and manufacture information

then this continues for about 14K  worth of data sets and ends with 

caseElse
    message("no Serial number found")
            insp=1
            endInspection()
endSelect    

 

Link to comment
Share on other sites

Please sign in to view this quote.

Please sign in to view this username.

 Calypso is not what you need here. You need a script to perform this comparison outside Calypso; it will accomplish what you are trying to do in less than ten seconds. Are you familiar with Python or PowerShell?

Edited
Link to comment
Share on other sites

Please sign in to view this quote.

Thanks I was starting to come to that conclusion as well. I am not as familiar with it as I would like but I am sure I can figure it out. Thanks

Link to comment
Share on other sites

Please sign in to view this quote.

Please sign in to view this username.

 Make a plain text file on your desktop. Rename it to test.txt. Inside your para file, I am assuming your list looks like my snippet of inside my test.txt file.

 

Go to your Windows search (the magnifying glass) on your taskbar. Type in "ISE". The first thing that should come up is Microsoft PowerShell ISE. Right click, open as Administrator (if you can). Copy and paste this script into the ISE workspace. Adjust the file path at the top to YOUR test.txt location. Hit F5 or the green "Run Script" button at the top. Follow prompts. Adjust this as necessary to fit your application.

 

# Path to your text file
$filePath = "C:\PATH TO YOUR TEXT FILE\test.txt"

# Prompt user for Part Serial Number
$serialNumber = Read-Host "Enter Part Serial Number"

if ([string]::IsNullOrWhiteSpace($serialNumber)) {
    [System.Windows.MessageBox]::Show("No input provided for Serial Number.", "Error")
    exit
}

# Check if the serial number is numeric
if (-not ($serialNumber -match '^\d+(\.\d+)?$')) {
    [System.Windows.MessageBox]::Show("Please enter a numeric serial number.", "Invalid Input")
    exit
}

# Prompt user for Current Measured Value
$currentMeasuredValueInput = Read-Host "Enter Current Measured Value"

# Validate the current measured value input
if ([string]::IsNullOrWhiteSpace($currentMeasuredValueInput)) {
    [System.Windows.MessageBox]::Show("No input provided for Current Measured Value.", "Error")
    exit
}

if (-not ($currentMeasuredValueInput -match '^\d+(\.\d+)?$')) {
    [System.Windows.MessageBox]::Show("Please enter a numeric Current Measured Value.", "Invalid Input")
    exit
}

# Read all lines from the file
$lines = Get-Content -Path $filePath

# Initialize variable for match line index
$matchIndex = -1

# Search for the serial number in the file
for ($i = 0; $i -lt $lines.Length; $i++) {
    if ($lines[$i] -match [regex]::Escape($serialNumber)) {
        $matchIndex = $i
        break
    }
}

if ($matchIndex -eq -1) {
    [System.Windows.MessageBox]::Show("Serial number not found in the file.", "Not Found")
    exit
}

# Check if there's a line below the match
if ($matchIndex + 1 -ge $lines.Length) {
    [System.Windows.MessageBox]::Show("No data after the matched line.", "Error")
    exit
}

# Extract value after '=' in the line below
$nextLine = $lines[$matchIndex + 1]
if ($nextLine -match '=') {
    $parts = $nextLine -split '=', 2
    $valueStr = $parts[1].Trim()
} else {
    [System.Windows.MessageBox]::Show("No '=' found in the line below the match.", "Error")
    exit
}

# Validate that the value after '=' is numeric
if (-not ($valueStr -match '^\d+(\.\d+)?$')) {
    [System.Windows.MessageBox]::Show("The value after '=' is not numeric.", "Invalid Data")
    exit
}

# Convert inputs to numbers
$measuredValue = [double]$currentMeasuredValueInput
$fileValue = [double]$valueStr

# Calculate the absolute difference
$difference = [math]::Abs($measuredValue - $fileValue)

# Show the result with serial number included
[System.Windows.MessageBox]::Show("The absolute difference between the current measured value and the DM value for serial number '$serialNumber' is '$difference'.", "Result")

 

 

test text file.png

forRyanBorg.png

Link to comment
Share on other sites

Please sign in to view this quote.

My suggestion was specifically about your question regarding outputting data to excel.

Link to comment
Share on other sites

Please sign in to view this quote.

Clarke, Thanks that makes much more sense then what I tried I am still figuring out the limits of what should and shouldn't be done in pcm. Boy did a find a limit this time. 

Link to comment
Share on other sites

Please sign in to view this quote.

Thank you for writing this it is working perfectly. I had to adjust it only slightly since the data base had a few extra bits of information. Thank you again for your help

  • Like! 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...