solar tracker controller


Results 1 to 40 of 42

Threaded View

  1. #1
    CIRE's Avatar
    CIRE Guest

    Smile solar tracker controller

    hello to all in the forum!
    I'm new here in the forum and starter in this picbasic programming. please anyone could help me to rewrite this code.
    I just added this two lines to the original code and it won't work.
    the portb.0 and portb.1 connected to the H bridge.
    Code:
    if PORTA.1 = 0 then face_east   'limit switch1 
    if PORTA.2 = 0 then hold     'limit switch2      
    
    ****************************************************
    
    @ DEVICE PIC16F84,WDT_ON,PWRT_ON,PROTECT_OFF
    INCLUDE "bs1defs.bas"
    
    start:
    low PORTB.0            'pin portb.0 low 
    low PORTB.1            'pin portb.1 low 
    Pot PORTB.2,255,b0        'read first cds sensor
    pot PORTB.3,255,b1        'read second cds sensor
    
    
    if b0 = b1 then start        'if equal do nothing
    if b0 > b1 then greater    'if greater, check how much greater
    if b0 < b1 then lesser    'if lesser, check how much lesser
    
    if PORTA.1 = 0 then face_east   'limit switch1
    if PORTA.2 = 0 then hold       'limit switch2
    
    greater:            'greater routine
    b2 = b0 - b1        'find the difference
    if b2 > 10 then cw        'is it within the range? if not go to clockwise/ solar panel facing west
    goto start            'if it is in the range,do it again
    
    lesser:                            'lesser routine
    b2 = b1 - b0                    'find the difference
    if b2 > 10 then ccw          'is it within the range? if not got counter clockwise/solar panel facing east
    goto start                   'if it is in the range, do it again
    
    cw:                          'turn the motor shaft clockwise / solar panel facing west
    high PORTB.0                 'pin portb.0 high / facing west
    pause 100                    'let it turn for the moment
    goto start                   'check again
    
    ccw:                         'turn the motor shaft counter clockwise/ solar panel facing east
    high PORTB.1                 'pin portb.1 high/ solar panel facing east
    pause 100                    'let it turn for the moment
    goto start                   'check again
    
    face_east:                   'facing east
    low PORTB.0                  'pin portb.0 low  /stopping the solar panel for moving
    low PORTB.1                  'pin portb.1 low  / stopping the solar panel for moving
    sleep 14400                  'wait for 4 hours 
    high PORTB.1                 'pin portb.1 high /solar panel back facing east ready for next day sun shine
    sound PORTB.4,[124,12000]    'tone
    pause 1000                   'wait for 1 sec
    goto start                   'check again
    
    hold:                        '
    low PORTB.0                  'pin portb,0 low / stopping the solar panel for moving
    low PORTB.1                  'pin portb.1 low / ----- do ----
    sleep 3600                   'wait for 1 hour 
    goto start                   'check again
    end
    'Copied from pic microcontroller project book by John Iovine
    Last edited by ScaleRobotics; - 1st March 2011 at 16:18. 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 : 0

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