#include<reg52.h>
#define LINE1 0x80
#define LINE2 0xC0
#define
COLUMN1 0x00
#define COLUMN2 0x01
#define COLUMN3 0x02
#define COLUMN4 0x03
#define COLUMN5 0x04
#define COLUMN6 0x05
#define COLUMN7 0x06
#define COLUMN8
0x07
#define COLUMN9 0x08
#define COLUMN10 0x09
#define COLUMN11 0x0a
#define COLUMN12 0x0b
#define
COLUMN13 0x0c
#define COLUMN14 0x0d
#define COLUMN15 0x0e
#define COLUMN16 0x0f
Sbit LCD_RS=P0^0;
Sbit LCD_RW=P0^1;
Sbit LCD_EN=P0^2;
Sbit LCD_BUSY=P1^7;
Sbit
|
ADC_RD=P0^5;
|
|
Sbit
|
ADC_WR=P0^4;
|
|
Sbit
|
ADC_CLK=P0^3;
|
|
Sfr
|
ADC_DATA=0X90;
|
|
Sfr
|
LCD_DATA=0x90;
|
|
Void
|
LCD_Data (unsigned char);
|
|
Void
|
LCD_Command (unsigned char);
|
|
Void
|
LCD_Init (void);
|
|
Void
|
LCD_Decimal (unsigned char pos,unsigned
char var);
|
|
Void
|
LCD_Hex (unsigned char pos,unsigned char
var);
|
|
Void
|
LCD_String (unsigned char,unsigned char
*var);
|
|
Void
|
LCD_Int16 (unsigned char pos,unsigned int
var,unsigned char n);
|
|
Void
|
LCD_Clear ();
|
|
Void
|
Delay (unsigned int tic);
|
|
Unsigned char ADC0804_Read ();
|
||
Void
|
RS232_Init (int
baudrate);
|
|
Void
|
RS232_String (unsigned char *var);
|
|
Void
|
RS232_Send (unsigned char d);
|
| |||
Sbit a= P2^0;
|
|||
Sbit x= P2^1;
|
|||
Sbit
|
c=P2^2;
|
||
Sbit
|
e=P2^3;
|
Void main (void)
{
Unsigned char
Val, d, PORT_2; a=0;
x=0;
c=0;
e=0;
BUZZER=0;
LCD_Init
();
RS232_Init
(9600);
LCD_String
(0x80,"ADC=");
for
(;;)
{
int
i=0;
do
{
i++;
Delay
(50);
Val=ADC0804_Read
();
LCD_Decimal
(LINE1+COLUMN5, val);
// LCD_Decimal(LINE1+COLUMN10,y);
d=100; While (d! =0)
{
RS232_Send
(val/d+0x30);
Val=
val%d;
d=d/10;
}
}
While (i!=5);
RS232_Receive
();
PORT_2=RS232_Receive ();
LCD_String
(0xC0,"P2=");
LCD_Decimal
(LINE2+COLUMN4,PORT_2);
Switch
(PORT_2)
{
case 49: a=~a; x=0;c=0;e=0;Delay(1000);break; case 50:x=~x;
a=0;c=0;e=0;Delay(1000);break; case 51:c=~c; a=0;x=0;e=0;Delay(1000);break;
case 52:e=~e; a=0;x=0;c=0;Delay(1000);break; case 53:a=0; x=0;c=0;e=0;Delay(1000);break;
}
}
}
Visual basic:
What a GUI??
GUI is
stand for Graphical User Interfaces .It allows for interaction with a computer
or other media formats which employ graphical images, special graphical element
devices and along with text to represent the information and actions available
to a user. GUI allow handling any actions like a mouse click, user enter the
data and keystrokes. There was a lot of software to develop a GUI. For example,
Visual Basic allow a designer to develop GUI application as a monitoring and
controlling system , database application for business and education , games
software and more applications.
What a Visual Basic??
VISUAL
BASIC is a high level programming evolved from the earlier DOS version called
BASIC. In Visual Basic programming is done in a graphical environment. In
Visual Basic, the GUI also involves in certain action such as interrupts,
timers, serial communication, user control and more actions.
Serial Communication in Visual
Basic-
Visual
Basic can be used to access serial communication function. -Allow hardware part
communicate between GUI for several application like monitoring and control
process
Communication
Control in Visual Basic
Visual Basic allow many additional components to
be add in the toolbox. In order to used serial communication, the Microsoft Com
components add to toolbox for transmit and receive data from hardware
Visual
Basic used in PC-Based Temperature Control
-This project objective is to use PC-Based for
monitor and control the temperature. It means that, the GUI developed
should have the text or graphic to show current temperature and the fan status
information.
-Visual
Basic is used to construct A GUI for temperature monitoring and control. As i
mention before, A Visual Basic allow a hardware communicate between computer by
using serial communication.
-According
to this project, the hardware refer to 8051
Microcontroller
communicates between a GUI to display temperature value.
Step t hat have been used
in building a GUI:
Step 1: Design the
interface
Step 2: Set Properties of the controls (Objects)
Step 3: Write the events'
procedure
Advantages:
If we
compare a simple 8051 based temperature control with PC based temperature
control technique then we got that pc based temperature control technique is an
more efficient and have an some advantages.
_ Calibration:
Calibration is the most important characteristic in any type of instrument. In this project we can easily calibrate by
simply language program. We set any desired value and determine if it has any
error then we adjust the value or eliminate the error by using programming, no
hardware adjusting needed.
_ Graphical Representation: We are
used graph for better understanding
to solve and minimize the error. Here we plot a curve in between the output
value of temperature sensor LM35 and time.
Disadvantages:
Generally
every instrument has some advantage and disadvantage also. The disadvantages
are following:
Here we
used serial port as a connecting wire; if we used USB (universal serial bus)
port then we increase the baudrate in between sending and receiving.
In this
system if any problem occurred that means power off or other type of problem
faced then the software not work means again start the software.
Conclusion:
There are a few test that have be done in
completing this project in order to have accurate data and value to be display
at PC. There are temperature sensor tests, A/D converter test, RS232 test and
complete project test.
As a conclusion, the
project was aim the objective to measured temperatures in several location then
display at computer besides, success to develop a GUI by using Visual Basic for
temperature monitoring and control.
Future
Improvement: In the future, this project can make several improvements in order
to add another feature such as using a wireless to communicate between sensor
and microcontroller, monitor and control the temperature via internet and using
USB for communication between microcontroller and computer. For graphical User
Interfaces, add the function to show real time graph between temperature and
time. Then add some features to store all data measured as user reference.
PC Based Temp control using by RS232
ReplyDelete