How-To Guides
Analytics Guides

Use the Conversion Function

15min

You can use the Conversion processor to convert commonly used units.

Video



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

User Scenarios

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.

User Scenario 1

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

Use Scenario 2

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

Use Scenario 3

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

Step 1: Add a Device

Follow the steps to Connect a Device and configure the following parameters:

  • Device Type: Simulator
  • Driver Name: Generator
  • Enable Alias Topics: Select the checkbox.

Step 2: Add Tags

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.

Tag 1 (User Scenario 1)

  • Name: Select S - Random value generator.
  • Value Type: Select int64.
  • Polling Interval: Enter 5.
  • Tag Name: Enter Timestamp.

Tag 2 (User Scenario 2)

  • 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.

Tag 3 (User Scenario 3)

  • 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.

Step 3: Create Analytics Flows

You can now create the analytics flows using data from the device and tags you previously created.

To create the analytics flow:

  1. Navigate to Analytics.
  2. On the analytics canvas, click Add processor. The Create a processor dialog displays.

    The Add processor option
    The Add processor option
    
  3. Select DataHub Subscribe.
  4. In the Topic field, click the search icon, select the device you previously created, and then select the alias topic for the Timestamp tag.

    Document image
    
  5. Click Save.
  6. Click Add processor again and select Conversion.
  7. In the Conversion field, select timestamp to UTC, and click Save.
  8. Connect the two processors, select Events, and enter a definition of timestamp for the connection.

    Processor flow for Timestamp tag
    Processor flow for Timestamp tag
    
  9. 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.
  10. 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.
  11. On the analytics canvas, click Save.

The configured analytics flows should look like the following.

Completed analytics flows canvas
Completed analytics flows canvas


Step 4: View Conversion Data

You can view data on the analytics canvas by clicking the View icon in each Conversion processor.



View icons for Conversion processors
View icons for Conversion processors


Conversion Data for Timestamp Tag11.

A value for the time the data was generated in UTC is included in the payload.

Time in UTC included in payload
Time in UTC included in payload


Conversion Data for Temperature Tag

The temperature value of 75 Celsius is converted to 167 Fahrenheit.

Converted value from Celsius to Fahrenheit
Converted value from Celsius to Fahrenheit


Conversion Data for Angle Tag

The value of 65 degrees is converted to 1.1344640137963142 radian.

Converted value from degrees to radian
Converted value from degrees to radian