Shop OBEX P1 Docs P2 Docs Learn Events
Timing — Parallax Forums

Timing

calebcl34calebcl34 Posts: 2
edited 2009-01-08 16:40 in BASIC Stamp
Currently in Engineering class I am making a solar tracker, which finds the spot where it can obtain the most amount of solar energy by using a photoresistor, and follows the sun until the sun goes down. My problem is that my program only lets my solar panel spin one direction. Does anyone have a program that would make it so once it reaches a certain time limit set, such as 6 hours, it turns back the other direction? If I leave it the way it is, the wires I have that are connected to the Board of Education will wrap around the post I have holding the solar panel up and screw it up. Help me please!

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2009-01-08 16:01
    One method is to follow the sun all day, then at midnight, cycle back to the very beginning and wait for the sun to come up.

    Or, if the photoresistor has a very high value when it gets dark (compared to any time it's daylight), use that value to trigger the runback. This assumes of course that your motor can run in both directions. Maybe get the light-sensing system to slide under a cover as the system gets to the 'late-day' postion.

    If you have to add a clock, it also gives you the opportunity to have the system detect long periods of cloud cover and 'bump' the system along so it will be in approximately the right position when the sun comes out again.

    Without a clock, 6 hours can be timed this way:

    Create a subroutine that takes 15 seconds to complete. Perhaps several PAUSE statements.
    From the main program, goto the subroutine then return.
    Count how many times you go to the subroutine.
    When the count reaches 1440, you've timed 6 hours.

    If you need your main program to do things faster than every 15 seconds, just make the subroutine shorter and count more of them.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • calebcl34calebcl34 Posts: 2
    edited 2009-01-08 16:06
    Alright great, thanks so much for your help, i really appreciate it.

    Caleb
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-01-08 16:40
    Hi Caleb, it's also advisable where there is a likelihood of damage to your equipment to place a limit switch at each extreme to prevent overtravel.

    Jeff T.
Sign In or Register to comment.