Microcontroller
اعداد:
In this project, we display the control of a fluid level measurement system. It is based on a
realistic water system control in an ordinary home. This system enables us to control the volume
of the water in the tank which means knowing how much the tank is full or empty. Therefore, if
the tank is empty, our control gives the opportunity for the pump(water motor) to fill up the
tank again by pumping water from the well and inserting it into the water tank.This will be done
in different speeds according to the “fullness” of the tank. In this control system, we will need the
following to carry out the process:
Simply here, the conductive water level sensor in the water tank is connected with the PIC
allowing it to control the input voltage to the DC motor(centrifugal pump). This leads to the
following assumptions:
1- If the tank is empty, the level sensor connected to the tank will open a path for the
current.
2- This will feed the DC pump with power
3- The pump will keep pumping water in different speeds according to the conductive wire
reached which will cause less water pumping as the water level goes up.
4- When the tank is full, the highest conductive wire will cause current to flow that will shut
the pump power system down until the level goes back down and the conduction is no
longer reached.
The following schematic will display the main hardware in this control system:
This is the program used in the PIC18 control system:
#include<p18f4550.h>
#include"gamelinit.h"
#include"timers.h"
#include<pwm.h>
#include<adc.h>
void main(void)
{
TRISBbits.TRISB0 =1;
TRISBbits.TRISB1 =1;
TRISBbits.TRISB2 =1;
TRISBbits.TRISB3 =1; //RB0 - RB3 for level detecting
TRISBbits.TRISB4 =1; //for switch
while(1)
{
if (sw==1)
{
WriteTimer0(250);
while(INTCONbits.TMR0IF==0);
INTCONbits.TMR0IF=0;
ConvertADC();
while(BusyADC()==1);
c=ReadADC();
if(c<=205)
{
SetDCPWM1 (0);
}
if(c>820)
{
if(sum==3)
{
SetDCPWM1 (75);
}
if(sum==8)
{
SetDCPWM1 (50);
}
if(sum==33)
{
SetDCPWM1 (0);
}
if(sum==0 || sum==1)
{
SetDCPWM1 (100);
}
else
{
SetDCPWM1 (0);
}
ClosePWM1();
CloseADC();
CloseTimer0();
}
2-A small delay will activate in order for the ADC to initialize
3- As for sum, we did that so we can do a single operation without putting too many commands
*/
We have also worked this semester on the following:
This programmer did not work because of that the rs232 was serialized.
2) JDM based programmer #2
This was a PIC18 programmer that we tried to build, it did not work because the first leg of the
PIC was broken.
3) IC level sensor
This is a level sensor based on the IC CD4066, it did not work with us because it probably burned
while we where soldering its legs.