• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

hi... required help from yu guyz.....

Thread starter #1
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.
 
#2
Hi,

sorry, I am weak in C programming (for last 4 years, I am doing assembly programming), so can't help you in C coding.

But I would suggest you to remove ADC.

I have implemented this project last year.
I have used 4 LDRs, 2 for east west (for daily rotation) and 2 for north south (in a whole year)
I have used 4 comparators. so if comparator of east is giving high and compartor of west is giving low then move motor to west. and vice versa

see if you can use this logic.
 

EE World Online Articles

Loading

 
Top