
Connections: - LDR is given bias through 10K resistor. the VIN+ input pin is connected at the junction of LDR and 10K as shown. other inputs of ADC like RD, WR, & CS are connected with P3.7, P3.6 and Gnd respectively. INTR o/p of ADC is connected with P3.3 pin. R2 along with C1 provides basic clock signal to ADC. R3 and R4
together provides reference voltage to ADC. data pins D0 - D7 of ADC are connected with P1. another port P2 of 89C52 is connected with data pins D0 - D7 of LCD. the control pins E, RW & Rs of LCD are connected with P3.2, P3.1 & P3.1 respectively. pin no 1,2 & 3 are given proper bias (not shown). two LEDs D1-D2 are connected with P3.4 and P3.5 as shown. port P0 pins P0.0 - P0.3 are connected with stepper motor terminals through ULN chip. crystal circuit is not shown here. C2 is connected between Vcc and RST pin for power on reset feature.
Operation:
-
-
controller sends write pulse to ADC to start conversion and give indication on D1
-
it waits for INTR o/p form ADC. when conversion is over, interrupt is generated.
-
controller reads digital data from ADC and compares it with set value
-
displays both set value and current value on LCD
-
if value
doesn't match it checks if current value is greater or smaller
-
if value is greater then rotate motor in clockwise direction
-
so the moving platform will move towards light source to make it smaller
-
the reverse thing happens if difference is negative.
-
it rotates the motor till the current value is
within the set value range.
software: - entire above operation depends upon the software embedded into 89C52. the software is written in C language and compiled using KEIL (IDE) cross compiler. complete software program is collection of different functions. so let us understand them one by one.
writecmd function sends command byte to LCD. It takes one argument byte and sends it to P2
writedata function sends data byte to be displayed on LCD. It also takes one argument byte and sends it to P2
writestr function writes whole string (message) on LCD. It takes pointer as an argument that points address of first character of string. then through pointer it sends all the character one by one to P2
lcddely function provides delay after sending command or data byte to LCD
bigdely function generates delay of around 2 to 3 seconds. it is given between two write pulses of ADC
dely function generates delay of around 0.2 second. it is given for LED blinking.
display
function takes hex value and first convert it into decimal, then convert it to
ASCII. then display these ASCII characters on LCD
int1
function is interrupt enabled function. it is called automatically when
interrupt is generated. so when conversion is over interrupt is generated and
this function is automatically called. it performs following tasks
-
reads digital o/p from ADC
-
displays it as current value
-
compares it with set value
-
if found
greater rotates motor clockwise for 1 rotation
-
if found smaller rotates motor anticlockwise for 1 rotation
-
again sends write pulse for next conversion
last is
main
function that initializes all ports, then LCD and then first displays set value.
then it sends write pulse and wait for an interrupt.
click here
for complete program