Search
Enter Keywords:
Thursday, 09 September 2010
Home arrow Projects arrow PIC arrow Aquarium Fan Controller
Newsflash

A fresh new Website has been setup exclusively for my DIY projects, Electronics experiments , Analog Synthesizer repair and Modular Synthesizer design. Vintage IC' s shop has moved as well .

Alll other music stuff remains on csabazvekan.com


In order to see resources you need to be logged in as a registered user. Registration takes seconds and is free !

 
Aquarium Fan Controller Print E-mail
Written by Administrator   
Saturday, 07 June 2008

This is a small Aquarium Fan controller. For 12 - 16Volt Fans .The ones that you have in your PC and other power supply. Do not hook up Mains power.

I do not take responsibility if you hook up 110V or 220v AC Mains. So please don't even try. It will blow the little relay and might kill you !

 

 
 
'* Project name:
'     Aquathermostat
' * Copyright:
'     (c) Csaba, 2007.
' * Description:
'     This is a simple thermostat working with the DS18B20 on RA5
'      PORT C can switch any relay / fan etc.
' * Test configuration:
'     MCU:             PIC16F676
'     Dev.Board:       EasyPIC4 /Special Target board Aquathermostat
'     Project:         Microchip/AquariumThermostat
'     ICSP on board :  No
'     Oscillator:      INTRC_OSC _No Clockout, 4.000 MHz
'     Ext. Modules:    DS18x20 connected to RA5 pin.
'     SW:              mikroBasic
' * NOTES:
'     - Two wire LCD on RA0 CLK, RA1 DATA only if desired to view Temperature with LCD
'     - portA = pull-up
'     - portC = pull-up
'     - portE LEDs switch = Off
 
program aquathermostat
 
include TW_LCD
' Set TEMP_RESOLUTION to the corresponding resolution of your DS18x20 sensor:
'  18S20: 9  (default setting; can be 9,10,11,or 12)
'  18B20: 12
 
const TEMP_RESOLUTION as byte = 12
 
 
 
dim j as byte
dim temp as word
'dim temp1 as word
dim text as string[7]
dim temp_whole as byte
 
 
sub procedure Read_Temperature
 
 
dim temp_whole as byte
dim temp_fraction as word
dim temp2write as word
 
  Ow_Reset(PORTA,5)            ' Onewire reset signal
  Ow_Write(PORTA,5,0xCC)       ' Issue command SKIP_ROM
  Ow_Write(PORTA,5,0x44)       ' Issue command CONVERT_T
  Delay_us(120)
 
  Ow_Reset(PORTA,5)
  Ow_Write(PORTA,5,0xCC)       ' Issue command SKIP_ROM
  Ow_Write(PORTA,5,0xBE)       ' Issue command READ_SCRATCHPAD
  Delay_ms(400)
 
  j    = OW_Read(PORTA,5)      ' Get temperature LSB
  temp   = OW_Read(PORTA,5)    ' Get temperature MSB
  temp = temp << 8
  temp = temp + j              ' Form the 2byte variable
 
end sub
sub procedure Write_Temp(dim temp2write as word)
 
const
  RES_SHIFT as byte = TEMP_RESOLUTION - 8            ' depends on sensor's resolution
 
 
dim  temp_fraction as word
 
 
  if ((temp and 0x8000) > 0) then                    ' check if temperature is negative
    text[0] = "-"
    temp2write = (not temp2write) + 1
  end if
 
  temp_whole = temp2write >> RES_SHIFT               ' determine whole number
  if (temp_whole div 100) then
     text[0] = temp_whole div 100  + 48
  end if
 
  text[1] =(temp_whole div 10) mod 10 + 48           ' prepare temp_whole for LCD
  text[2] = temp_whole mod 10 + 48
 
  temp_fraction = temp2write << (4-RES_SHIFT)        ' determine fraction
  temp_fraction = temp_fraction and 0x000F
  temp_fraction = temp_fraction * 625
 
  text[4] =  temp_fraction div 1000 + 48             ' prepare temp_fraction for LCD
  text[5] = (temp_fraction div 100) mod 10 + 48
  text[6] = (temp_fraction div 10)  mod 10 + 48
  text[7] =  temp_fraction mod 10 + 48
 
  TW_Lcd_Out(2,1,text)                                  ' display temperature
end sub
 
 
 
' ----Main----
main:
 
'--- Configure RA5 pin as digital I/O
  OSCCAL = $00                'slowest OSCI calibration
  CMCON = 0
  ADCON0 = 0
  ADCON1 = 0
 
  '--- PORTA is input
  PORTA  = %00100000
  TRISA  = %00100000
  PORTC  = 0                   ' clear all PORTC
  TRISC  = 0                   ' set Port C to Output
  TW_LCD_Init()                ' Two Wire LCD Init
  TW_LCD_CMD(LCD_Clear)
  TW_LCD_Out(1,1,"Temperature")
  text="+00.000"
  Read_Temperature()
  delay_ms(200)
  while true
 
      Read_Temperature()
      Write_Temp(temp)
      TW_LCD_Out(2,9,"       ")
      TW_LCD_OUT(2,1,text)
 
      if temp_whole > 26 then PORTC = %00011111 'turn on what ever if temp greater than 27
      else PORTC = %00100000
      end if
 
      Delay_ms(1000)
 
  wend
end.
 
Last Updated ( Wednesday, 25 June 2008 )
 
Main Menu
Home
Forum
Joomla! License
News
Blog
Links
Contact Us
Search
News Feeds
FAQs
Wrapper
Downloads
Shop
Projects
Games
OS Tips & Tricks
Sponsored Links
Joomla! Home
Joomla! Forums
OSM Home
Administrator
© 2010 The Csaba DIY and Electronic Site
Joomla! is Free Software released under the GNU/GPL License.