Hybrid Car – More Fun with Less Gas

Simple solar garage door controller? - Page 2

register ::  Login Password  :: Lost Password?
Posted by nicksanspam on December 18, 2004, 8:24 pm
 


I was hoping for this winter :-)

Nick


Posted by Charles Beener on December 20, 2004, 2:51 am
 
nicksanspam@ece.villanova.edu wrote:

    I would use a 16F84A Microchip and use the temperature sensor DS18B10
   1-wire digital temperature sensor they run around $.50 each and you
could connect up to 20 or so if need be to the same two wires. here is
the code for that.I didn't declare any variables in the source code but
that should get you started. The 16F84A has 12 bits of I/O EPROM  and
Ram build in.  It cost $ it can be programmed with you serial port and
a few other part. the Assembler is MPLAB it will produce the Hex code
to program the PIC. It is free from them. It has a great debugger in it
also. To open and close the door have the Pic drive a Dip Relay . They
only take about 5ma. to operate.



            LIST PF84A           ;  16F84A Runs at 4 MHz
            INCLUDE "p16f84a.inc"
            __CONFIG _PWRTE_ON & _XT_OSC & _WDT_OFF  ; uses 10 MHz crystal
            ERRORLEVEL -224        ;  supress annoying message from tris
            ERRORLEVEL -302        ;  supress message from page change
;-----------------------------------------------------------------

;  declar any varables needed

;---------------------------------------------------------------
     org 0

;--------------------------------------------------------------

Main:
      call Init               ; initialize ports, set up timer

     CALL   INITDS1820        ; init DS1820
      MOVLW  0CCH              ; skip ROM
      MOVWF  O_BYTE
      CALL   OUT_BYTE

     movlw    4EH                ; WRITE SCRACH PAD SETUP FOR 9 BIT TEMPERATURE
      MOVWF  O_BYTE
      CALL   OUT_BYTE
     movlw    0H
      MOVWF  O_BYTE
      CALL   OUT_BYTE
     movlw    0H
      MOVWF  O_BYTE
      CALL   OUT_BYTE
     movlw    1FH        :9 BIT TEMPERATURE  IS 1FH 12 BIT 7F
      MOVWF  O_BYTE
      CALL   OUT_BYTE

      CALL   INITDS1820        ; init DS1820
      MOVLW  0CCH              ; skip ROM
      MOVWF  O_BYTE
      CALL   OUT_BYTE

     movlw    48H
      MOVWF  O_BYTE
      CALL   OUT_BYTE

     BCF    PORTB,7
     MOVLW    D'10'
      call   nmsec

   CALL   INITDS1820        ; init DS1820

      MOVLW  0CCH              ; skip ROM
      MOVWF  O_BYTE
      CALL   OUT_BYTE

      MOVLW  44H               ; perform temperature conversion
      MOVWF  O_BYTE
      CALL   OUT_BYTE

     BCF    PORTB,7

     MOVLW    D'95'
      call   nmsec                  ;  Wait 95 msecs before Reset

     BSF    PORTB,7

      CALL   WAIT              ; wait for conversion to complete
                ; wait for all ones from 1820

      CALL   INITDS1820

      MOVLW  0CCH              ; skip ROM
      MOVWF  O_BYTE
      CALL   OUT_BYTE

      MOVLW  0BEH              ; read scratchpad
      MOVWF  O_BYTE
      CALL   OUT_BYTE
      CALL   IN_BYTE            ; get from DS1820 and save
      movwf  TEMP_LSB
      CALL   IN_BYTE
      movwf  TEMP_MSB
     RRF    TEMP_MSB,F
        RRF    TEMP_LSB,F
     BCF    STATUS,C    
     RRF    TEMP_MSB,F
        RRF    TEMP_LSB,F
     BCF    STATUS,C


; the W registor has to Deg C in it. in the TEMP_LSB  varable

    goto  Main

;----------------------------------------------------------------------;
;                       Initialize the ports                           ;
;----------------------------------------------------------------------;
Init:
             clrf   PORTA
             clrf   PORTB

             movlw B'00011011'          ; RA4- RA4 input, others outputs
             tris   PORTA
             movlw B'00000000'          ; RB6, RB7 input, others outputs
             tris   PORTB
             return
;----------------------------------------------------------------------;
;----------------------------------------------------------------------
; The following are standard 1-Wire routines.
;----------------------------------------------------------------------
INITDS1820:
      CALL   PIN_HI
      CALL   PIN_LO

      MOVLW     50              ; 500 us delay
      CALL DELAY_10USEC

      CALL PIN_HI
      MOVLW  50       ; 500 usec delay
      CALL DELAY_10USEC

      RETURN
;----------------------------------------------------------------------
;----------------------------------------------------------------------
IN_BYTE:                   ; returns byte in W
      MOVLW  8
      MOVWF  INDEX
      CLRF   I_BYTE
IN_BYTE_1:
      CALL PIN_LO         ; momentary low on DATA_PIN
      NOP
      NOP
      NOP

      CALL PIN_HI
      NOP
      NOP
      NOP
      NOP
      NOP
      NOP
      NOP
      MOVF   PORTA, W          ; 7 usecs later, fetch from DATA_PIN
      MOVWF  TEMP
      BTFSS  TEMP, 3
      BCF    STATUS, C       ; its a zero
      BTFSC  TEMP, 3
      BSF    STATUS, C       ; its a one

      RRF    I_BYTE, F

      MOVLW  5              ; now delay 60 usecs
      CALL   DELAY_10USEC
      DECFSZ INDEX, F
      GOTO   IN_BYTE_1

      MOVFW  I_BYTE         ; return the result in W
      RETURN

;----------------------------------------------------------------------
OUT_BYTE:
      MOVLW  8
      MOVWF  INDEX
OUT_BYTE_1:
      RRF    O_BYTE, F
      BTFSS  STATUS, C
      GOTO   OUT_0
      GOTO   OUT_1
OUT_BYTE_2:
      DECFSZ    INDEX, F
      GOTO   OUT_BYTE_1
      RETURN
OUT_0:
      CALL   PIN_LO             ; bring DATA_PIN low
      MOVLW  6                    ; for 60 usecs
      CALL   DELAY_10USEC
      CALL   PIN_HI
      GOTO   OUT_BYTE_2
OUT_1:
      CALL PIN_LO             ; momentary low
      CALL   PIN_HI
      MOVLW 6
      CALL DELAY_10USEC
      GOTO   OUT_BYTE_2

;----------------------------------------------------------------------

PIN_HI:
      BSF  STATUS, RP0
      BSF  TRISA, DATA_PIN       ; high impedance
      BCF  STATUS, RP0
      RETURN

;----------------------------------------------------------------------
PIN_LO:
      BCF  PORTA, DATA_PIN
      BSF  STATUS, RP0
      BCF  TRISA, DATA_PIN       ; low impedance zero
      BCF  STATUS, RP0
      RETURN

;----------------------------------------------------------------------

;----------------------------------------------------------------------
; read the DS2423
DS2423
;do a reset to DS2423
      CALL   PIN_HI
      CALL   PIN_LO
      MOVLW     50              ; 500 us delay
      CALL DELAY_10USEC
      CALL PIN_HI
      MOVLW  50       ; 500 usec delay
      CALL DELAY_10USEC

      MOVLW  0CCH              ; skip ROM
      MOVWF  O_BYTE
      CALL   OUT_BYTE
      MOVLW  0A5H              ; read scratchpad
      MOVWF  O_BYTE
      CALL   OUT_BYTE
      MOVLW  0C0H              ; read scratchpad
      MOVWF  O_BYTE
      CALL   OUT_BYTE
      MOVLW  001H              ; read scratchpad
      MOVWF  O_BYTE
      CALL   OUT_BYTE
     movlw    D'32'
     movwf    temp2
loopmenory
      CALL   IN_BYTE
      DECFSZ  temp2,F
     goto    loopmenory
      CALL   IN_BYTE
     movwf    count1
      CALL   IN_BYTE
     movwf    count2
      CALL   IN_BYTE
     movwf    count3
      CALL   IN_BYTE
     movwf    count4
     return

;-----------------------------------------------------------
;----------------------------------------------------------------------
DELAY_2500uSEC
     movlw  d'250'
DELAY_10USEC:  ; provides a delay equal to W * 10 usecs
      MOVWF LOOP1
DELAY_10USEC_1:
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    DECFSZ LOOP1, F
    GOTO DELAY_10USEC_1
    RETURN


        This some of the code I just done last week . I'm making a weather
station with one those PIC.

            Enjoy  Charles

Posted by nicksanspam# on December 20, 2004, 4:02 am
 

Thanks! How much, and when can you deliver it?

Nick


Posted by Charles Beener on December 20, 2004, 4:08 am
 nicksanspam#@ece.villanova.edu wrote:

If you reallllllllly need it Nick I could do it . But I really need more
info on the project.  What kind of user interface ? LCD 1 to 4 line
display with keyboard ? A PC serial interface ? If so ? what do you want
on .

      As they say MORE INPUT NEED MORE INPUT.
    Your a person with a good head . You should be able to do this
project in less than a week after you get the parts . RIGHT ?

        Charles
the options and what do you want it to look like ?

Posted by nicksanspam on December 20, 2004, 7:20 pm
 

Great :-) Thank you Charles!


Both :-)


It would automatically open a garage door with an existing electric opener
when the sun shines and close the door at night. The door would have clear
polycarbonate over the outside frame. We need a sun sensor (eg a thermostat
in a glass box) and an open-or-closed door position sensor (eg a reed switch
with a magnet) and a relay output that can short the garage door opener
button for 1 second (to simulate pushing the button.)

Later, we might want to turn on an exhaust fan to keep the garage from
overheating, and maybe turn on the fan at night in summertime for cooling,
when the outdoor temp is less than the indoor temp, and maybe turn on
the fan in spring and fall for heating when the outdoor temp is greater
than the indoor temp and the dew point of the outdoor air (as measured
with a humidity sensor) is greater than the indoor surface temps (to avoid
condensation on those surfaces.) Onset (www.onsetcomp.com) sells a $2.31
SHT75 12 bit digital combined RH and temp sensor intended for dew point
calculations.

The last function could be valuable to many homeowners in controlling
a whole house fan vs an AC or furnace when weather conditions are suitable.
Liz Robinson of the Philadelphia Energy Coordinating Agency and professor
Murray Milne at UCLA and Jeff Christian at Oak Ridge would love to get
their hands on a box like this. Lots of people could use it for cooling
and heating and energy-efficient dehumidification. In the Southwest, it
might control an indoor mister as well as the fan for evaporative cooling.

I would like to program it in BASIC (the dew point calculation could use
a logarithm function) and end up with a standalone box with a power supply
and a 4 character display and a keypad. I don't know much about PICs, but
I have the impression it could be a 16F77 or 16F877A.


Maybe a month :-) But I'd rather do incidence angle calculations for
evacuated tube collectors or help people solar heat houses.

Thanks again,

Nick


This Thread
Bookmark this thread:
 
 
 
 
 
 
  •  
  • Subject
  • Author
  • Date
please rate this thread