Bidyadhar Subudhi Head of the Department Department of Electrical Engineering National Institute of Technology Rourkela. A liquid level sensor (rotary potentiometer) detects the current level of the liquid in the tank in terms of the voltage across the potentiometer and feeds it to the microcontroller and the control action generated by the microcontroller is amplified by a suitable amplifier that drives the actuator drives (the pump) and ultimately controls the flow output of the pump. In the present project work, a discretized model of the fluid level system is developed using PI controller and is simulated in MATLAB Simulink to observe the nature of the PI controlled system output.
INTRODUCTION
INTRODUCTION
- MOTIVATION
- WORK SUMMARY
- REPORT ORGANISATION
- LIQUID LEVEL SYSTEM DESCRIPTION
The setup is connected to the circuit, and then the control algorithm is implemented in real time using a microcontroller. Water tank - This is the tank in which the liquid level must be controlled. The level of the floating arm and thus the resistance of the rotary potentiometer changes as the liquid level in the tank changes.
SYSTEM MODELING, DISCRETIZING AND
SYSTEM MODELING, DISCRETIZING AND SIMULATION
SYSTEM MODELING [1]
As we can see from equation (2.4), it is a non-linear relationship between the inflow rate (Qin) and the water height in the tank (h). This equation can be linearized for small perturbations around the operating point. Using the Laplace transform of equation (2.12), we obtain the transfer function of the reservoir for small disturbances with respect to the steady state value as a first-order system:. 2.13) The pump, level sensor and power amplifier are simple units and can be approximated as having only proportional gains and no system dynamics. Thus, you can get the block diagram of the level control system as shown in Figure 2.1 below.
SYSTEM DISCRETIZING
SYSTEM SIMULATION
Now the discretized device controlled by the PI controller looks like this, MATLAB Simulink. Thus, by comparing the simulation results of an uncontrolled discretized device and a PI-controlled discretized device, we notice that with the implementation of a PI controller, the desired set value in the output is achieved more evenly with fewer deviations and fluctuations. Therefore, in our project, we use PI controller algorithm to control the liquid level plant system to prevent tank overflow.
COMPONENTS USED IN THE PROJECT
COMPONENTS USED IN THE PROJECT
- ATMEGA32 MICROCONTROLLER
- ATMEGA32 Architecture
- PORT system
- Analog-to-Digital Converter
- Timer Subsystem
- Interrupt Subsystem
- AD7302 DIGITAL-TO-ANALOG CONVERTER
- LM675 POWER AMPLIFIER
- Water Pump
- Liquid level sensor
The result can either be left adjusted by setting the ADLAR bit (ADC Left Adjust Result) in the ADMUX register. The REFS[1:0] bits in the ADMUX register are also used to determine the reference voltage source for the ADC system. The result can be left justified by setting the ADLAR (ADC Left Adjust Result) bit in the ADMUX register.
TCNT0 is the 8-bit counter for Timer 0. The timer clock source (clkTn ) is entered in the 8-bit Timer/Counter Register (TCNT0). Three of the interrupts can be from external interrupt sources, and the remaining 18 interrupts are for the microcontroller's peripheral subsystems. The AD7302 converts an 8-bit digital value to an analog voltage. The AD7302 is designed to be a memory-mapped device.
The PD pin must be pulled high to function. The AD7302 needs a reference voltage to perform the D/A conversion. N is the decimal equivalent of the code loaded into the DAC register and ranges from 0 to 255. As the level of the floating arm changes due to the changing height of the liquid in the tank, the resistance of the rotary potentiometer changes .
Depending on the desired height of the liquid to be set as a set point, the corresponding voltage.
TESTING AND INTERFACING OF THE
TESTING AND INTERFACING OF THE DEVICES
TESTING OF DEVICES
- Testing of ATMEGA32
- Testing of ATMEGA32 ADC
- AD7302 Testing
In the following image we can see that on the right side we can see the status of various PORTs, ADC registers, timer registers, etc. A variable voltage was applied to pin no. 40 PA0 of the microcontroller and the ADC outputs ADCL and ADCH were transferred to PORTC and PORTD respectively to record and analyze the results. From the tabulated data, we find that the microcontroller gives approximately correct expected values after converting the analog i/p voltage to its equivalent 10-bit digital value.
The decimal equivalent is then converted to binary and compared to the last column of the above table and found to be almost close. 5 volts and 0 volts were given at the input pins of the DAC and the outputs were recorded in the following table. It was found that the outputs were almost equal to the theoretically calculated values of D/A conversion value given by the following relation-.
The circuit for testing the power amplifier is as follows. A different input was given on the input connector, and the outputs were tabulated. A graph was made with input voltages as x-axis and output voltages as y-axis and it was found that the curve became horizontal at input voltage = 4.02V and the corresponding output voltage was 11.03 volts. The maximum output obtained from the LM675 power amplifier is 11.03 volts, which is sufficient to drive the water pump.
It can be seen that the power amplifier has an almost constant gain gain of about 2.65 i.e.
INTERFACING OF DEVICES
- Interfacing of AD7302 to ATMEGA32
LM675 I/O characteristics
In the DAC, the CS signal is permanently pulled low to continuously transfer data to the it. LDAC is permanently pulled low to continuously transfer data from the input register to the DAC register and a. At the output pin A of the DAC, the LED is connected to see its response to the output voltage generated by the DAC.
If the circuit and code are working correctly, the brightness of the LED should change in proportion to the various inputs to the microcontroller. This is a logical representation of this, as the potentiometer is used to represent the liquid level sensor (which is nothing more than a rotary potentiometer that gives an input voltage based on the water level), and the LED in the output circuit is used to represent the pump of the actual circuit. Light and ON/OFF LEDs represent the opening and closing of the pump.
The output of the AD7302 is fed to a power amplifier LM675 to boost the DAC output current to enough to drive the pump. The C code implementing the algorithm was compiled and sent to the microcontroller to test the circuit's operation. The code checks the operation of the circuit by causing the LED to glow if the voltage of the input potentiometer is above the midpoint.
The flashing of the LED indicates that the interconnected circuit of ATMEGA32 and AD7302 is responding correctly and thus the LED can be replaced with the LM675 circuit.
DEVELOPMENT OF DISCRETE PI
DEVELOPMENT OF DISCRETE PI CONTROLLER
CONTROLLER REALIZATION IN DISCRETE DOMAIN
To use the PI algorithm in our project, the digital implementation of PI is needed, so we need a Z-transform of the parallel form Equation (4.3), since the z-transform is for the discrete domain as the s-transform is for the continuous domain . .
The DAQ 6221 card is a small electronic card that plugs into the parallel port of a personal computer. Labview software runs on a PC and can be used to record real-time measurements of the DAQ 6221 card. The following figure shows the circuit diagram and hardware set up to perform an open-loop step response test.
The following is the code to send the step signal to the liquid level system. Then, the D/A is disabled by setting its WR pin so that the value sent to the D/A is latched. A step signal of 200 is sent and the D/A is enabled by clearing the WR pin so that the step signal can be transferred to the DAC.
The following figure shows the output of the LABVIEW program for recording the step response. The above curve is transferred to MATLAB and the tangent is drawn to the curve so that it has the maximum possible slope and its x-intercept determines the PI parameter TD (delay constant). Since the sampling time is usually chosen to be less than one-tenth of the system time constant ie.
The PI coefficients Kp and Ti can be determined using Ziegler Nichols open loop settings as shown below in the following table.
DISCRETE TIME PI ALGORITHM
IMPLEMENTATION OF CONTROLLER
ALGORITHM
IMPLEMENTATION OF CONTROLLER ALGORITHM
ADC channel 0 is connected to the plant level sensor output (y). The output of the DAC is connected to the LM675 power amplifier which drives the pump. The sampling interval is 0.1 s (100 ms) and the timer interrupt service routine is used to obtain the required sampling interval.
The program consists of the Initialize_Timer, Initialize_Read_ADC and Interrupt Service Routine (ISR) functions. The output of the uk controller is sent to the DAC by enabling the DAC and also taking into account that the D/A converter is limited to full scale ie. after sending the output to the D/A, the DAC is prevented from locking the current value so that it does not accidentally change.
The variables are then updated and at the end the ISR routine reactivates the timer interrupts and the program waits for the occurrence of the next interrupt[1]. The following function initializes the timer0 so that interrupts can be generated at 10ms intervals. TCNT0=0X00; // reset the timer counter for next interrupt TIFR=0X02;// clear timer overflow bit by setting it so that the next timer overflow interrupt can.
The main program initializes the variables, setpoint, DAC, etc. and then waits in an endless loop for the timer to break every 100 ms.
RESULTS AND CONCLUSION
RESULTS AND CONCLUSION
RESULTS
The output response of the PI controlled liquid level closed loop system is as follows. It can be seen that the liquid steadily reaches its desired height, which corresponding to the level sensor's output voltage of 3.8 volts is set as the set point and stops there without increasing further. When the water is emptied from the tank, the pump starts to fill the water again to the set point and then stops again.
So we can see that the PI algorithm is properly followed, so we have successfully designed an automatic digital controller for the liquid level system. There is no need to manually switch the pump on or off as it can be controlled automatically. We can also compare the simulated result and the experimental result to see if the controller behaves as expected with almost the same PI coefficients used in the simulation and experiment.
CONCLUSION
Selecting ATMEGA32 helps in 10 times faster execution (compared to conventional microcontrollers like 8051) and more effective performance as each instruction only needs one clock cycle for execution and the multiply process needs 2 clock cycles for execution while other microcontrollers need more cycles. It also reduces the need for using external ADC, simplifying the circuit. Selecting AD7302 helps for accurate performance as it has the WR pin which when pulled high locks its value and prevents it from changing accidentally. The system can be used in industrial applications for accurate liquid level measurement and control as required in boilers in power plants, petroleum industries, pharmaceutical or chemical industries, etc.
It can also be used for domestic applications to prevent tank overflows and thus save electricity and water.