Output Temperature Sensor to Report

Output Temperature Sensor to Report

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.


  1. MyTemp1 = "xxx"
  2. funcWk = GetTemperatureReading(MyTemp1, 4)
  3. If funcWk = 1 Then
  4. manTmp = MsgBox("GetTemperatureReading() Failed" & vbCrLf & "Enter Temperature Manually?", 36, "Temperature Reading Error")
  5. If manTmp = 6 Then
  6. MyTemp1 = InputBox("Please enter temperature", "Enter Temperature", "68")
  7. End If
  8. Else
  9. MsgBox(MyTemp1)
  10. End If

Aside from Temperature reading obtained from VB Script, it's possible to add any VB Script Variable to the Report in the same manner as described below.  For example, you might add the current System Time by creating a variable like this - MyVarTime = Now()

Finally add a Customer Data Field to the Report header and specify the variable using the [Set] button.
Report Properties - Customer Data

It's also possible to display Variable data in Report>User Notes:
Report > User Notes - use @ to display VB Variable

Finally, after running program we see the results displayed in CMM-Manager report:
Temperature info displayed in CMM-Manager report