PLC Programming For Tank Level Measurement Using Ultrasonic Sensor

In our earlier post we saw the PLC Logic for Auto filling of Tank using Digital inputs for LOW and HIGH Level signals. Today in this post we will see how we can we measure the level of tank using the Ultrasonic/Capacitive level sensor and accordingly ON/OFF the PUMP at low and high levels.

PLC Programming for Tank Level Measurement using Ultrasonic Sensor :-

First of all we need to choose the Ultrasonic/Capacitive level sensor according to our tank level height. The Sensor will give a 4-20mA signal to PLC and accordingly we will calculate the level in the tank.

PLC Logic Development : -

First of all we need to connect the analog input from the ultrasonic sensor to PLC , we have already told that in our earlier post . You can see here.

After that we have to write SCL (scaling instruction) in the PLC to covert the value received by PLC to the scale we want. For example if the height of our tank is 5000cm , PLC will receive the 4-20ma singnal and internally will convert it in to range of o to 0FA0(hexa) and with the help of SCL instruction we will scale this value between 0 to 5000.

So that when the Ultrasonic sensor will give 4mA signal then level in tank will be zero and when signal of 20mA will be received then level in tank will be 5000cm.
In SCL instruction we have to define the scaling parameters in some D :-
D200 - 0
D201 - 0
D202 -5000(hexa)
D203- 0FA0 (hexa)
here the value 0 to 0FA0 received by PLC will be scaled to 0 to 5000 (our tank height)
Now in this PLC Program we have kept the low level at 2500cm and high level at 4600cm.
You can download the PLC program from below , we have build the PLC Program using the omron CX-supervisor software. Both the .cxp and .pdf file are included in.

Download PLC program for Tank Level Measurement.

If you face any problem with this PLC Program or want any modification then write us in comment section.
Also you can subscribe to receive latest updates about PLC Programming , SCADA tutorials, HMI programming , MODBUS programming , VFD Installation. Subscribe to Automation-Talk by Email.

Advertisements :-


  1. I am trying to sense a blade on a spinning tool, with a analog prox (sensing 8v no blade/11v blade preset). Its a fanuc controller, input module #AAD04A with a balluff analog proximity switch (BAW M08EI-UAD25F-BP03). Having trouble with the logic. Any help would be appreciated.

  2. Dear,
    You can make the logic by comparing the analog value with the preset constant(i.e for 8v and 11v)
    And then set a bit for particular condition i.e blade present or not.

    If any other clarification ..feel free to ask.

  3. I am trying to control heater using plc fatek analog module and I don't have any information about scaling here , i will use RTD pt100

  4. Dear Mahmoud ,
    You have to use the RTD card for getting the value of temperature in PLC.
    Also i would like to tell you that the Scaling information for FATEK plc can be found in the manual.
    As per my info , it will be 0 to 4000 for 0 to 10V input.

  5. sir
    here ur explanation very helpful to me thank u sir
    i want to know how to define d202-5000(hexa)
    d203-0FA0(hexa)what is mean of 0FA0 how we we know this values to werite in program

  6. hello sir how you select I2001 in input type in first block in program?


Get New Updates

Enter your email address:

Delivered by FeedBurner

Receive all updates via Facebook. Just Click the Like Button Below