📖 Scenario: You are setting up a PLC to read analog sensor values. The sensors output signals in two common ranges: 4-20mA current and 0-10V voltage. You need to convert these raw input values into meaningful engineering units.
🎯 Goal: Build a simple PLC program that converts raw analog input values from 4-20mA and 0-10V sensors into scaled engineering units using linear scaling formulas.
📋 What You'll Learn
Create variables to hold raw input values for current and voltage signals
Create configuration variables for minimum and maximum raw input values
Write code to scale the raw inputs to engineering units using linear formulas
Print or display the scaled engineering values
💡 Why This Matters
🌍 Real World
This project simulates how PLCs read and convert analog sensor signals from industrial devices like flow meters, pressure sensors, or temperature transmitters.
💼 Career
Understanding analog input scaling is essential for automation engineers and technicians who configure PLCs to monitor and control industrial processes accurately.
Progress0 / 4 steps
1
Create raw input variables
Create two variables called raw_current and raw_voltage to hold the raw analog input values. Set raw_current to 3277 and raw_voltage to 2048.
PLC Programming
Hint
Think of raw_current and raw_voltage as the numbers read from the PLC's analog input registers.
2
Add configuration variables for scaling
Add four variables: current_min set to 3277, current_max set to 16383, voltage_min set to 0, and voltage_max set to 4095. These represent the raw input ranges for 4-20mA and 0-10V signals.
PLC Programming
Hint
These values correspond to the raw ADC counts for the sensor signal ranges.
3
Calculate scaled engineering values
Write code to calculate scaled_current and scaled_voltage by scaling the raw inputs to engineering units. Use the formulas: scaled_current = 4 + (raw_current - current_min) * (20 - 4) / (current_max - current_min) scaled_voltage = 0 + (raw_voltage - voltage_min) * (10 - 0) / (voltage_max - voltage_min)
PLC Programming
Hint
Use simple math to convert raw counts to real-world units like mA and volts.
4
Display the scaled values
Write two print statements to display the values of scaled_current and scaled_voltage with labels: "Scaled Current (mA):" and "Scaled Voltage (V):".
PLC Programming
Hint
Use print statements to show the final converted values clearly.
Practice
(1/5)
1. What is the typical current range used for analog input signals in industrial PLCs?
easy
A. 0-5V
B. 10-30mA
C. 4-20mA
D. 0-24V
Solution
Step 1: Understand common analog signal standards
Industrial sensors commonly use 4-20mA current loops for analog signals because they are less affected by electrical noise.
Step 2: Compare options with standard ranges
Among the options, only 4-20mA is the standard current range for analog inputs in PLCs.
Final Answer:
4-20mA -> Option C
Quick Check:
Standard analog current signal = 4-20mA [OK]
Hint: Remember: 4-20mA is the classic industrial current signal [OK]
Common Mistakes:
Confusing voltage and current ranges
Choosing 0-5V as standard current signal
Thinking 10-30mA is common
2. Which of the following is the correct way to configure a 0-10V analog input in a PLC program?
easy
A. Set input range to 0-24V and scale raw value accordingly
B. Set input range to 4-20mA and scale raw value accordingly
C. Set input range to 0-5V and scale raw value accordingly
D. Set input range to 0-10V and scale raw value accordingly
Solution
Step 1: Identify the signal type
For a 0-10V sensor, the PLC input must be configured to accept voltage signals from 0 to 10 volts.
Step 2: Apply correct scaling
The raw input value must be scaled based on the 0-10V range to convert it into meaningful units.
Final Answer:
Set input range to 0-10V and scale raw value accordingly -> Option D
Quick Check:
0-10V input needs 0-10V range setting [OK]
Hint: Match sensor type with input range setting [OK]
Common Mistakes:
Using 4-20mA range for voltage input
Choosing 0-5V range for 0-10V sensor
Ignoring scaling after setting range
3. Given a 4-20mA input scaled to 0-100 units, what is the scaled value if the raw input is 12mA?
medium
A. 50
B. 60
C. 40
D. 70
Solution
Step 1: Understand scaling formula for 4-20mA
The formula to scale current (I) to units is: scaled = ((I - 4) / (20 - 4)) * 100