In industrial automation, reading a sensor is only half the battle. The real challenge is converting a raw electrical signal into a value that humans—and machines—can actually use. This lesson covers the industry-standard 4-20mA current loop and how to scale it within akYtec Logic Program (ALP).
1. Why 4-20mA? (The B2B Standard)
While hobbyist projects often use 0-5V, industrial systems prefer 4-20mA for two reasons:
- Noise Immunity: Current signals aren’t affected by voltage drops over long cables.
- Fault Detection: A 0mA reading signals a broken wire, whereas a 4mA reading signals a live “zero” value.
2. Physical Wiring: 2-Wire Pressure Sensor
Most industrial sensors use a “Loop Powered” 2-wire configuration.
- Sensor (+) Red: Connect to +24V DC.
- Sensor (-) Black: Connect to the AI1 (Analog Input) terminal on your akYtec device.
- Device Ground: Ensure your akYtec controller and 24V supply share a common ground (GND).
3. ALP Configuration
Before programming, you must tell the hardware to expect current rather than voltage.
- In ALP, go to the Device Configuration tab.
- Select your Analog Input (e.g., AI1).
- Set Sensor Type to
4-20mA. - Set Lower/Upper limits to
0and1.0(or0-4000depending on your specific hardware model’s resolution).
4. The Linear Scaling Logic (LIN_INT)
To turn the 0.0 - 1.0 raw signal into a meaningful value (like 0.0 - 10.0 Bar), we use the LIN_INT block.
Block Setup:
- X1 (Raw Min): 0.0
- X2 (Raw Max): 1.0
- Y1 (Unit Min): 0.0
- Y2 (Unit Max): 10.0 (The maximum range of your sensor)
ALP Screenshot Description:
Imagine a square block titled LIN_INT. On the left, a floating-point variable named AI_Raw enters the X input. On the right, the output leads to a display variable named Pressure_Bar.
5. Adding “Broken Wire” Detection
To maintain B2B safety standards, we must detect if the sensor fails.
- Add a Compare block.
- Set it to check if
AI_Rawis less than0.02(roughly 3.9mA). - Link the output to a Red LED or a Modbus Alarm Coil.
🚀 LogicHobbyist Pro Tip: Scaling Precision
When scaling in ALP, always use Floating Point (REAL) variables. Using Integers will round your values, causing you to lose the decimal precision needed for accurate pressure or temperature monitoring.
⚠️ Industrial Safety: The “Live Zero”
Always program a fault routine for when the signal drops below 3.8mA. In industrial logic, a 0mA reading doesn’t mean “zero pressure”—it means a broken wire. Use a Compare block to trigger an alarm if the input is < 0.05.