solar tracker controller


Results 1 to 40 of 42

Threaded View

  1. #11
    Join Date
    Mar 2011
    Posts
    6


    Did you find this post helpful? Yes | No

    Smile Re: solar tracker controller

    hello
    can anyone check my proramming
    i am doing the same project.....

    solar tracker
    pic 16f877
    2cds with dc motor


    Code:
    v1 var byte                       'variable v1
    v2 var byte                       'variable v2
    v3 var byte                    'variable v3
    
    
    TRISA = 1                       'Set all PORTA pins as inputs
    TRISc = 0                     'Set all PORTc pins as outputs
    
    start:
    
    pot porta.0,255,v1             'Read 1st CdS Sensor (east)
    pot porta.1,255,v2            'Read 2nd CdS Sensor (west)
    
    if v1 <= 230 then skp        'start program
    if v2 > 230 then slp        'is it dark enough to sleep? (sleep mode)
    
    skp:
    if v1 = v2 then start        'If equal, do nothing
    if v1 > v2 then greater        'If greater, check how much greater
    if v1 < v2 then lesser        'If lesser, check how much lesser
    
    greater:                    'Greater routine
    v3 = v1 - v2                  'Find the difference
    if v3 > 10 then cw             'Is it within range? If not, go to cw
    goto start                    'In range do again
    
    lesser:                        'Lesser routine
    v3 = v2 - v1                'Find the difference
    if v3 > 10 then ccw            'Is it within range? If not, go to ccw
    goto start                    'Do again
    
    slp:
    low portc.0                       'stopping the solar tracker for moving 
    low portc.1                    'stopping the solar tracker for moving
    goto start 
    
    cw:                            'Turn the sensor array clockwise
    high portc.o                  'Turn on h-bridge
    pause 100                     'Let it turn for a moment
    goto start                    'Check again
    
    ccw:                         'Turn the sensor array counter clockwise
    high portc.1                   'Turn on h-bridge
    pause 100                     'Let it turn a moment
    goto start                    'Check again
    
    end
    Last edited by ScaleRobotics; - 1st March 2011 at 16:19. Reason: added code tags

Similar Threads

  1. Microstepper controller
    By aratti in forum Schematics
    Replies: 14
    Last Post: - 3rd January 2015, 16:52
  2. Replies: 14
    Last Post: - 6th March 2011, 05:08
  3. Replies: 2
    Last Post: - 14th July 2008, 22:11
  4. Fridge controller
    By nomad in forum General
    Replies: 4
    Last Post: - 23rd February 2008, 07:13
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts