Development of microcontroller-based solar tracking system by using LDR sensor

Discussion in 'The Projects Forum' started by Cindy Tay Xin Yi, May 24, 2016.

  1. Cindy Tay Xin Yi

    Thread Starter New Member

    May 24, 2016
    3
    0
    hello, may anyone one help me, i;m stuck with my project.
    I need to develop a solar tracking system which using LDR sensor and the light is by using touch light and exposed to the sensor so that the stepper motor can move.
    I don't know how to write the source code that related with LDR sensor n stepper motor. I use PIC 16F877A microcontroller.

    The ADC converts these analog signals to digital form. The digitally converted signals are then compared by the L293D motor driver and the stepper motor is rotated accordingly.

    When LDR1 has higher light intensity than LDR2 then the resistance of LDR1 was smaller than that of LDR2 and the stepper motor rotates the solar panel in the counter clockwise direction.

    When LDR2 has higher light intensity than LDR1 then the resistance of LDR1 was larger than that of LDR2 and the stepper motor will rotates the solar panel in the clockwise direction.

    Please help me about the coding...I'm using MPLAB software with Hi-Tech compiler.
     
  2. Cindy Tay Xin Yi

    Thread Starter New Member

    May 24, 2016
    3
    0
    new circuit diagram.JPG
    This is my circuit diagram
     
  3. dannyf

    Well-Known Member

    Sep 13, 2015
    1,767
    357
    Just so you know, something like this can be done with a 555 timer too.
     
  4. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,671
    899
    Have you considered using a servo (hobby type) rather than stepper to balance the intensities of the two LDR's? If not, why not? Servos have the advantage of working relative to a fixed position. As for mechanical design, do you have a way to cast a shadow to facilitate lining the LDR's up with the sun (see: gnomon)?

    John
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    The position of the sun in the sky is not a random event. It is quite predictable. Mariners have used this fact for hundreds of years to locate where they are when floating in the middle of an ocean.

    However, the position of the brightest piece of the sky is a quite random event due to the effect of cloud cover and the like.

    Thus it is best to toss away the light sensors and use a prediction of where the sun will be at a given time.

    Oh, and something no one has ever told me: have you done the analysis showing the power consumed by the controller and motors is less than the added efficiency of moving the panels? Have you added in the risk of damage due to wind by not firmly bolting this thing down?

    As a academic exercise you may want to complete the task. Break It into smaller pieces. Learn how to read an analog input. Learn how to control the stepper motor. Then pairing them up should be a very simple task.

    You WILL want to program the pic in circuit, and using an in circuit debugger will be very useful. Go look those up. You will need to add a resistos (10k works well) between MCLR and power, and also free up RB6 and RB7.

    All those unused pins and you used the ones best suited to help you get this done. Oh well... This is still a paper design, right?
     
  6. Cindy Tay Xin Yi

    Thread Starter New Member

    May 24, 2016
    3
    0
    Yes...But for now i just using touch light represent the sun light...I dont know how to write the code in C language on MPLAB...When the touch light exposed to the LDR sensor then the motor will rotate..May u help me on the source code? Thanks very much...
     
  7. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Sorry, you will have to learn how to code yourself, or hire a consultant.

    We could point to some tutorials if you wish. Sorry my links are on another computer today.

    I almost missed mentioning welcome to the forums!
     
  8. dannyf

    Well-Known Member

    Sep 13, 2015
    1,767
    357
    maybe this project will motivate you to learn to code?
     
Loading...