تبلیغات
الکترونیک و کامپیوتر - مطالب شهریور 1391
منوی اصلی
الکترونیک و کامپیوتر
اخبار، سرگرمی، نرم افزار
  • یکشنبه 26 شهریور 1391 05:10 ب.ظ نظرات ()

     

    ' *****************************************************************************

    ' *

    ' * Title         : PRG

    ' * Version       : 1.0

    ' * Last Updated :  2011

    ' * Target        : Atmega16

    ' * Author        : I-SEDIGHI

    ' * Program code  : BASCOM AVR

    ' * Description

    ' *

    ' *****************************************************************************

    $regfile = "m16def.dat"

    $crystal = 1000000

      Config Portd = Output

     

     

      Dim Portd.0 As Byte

      Dim Portd.1 As Byte

      Dim Portd.2 As Byte

      Dim Portd.3 As Byte

      Dim Portd.4 As Byte

      Dim Portd.5 As Byte

      Dim Portd.6 As Byte

      Dim Portd.7 As Byte

     

    Do

    Ddrd.0 = 1

    Ddrd.1 = 1

    Ddrd.2 = 1

    Ddrd.3 = 1

    Ddrd.4 = 1

    Ddrd.5 = 1

    Ddrd.6 = 1

    Ddrd.7 = 1

     

    Portd.0 = 0

    Portd.1 = 0

    Portd.2 = 0

    Portd.3 = 0

    Portd.4 = 0

    Portd.5 = 0

    Portd.6 = 0

    Portd.7 = 0

     

    Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Down , Prescale = 1

    Pwm1a = 800

    Pwm1b = 500

     

     

    Incr Pwm1a                                                  '= A

    Incr Pwm1b                                                  ' 255= B

     

     

    Pwm1a = Pwm1a + 100

    Set Portd.1

    Waitms 1

     

     

    Loop

    End

    آخرین ویرایش: - -
    ارسال دیدگاه
  • یکشنبه 26 شهریور 1391 05:08 ب.ظ نظرات ()

    $regfile = "m8def.dat"

    'We use internal osc 1000000 for atmega32

    $crystal = 1000000

    Config Lcdpin = Pin , Db7 = Pb.7 , Db6 = Pb.6 , Db5 = Pb.5 , Db4 = Pb.4 , Rs = Pb.2 , E = Pb.3

    Config Lcd = 16 * 2

    Config Adc = Single , Prescaler = Auto

    Start Adc

    Config Timer0 = Timer , Prescale = 1024

    Config Portd.0 = Output

    Enable Interrupts

    Enable Timer0

    On Timer0 Temp_sample

    Start Timer0

    Dim Sample As Word

    Dim W As Byte

    Dim Temp As Word

    Dim Portd.0 As Byte

    Dim Temp_final As Integer

    Dim Sum As Integer

    Deflcdchar 0 , 24 , 24 , 32 , 32 , 32 , 32 , 32 , 32        '' sign -> (')

    Cursor Off

    Cls

     

    Home L

    Lcd "iman sedighi"

    Do

    Pinc.1 = 0

    Portd.0 = 0

    If Pinc.1 = 0 Then Portd.0 = 1

    Loop

    End                                                         'end program

     

    Temp_sample:

    Incr Sample                                                 'incr sampling counter

    Temp = Getadc(0)                                            'read adc(0) every 65ms

    Sum = Sum + Temp                                            'sum the sample data

    If Sample = 15 Then                                         '20 samples

       Sample = 0                                               'reset sample counter

       Stop Timer0                                              'stop timer to calculation

       Sum = Sum / 15                                           'mean calculation

       Sum = Sum - 558                                          'decrementing offset

       Temp_final = Sum / 2                                     'every 10mv is almost 2 step of adc (adc step=5/1023=4.88mv)

       Select Case Temp_final

          Case Is =< 10 :                                       'compare temperature

             Home L

             Lcd " Low  "

          Case 11 To 34 :                                       'compare temperature

             Home L

             Lcd "Normal"

            Waitms 500

     

          Case Is >= 35 :                                       'compare temperature

             Home L

             Lcd " High  "

             Waitms 500

            

       End Select

     

       Home

       Lcd Temp_final ; Chr(0) ; "C    "                        'show temperature

       Start Timer0

       Sum = 0

    End If

     

    Return

    آخرین ویرایش: - -
    ارسال دیدگاه
  • جمعه 3 شهریور 1391 10:03 ب.ظ نظرات ()
    آخرین ویرایش: سه شنبه 16 آبان 1391 01:46 ب.ظ
    ارسال دیدگاه