📖 Scenario: You work in a factory where sensors measure temperature as raw analog values from 0 to 4095. You need to convert these raw values into real temperatures in degrees Celsius for monitoring.
🎯 Goal: Build a simple PLC program that scales raw analog input values (0-4095) to temperature values (0-100 °C).
📋 What You'll Learn
Create a variable raw_value with a sample analog input value.
Create a variable max_raw to hold the maximum raw input value (4095).
Write the scaling logic to convert raw_value to temperature in temperature_celsius.
Print the scaled temperature value.
💡 Why This Matters
🌍 Real World
Scaling raw sensor data to meaningful units is common in industrial automation to monitor and control processes accurately.
💼 Career
Understanding how to scale analog inputs is essential for PLC programmers and automation engineers working with sensors and control systems.
Progress0 / 4 steps
1
DATA SETUP: Create the raw analog input variable
Create a variable called raw_value and set it to 2048 to represent a sample analog input.
PLC Programming
Hint
Think of raw_value as the sensor reading from 0 to 4095.
2
CONFIGURATION: Define the maximum raw input value
Create a variable called max_raw and set it to 4095 to represent the maximum raw analog input value.
PLC Programming
Hint
This value is the highest possible reading from the sensor.
3
CORE LOGIC: Scale the raw value to temperature
Create a variable called temperature_celsius that scales raw_value from 0 to max_raw into a temperature range from 0 to 100 degrees Celsius using the formula: temperature_celsius = (raw_value / max_raw) * 100.
PLC Programming
Hint
Divide the raw value by max_raw, then multiply by 100 to get degrees Celsius.
4
OUTPUT: Display the scaled temperature
Write a print statement to display the value of temperature_celsius.
PLC Programming
Hint
The printed value should be approximately 49.96 degrees Celsius.
Practice
(1/5)
1. What is the main purpose of scaling analog values in PLC programming?
easy
A. To reduce the size of the PLC program
B. To increase the speed of the PLC processor
C. To convert raw sensor signals into meaningful engineering units
D. To change digital signals into analog signals
Solution
Step 1: Understand analog input signals
Raw sensor signals are usually voltage or current values that need interpretation.
Step 2: Purpose of scaling
Scaling converts these raw signals into meaningful units like temperature or pressure.
Final Answer:
To convert raw sensor signals into meaningful engineering units -> Option C
Quick Check:
Scaling = Convert raw to useful units [OK]
Hint: Scaling means converting raw sensor data to real-world units [OK]
Common Mistakes:
Confusing scaling with speeding up the PLC
Thinking scaling reduces program size
Mixing analog and digital signal conversion
2. Which of the following is the correct formula to scale a raw analog input raw from range raw_min to raw_max into a scaled output range scale_min to scale_max?
Using addition instead of subtraction in denominator
Mixing max and min values incorrectly
3. Given a raw input value of 2500 from a sensor with raw range 0-4095, scaled to temperature range 0-100°C using the formula scaled = (raw - 0) * (100 - 0) / (4095 - 0) + 0, what is the scaled temperature?
5. You have a sensor outputting raw values from 500 to 3500 representing pressure from 20 to 100 psi. Which formula correctly scales a raw input raw to pressure?