It is possible to read temperature from sensors on CMM that's equipped with Thermal Compensation.
The GetTemperatureReading() function can be used to store the current temp reading to a variable:
VB Function
int GetTemperatureReading( double &dTemp, int nIndex )
Return Value
0 if the function is successful, which indicates dTemp is a valid temperature reading.
1 if the function fails to get a valid temperature reading, or thermal compensation is not enabled or supported by the controller being used.
Parameters
dTemp
Stores the retrieved temperature reading if the function is successful.
nIndex
Specifies which sensor’s temperature reading to be retrieved. Defined as follows:
X Axis – 1; Y Axis – 2; Z Axis – 3; Part – 4.
The following code will write the part sensor value to the variable "MyTemp1" and the variable "funcWk" will be 0 or 1 depending on whether the function was able to retreive the value or not. If machine is not properly equipped the user is prompted to enter temperature manually.
- MyTemp1 = "xxx"
- funcWk = GetTemperatureReading(MyTemp1, 4)
- If funcWk = 1 Then
- manTmp = MsgBox("GetTemperatureReading() Failed" & vbCrLf & "Enter Temperature Manually?", 36, "Temperature Reading Error")
- If manTmp = 6 Then
- MyTemp1 = InputBox("Please enter temperature", "Enter Temperature", "68")
- End If
- Else
- MsgBox(MyTemp1)
- End If
Finally add a Customer Data Field to the Report header and specify the variable using the [Set] button.
Finally, after running program we see the results displayed in CMM-Manager report: