Use the Conversion Function
You can use the Conversion processor to convert commonly used units.
You have the following base conversion options:
- timestamp -> local time
- timestamp -> UTC
- Celsius -> Fahrenheit
- Fahrenheit -> Celsius
- degree -> radian
- radian -> degree
- degree -> gon
- gon -> degree
- radian -> gon
- gon -> radian
Review the following scenarios for converting several tag values. For these scenarios, you will simulate data coming from a PLC and make the following conversions.
You have multiple manufacturing sites across several time zones. For monitoring and analysis purposes, you'd like to synchronize your data based on time measurements for all sites.
You will then complete the following conversion:
- timestamp -> UTC
Some of your manufacturing equipment uses Fahrenheit for temperature control, while other equipment uses Celsius. This requires you to standardize the temperature measurements of all equipment for consistent and efficient process control.
You will then complete the following conversion:
- Fahrenheit -> Celsius
Your manufacturing site has CNC machines, which use toolpaths defined in degrees. However, some trigonometric calculations and algorithms used in CNC programming require angular measurements to be in radians.
You will then complete the following conversion:
- degree -> radian
Follow the steps to Connect a Device and configure the following parameters:
- Device Type: Simulator
- Driver Name: Generator
- Enable Alias Topics: Select the checkbox.
After connecting the device, add the following tags. See Add Tags to learn more. Each tag will represent one of the user scenarios noted above.
- Name: Select S - Random value generator.
- Value Type: Select int64.
- Polling Interval: Enter 5.
- Tag Name: Enter Timestamp.
- Name: Select S - Random value generator.
- Value Type: Select int64.
- Polling Interval: Enter 5.
- Tag Name: Enter Temperature.
- Min_value: Enter 75.
- Max_value: Enter 75.
- Name: Select S - Random value generator.
- Value Type: Select int64.
- Polling Interval: Enter 5.
- Tag Name: Enter Angle.
- Min_value: Enter 65.
- Max_value: Enter 65.
You can now create the analytics flows using data from the device and tags you previously created.
To create the analytics flow:
- Navigate to Analytics.
On the analytics canvas, click Add processor. The Create a processor dialog displays.
- Select DataHub Subscribe.
In the Topic field, click the search icon, select the device you previously created, and then select the alias topic for the Timestamp tag.
- Click Save.
- Click Add processor again and select Conversion.
- In the Conversion field, select timestamp to UTC, and click Save.
Connect the two processors, select Events, and enter a definition of timestamp for the connection.
- Repeat steps 2-8 for the Temperature tag and configure the following:
- In the DataHub Subscribe processor, select the alias topic for the Temperature tag.
- In the Conversion processor, select a conversion of Celsius -> Fahrenheit.
- When you connect the two processors, select Events and enter a definition of temperature for the connection.
- Repeat steps 2-8 for the Angle tag and configure the following:
- In the DataHub Subscribe processor, select the alias topic for the Angle tag.
- In the Conversion processor, select a conversion of degree -> radian.
- When you connect the two processors, select Events and enter a definition of angle for the connection.
- On the analytics canvas, click Save.
The configured analytics flows should look like the following.
You can view data on the analytics canvas by clicking the View icon in each Conversion processor.
A value for the time the data was generated in UTC is included in the payload.
The temperature value of 75 Celsius is converted to 167 Fahrenheit.
The value of 65 degrees is converted to 1.1344640137963142 radian.