Jun 18, 2018

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 measure the level of a 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

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:-

Now, 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 it here.

After that, we have to write SCL (scaling instruction) in the PLC to convert 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 signal and internally will convert it into a 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 the level in the tank will be zero and when a signal of 20mA will be received then the level in the 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 the high level at 4600cm. You can download the PLC program from below, we have built the PLC Program using the Omron CX-supervisor software. Both the .cxp and .pdf files are included.

Download PLC program for Tank Level Measurement.

Hope you like this PLC program on controlling your Tank according to the measurement using an Ultrasonic sensor. If you face any problem with this PLC Program or want any modification then write us in the comment section. 

Also, you can subscribe to receive the latest updates about PLC Programming languages, SCADA tutorials, HMI programming, MODBUS programming, VFD Installation., etc. 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?

  7. Which sensor are you use for level measurement ? Can you tell me the product code or proper name ?

  8. Which sensor are you use for level measurement ? Can you tell me the product code or proper name ?


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