Hi all of you..
I am doing a project on solar tracker. For this I am using 2 photo transistors on either side of the solar panel. The light intensity falling on the photo transistors are given to ADC and then given to micro controller (AT89S52). The program has to compare the values of the photo transistors and then depending upon this the micro controller will control the stepper motor's movement to either clockwise or anti- clockwise. The motor has to stop in case if both the values are equal.
Heres the program i have written, but its kinda not working. Also i need to check for the photo transistors values for every 15 minutes. And the motor has to rotate only once and stop, I mean for a particular degree of rotation. So if you could please check it and let me know, it would be of great help.. Thank you...
#include <reg51.h>
sbit READ_1 = P0^0;
sbit WRITE_1 = P0^1;
sbit INTR_1 = P0^2;
sbit READ_2 = P0^4;
sbit WRITE_2 = P0^5;
sbit INTR_2 = P0^6;
#define MYDATA_1 P1
#define MYDATA_2 P3
#define Stepper_motor P2
void main(void)
{
unsigned char value_1,value_2;
MYDATA_1 = 0xFF;
MYDATA_2 = 0xFF;
INTR_1 = 1;
INTR_2 = 1;
READ_1 = 1;
READ_2 = 1;
WRITE_1 = 1;
WRITE_2= 1;
while(1)
{
WRITE_1 = 0;
WRITE_2 = 0;
WRITE_1 = 1;
WRITE_2 = 1;
while(INTR_1 == 1);
while(INTR_2 == 1);
READ_1 = 0;
READ_2 = 0;
value_1 = MYDATA_1;
value_2 = MYDATA_2;
if ( value_1 == value_2 )
{
Stepper_motor = 0;
}
else if ( value_1 < value_2 )
{
stepper = 0x0C;
delay();
stepper = 0x06;
delay();
stepper = 0x03;
delay();
stepper = 0x09;
delay();
}
else if
{
stepper = 0x09;
delay();
stepper = 0x03;
delay();
stepper = 0x06;
delay();
stepper = 0x0C;
delay();
}
READ_1 = 1;
READ_2 = 1;
}
}
With Regards,
Thank you.
I am doing a project on solar tracker. For this I am using 2 photo transistors on either side of the solar panel. The light intensity falling on the photo transistors are given to ADC and then given to micro controller (AT89S52). The program has to compare the values of the photo transistors and then depending upon this the micro controller will control the stepper motor's movement to either clockwise or anti- clockwise. The motor has to stop in case if both the values are equal.
Heres the program i have written, but its kinda not working. Also i need to check for the photo transistors values for every 15 minutes. And the motor has to rotate only once and stop, I mean for a particular degree of rotation. So if you could please check it and let me know, it would be of great help.. Thank you...
#include <reg51.h>
sbit READ_1 = P0^0;
sbit WRITE_1 = P0^1;
sbit INTR_1 = P0^2;
sbit READ_2 = P0^4;
sbit WRITE_2 = P0^5;
sbit INTR_2 = P0^6;
#define MYDATA_1 P1
#define MYDATA_2 P3
#define Stepper_motor P2
void main(void)
{
unsigned char value_1,value_2;
MYDATA_1 = 0xFF;
MYDATA_2 = 0xFF;
INTR_1 = 1;
INTR_2 = 1;
READ_1 = 1;
READ_2 = 1;
WRITE_1 = 1;
WRITE_2= 1;
while(1)
{
WRITE_1 = 0;
WRITE_2 = 0;
WRITE_1 = 1;
WRITE_2 = 1;
while(INTR_1 == 1);
while(INTR_2 == 1);
READ_1 = 0;
READ_2 = 0;
value_1 = MYDATA_1;
value_2 = MYDATA_2;
if ( value_1 == value_2 )
{
Stepper_motor = 0;
}
else if ( value_1 < value_2 )
{
stepper = 0x0C;
delay();
stepper = 0x06;
delay();
stepper = 0x03;
delay();
stepper = 0x09;
delay();
}
else if
{
stepper = 0x09;
delay();
stepper = 0x03;
delay();
stepper = 0x06;
delay();
stepper = 0x0C;
delay();
}
READ_1 = 1;
READ_2 = 1;
}
}
With Regards,
Thank you.