سلام. من یه کد نوشته بودم که تو یه بخشش از ساعت ds1307 استفاده کردم. همه چیز اوکی بود تا زمانی چند روز پیش که یهو دیدم میکرو قفل میکنه . دقت که کردم متوجه شدم به محض اینکه ساعت فراخونی میشه میکرو قفل میشه و بیخیال بقیه داستان میشه .
کریستال رو عوض کردم و آی سی رو هم عوض کردم.
مقاومت های پول آپ روی پایه های دیتا هم 4.7 کیلو هستش. البته اینو بگم که قبلا اشتباهی 47 کیلو گذاشته بودم ولی کار میکرد. با این وجود خراب که شد عوضش کردم.
خازن 100 نانو رو هم اسمبل نکرده بودم. اینم دو سه روز قبل از این که خراب بشه اسمبل کردم روش که نتیجه معکوس داشت و الانم درش اوردم
الان بیشتر شک کردم که پایه های میکرو خراب شده باشن.
دلیل: ادغام دو پست برای جلوگیری از اسپم
راستی باتریشم 3 ولت اوکیه و تغذیه اش هم 5 ولته
دلیل: ادغام دو پست برای جلوگیری از اسپم
اینم کدش قسمت rtc
$regfile = "m2560def.dat"
$crystal = 8000000
$baud = 9600 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ###############################
'------------------------ lcd -----------------------------------------------
Config Lcd = 20 * 4
Config Lcdpin = Pin , Rs = Pinc.5 , E = Pinc.4 , Db4 = Pinc.3 , Db5 = Pinc.2 , Db6 = Pinc.1 , Db7 = Pinc.0
Cls
Lcd "hellow"
Deflcdchar 0 , 32 , 8 , 4 , 2 , 31 , 2 , 4 , 8 ' replace [--->] with number (0-7)
Deflcdchar 1 , 4 , 14 , 21 , 4 , 4 , 4 , 4 , 4 ' replace [^] with number (0-7) felashe ro be bala
Deflcdchar 2 , 4 , 4 , 4 , 4 , 4 , 21 , 14 , 4 ' replace [\/] with number (0-7)felashe ro be paeen
Deflcdchar 3 , 32 , 32 , 32 , 32 , 1 , 2 , 20 , 8 ' replace [Tik] with number (0-7)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------interrups-------------------
Enable Interrupts
Enable Int5
Config Int5 = Falling
On Int5 Gsmint
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------com port -----------------
Open "comh.1:9600,8,n,1" For Output As #1
Open "come.1:9600,8,n,1" For Input As #2
'Config Com1 = 9600 , Parity = None , Stopbits = 1 , Databits = 8
'Open "com1:" For Binary As #1
'Enable Urxc
On Urxc Check_card
Enable Interrupts
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------I2C port -----------------
Config Sda = Portd.1
Config Scl = Portd.0
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------Display Board pin configuration-------------------
Motor1_s Alias Portj.6
Motor2_s Alias Portj.5
Motor3_s Alias Portj.4
Motor4_s Alias Portj.3
Motor5_s Alias Portj.2
Valv1_s Alias Portj.1
Valv2_s Alias Portj.0
Valv3_s Alias Portc.7
Valv4_s Alias Portc.6
''____________________________
Flows1_s Alias Porta.4
Flows2_s Alias Porta.5
Flows3_s Alias Porta.6
Flows4_s Alias Porta.7
Pw_r Alias Porta.3
Sens1_s Alias Porta.2
Sens2_s Alias Porta.1
Sens3_s Alias Porta.0
Sens4_s Alias Portk.7
''____________________________
Int_rfid Alias Int2
'Tx_rfid Alias
Key_a Alias Pind.4
Key_b Alias Pind.5
Key_c Alias Pind.6
Key_d Alias Pind.7
Key_r Alias Pine.4
Key_int Alias Int4
'#############################################
'-------------- Main Board pin configuration--------------------
Motor1 Alias Portl.0
Motor2 Alias Portl.1
Motor3 Alias Portl.2 '
Motor4 Alias Portl.3
Motor5 Alias Portl.4
'----------------------------------
Valv1 Alias Portl.5
Valv2 Alias Portl.6
Valv3 Alias Portl.7
Valv4 Alias Porte.3
'----------------------------------
Sens1 Alias Pinf.2
Sens2 Alias Pinf.3
Sens3 Alias Pinf.4
Sens4 Alias Pinf.5
Sens5 Alias Pinf.6
Sens6 Alias Pinf.7
Sens7 Alias Pink.0
Sens8 Alias Pink.1
Sens9 Alias Pink.2
Sens10 Alias Pink.3
Sens11 Alias Pink.4
Sens12 Alias Pink.5
Sens13 Alias Pink.6
'Sens14 Alias Pine.0
Sens15 Alias Pine.1
'_________________________________
Sim1_int Alias Int5
Pw_key Alias Porta.6
Flows_r Alias Pinh.3
Flows_l Alias Pinh.4
Flowm Alias Pinh.2
'################################################# ##############################
'_________________________ declare constants____________________________________
Const Key_up = 9 'esharegare ro be bala dar kepad
Const Key_down = 12 'esharegare ro be paeen dar kepad
Const Enter = 15 'adade kelide enter bar roye keypad
Const Mode_manual = 1 'adade mode manual bar roye keypad
Const Mode_gsm = 2 'adade mode gsm bar roye keypad
Const Mode_auto = 3 'adade mode automatic bar roye keypad
Const Key_setting = 14
Const Key_cancel = 10
Const Key_set = 0
'------------------------------------------------------------
'ds1307 config
Const Ds1307w = &HD0
Const Ds1307r = &HD1
'################################################# ##############################
'================================================= ==============================
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'_____________pin in/out configuration------------------------------------------
Config Porta = Output
Config Portc.6 = Output
Config Portc.7 = Output
Config Portd.4 = Input
Config Portd.5 = Input
Config Portd.6 = Input
Config Portd.7 = Input
'Config Porte.0 = Input
Config Porte.1 = Input
Config Porte.3 = Output
Config Porte.4 = Input
Porte.4 = 1
Config Porte.6 = Output
Config Portf = &B00000011
Config Porth.2 = Input
Config Porth.3 = Input
Config Porth.4 = Input
Config Portj = Output
Config Portk = Output
Config Portl = Output
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------------------DECLARE FUNCTIONS and sub rootines--------------------
Declare Sub Key_pad 'be dast avardane adade feshar dade shode dar keypad
Declare Sub Manual_mode ' zir barname mode dasti
Declare Sub Gsm_mode ' zir barname entekhabe mode payamaki(GSM)
Declare Sub Automatic_mode
Declare Sub Timer_mode_setting 'zir barname tanzime timerha
Declare Sub Timer_setting 'tanzimat har timer be sorate jodagane
Declare Sub Tanzime_zaman 'tanzim kardan saat baraye halate timer setting
Declare Sub Smart_mode 'zir barname halate smart
Declare Sub Smart_mode_sttings 'zir barname mode automatic
Declare Sub Mode_a_seting 'taghire tanzimate halate smart mode A
Declare Sub Mode_b_seting 'taghire tanzimate halate smart mode B
Declare Sub Mode_c_seting 'taghire tanzimate halate smart mode C
Declare Sub Mode_d_seting 'taghire tanzimate halate smart mode D
'----------------------------------------------------------------------------
'for sim800
Declare Sub Deleting
Declare Sub Gsm_action
'################################################# ##############################
'________________________declare variables______________________________________
Dim Key As Byte 'adde be dast amade dar keypad
Dim System_mode As Byte 'entekhabe halate(mode) amalkarde system
Dim Neshangar As Byte 'mahale gharar gereftane neshangare Mouse
Dim Time_motor1_on(8) As Byte 'zamanhaye roshan shodane motore 1
Dim Time_motor2_on(8) As Byte 'zamanhaye roshan shodane motore 2
Dim Time_motor3_on(8) As Byte 'zamanhaye roshan shodane motore 3
Dim Time_motor4_on(8) As Byte 'zamanhaye roshan shodane motore 4
Dim Time_motor5_on(8) As Byte 'zamanhaye roshan shodane motore 5
Dim Time_valv1_on(8) As Byte 'zamanhaye roshan shodane valve 1
Dim Time_valv2_on(8) As Byte 'zamanhaye roshan shodane valve 2
Dim Time_valv3_on(8) As Byte 'zamanhaye roshan shodane valve 3
Dim Time_valv4_on(8) As Byte 'zamanhaye roshan shodane valve 4
Dim Time_motor1_of(8) As Byte 'zamanhaye khamoosh shodane motore 1
Dim Time_motor2_of(8) As Byte 'zamanhaye khamoosh shodane motore 2
Dim Time_motor3_of(8) As Byte 'zamanhaye khamoosh shodane motore 3
Dim Time_motor4_of(8) As Byte 'zamanhaye khamoosh shodane motore 4
Dim Time_motor5_of(8) As Byte 'zamanhaye khamoosh shodane motore 5
Dim Time_valv1_of(8) As Byte 'zamanhaye khamoosh shodane valve 1
Dim Time_valv2_of(8) As Byte 'zamanhaye khamoosh shodane valve 2
Dim Time_valv3_of(8) As Byte 'zamanhaye khamoosh shodane valve 3
Dim Time_valv4_of(8) As Byte 'zamanhaye khamoosh shodane valve 4
Dim A3_state As Bit 'vaziat faal ya gheyre faal bodane sharte 3 dar mode A tavasote karbar
Dim Time_b1 As Integer 'taeen zamane baraye sharte 1 dar mode_b
Dim B2_state As Byte 'vaziate sharte B-2 dar mode smart
Dim B3_state As Byte 'vaziate sharte B-2 dar mode smart
Dim Timer_on_of As Bit 'entekhabe mode timer dar bakhshe tanzime zaman
Dim Daghighe As Byte 'entekhabe daghighe dar bakhsh tanzime zaman
Dim Saat As Byte 'entekhabe saat dar bakhshe tanzime zaman
Dim Valve_number As Byte 'entekhabe shomare valve dar bakhshe tanzime zaman
Dim Timer_number As Byte 'entekhabe shomare timer dar bakhshe tanzime zaman
Dim Show As Bit 'entekhabe nemayesh ya aadam nemayesh dar barname Main
Show = 1
Dim Smart_mode_state As Bit 'in moteghayer moshakhas mikonad dar halate automatic T smart faal bashad ya kheyr
Smart_mode_state = 0
B2_state = 4
B3_state = 8
'-------------------------------------------------------------------------------
'sim 800 dimension
Dim Uart_in(80) As Byte 'voroodi uart kham
Dim Sh_data_uart As Byte 'shomarande tedade dataye voroodi
Dim Aizan_shomar As Byte 'shomarande tedad aizanha
Dim Sh_soton As Byte 'tabdile adad be reshte
Dim Char As String * 1 'shomarande karaktere payame voroodi
Dim Sh_payam As Byte
Dim Sh_shir_payam_adad As Byte '
Dim Command_payam As String * 1
Dim Sh_shir_payam As String * 1
Dim Adad_string(9) As String * 1
Adad_string(1) = "1"
Adad_string(2) = "2"
Adad_string(3) = "3"
Adad_string(4) = "4"
Adad_string(5) = "5"
Adad_string(6) = "6"
Adad_string(7) = "7"
Adad_string(8) = "8"
Adad_string(9) = "9"
Sh_data_uart = 1
'----------------------------------------------------------------------------------
' ds1307 timer
Dim _sec As Byte
Dim _seci_1 As Byte
Dim _min As Byte
Dim _hour As Byte
Dim _year As Word
Dim Weekday As Byte
Dim M_day As Word
Dim M_month As Word
Dim M_year As Word
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'----------------------------Main Program---------------------------------------
_sec = 00
_min = 34
_hour = 12
Gosub Settime
Do
Gosub Read_date_time
If _sec <> _seci_1 Then
Locate 4 , 1
Lcd " "
Locate 4 , 1
Lcd "TIME: " ; _hour ; ":" ; _min ; ":" ; _sec ; " "
_seci_1 = _sec
End If
Loop
'=======================
Gsmint:
Return
End
Check_card:
Return
End
'=======================
'************************************************* ******************************
'****************************** ****************
'WWW.ISEEE.IR ***************** READ DATE AND TIME ****************
'****************************** ****************
'************************************************* ******************************
Read_date_time:
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' start address in 1307
I2cstart ' Generate start code
I2cwbyte Ds1307r ' send address
I2crbyte _sec , Ack
I2crbyte _min , Ack ' MINUTES
I2crbyte _hour , Ack ' Hours
I2crbyte Weekday , Ack ' Day of Week
I2crbyte M_day , Ack ' Day of Month
I2crbyte M_month , Ack ' Month of Year
I2crbyte _year , Nack ' Year
I2cstop
_sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
M_day = Makedec(m_day) : M_month = Makedec(m_month) : _year = Makedec(_year)
M_year = 2000 + _year
Return
'************************************************* ******************************
'****************************** ****************
'WWW.ISEEE.IR ***************** SET TIME ****************
'****************************** ****************
'************************************************* ******************************
Settime:
_sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
I2cstart
Cls : Lcd "1" ' Generate start code
I2cwbyte Ds1307w
Lcd "2" ' send address
I2cwbyte 0 ' starting address in 1307
I2cwbyte _sec ' Send Data to SECONDS
I2cwbyte _min ' MINUTES
I2cwbyte _hour
Lcd "3" ' Hours
I2cstop
Return
کریستال رو عوض کردم و آی سی رو هم عوض کردم.
مقاومت های پول آپ روی پایه های دیتا هم 4.7 کیلو هستش. البته اینو بگم که قبلا اشتباهی 47 کیلو گذاشته بودم ولی کار میکرد. با این وجود خراب که شد عوضش کردم.
خازن 100 نانو رو هم اسمبل نکرده بودم. اینم دو سه روز قبل از این که خراب بشه اسمبل کردم روش که نتیجه معکوس داشت و الانم درش اوردم

الان بیشتر شک کردم که پایه های میکرو خراب شده باشن.
دلیل: ادغام دو پست برای جلوگیری از اسپم
راستی باتریشم 3 ولت اوکیه و تغذیه اش هم 5 ولته
دلیل: ادغام دو پست برای جلوگیری از اسپم
اینم کدش قسمت rtc
$regfile = "m2560def.dat"
$crystal = 8000000
$baud = 9600 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ###############################
'------------------------ lcd -----------------------------------------------
Config Lcd = 20 * 4
Config Lcdpin = Pin , Rs = Pinc.5 , E = Pinc.4 , Db4 = Pinc.3 , Db5 = Pinc.2 , Db6 = Pinc.1 , Db7 = Pinc.0
Cls
Lcd "hellow"
Deflcdchar 0 , 32 , 8 , 4 , 2 , 31 , 2 , 4 , 8 ' replace [--->] with number (0-7)
Deflcdchar 1 , 4 , 14 , 21 , 4 , 4 , 4 , 4 , 4 ' replace [^] with number (0-7) felashe ro be bala
Deflcdchar 2 , 4 , 4 , 4 , 4 , 4 , 21 , 14 , 4 ' replace [\/] with number (0-7)felashe ro be paeen
Deflcdchar 3 , 32 , 32 , 32 , 32 , 1 , 2 , 20 , 8 ' replace [Tik] with number (0-7)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------interrups-------------------
Enable Interrupts
Enable Int5
Config Int5 = Falling
On Int5 Gsmint
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------com port -----------------
Open "comh.1:9600,8,n,1" For Output As #1
Open "come.1:9600,8,n,1" For Input As #2
'Config Com1 = 9600 , Parity = None , Stopbits = 1 , Databits = 8
'Open "com1:" For Binary As #1
'Enable Urxc
On Urxc Check_card
Enable Interrupts
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------I2C port -----------------
Config Sda = Portd.1
Config Scl = Portd.0
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------Display Board pin configuration-------------------
Motor1_s Alias Portj.6
Motor2_s Alias Portj.5
Motor3_s Alias Portj.4
Motor4_s Alias Portj.3
Motor5_s Alias Portj.2
Valv1_s Alias Portj.1
Valv2_s Alias Portj.0
Valv3_s Alias Portc.7
Valv4_s Alias Portc.6
''____________________________
Flows1_s Alias Porta.4
Flows2_s Alias Porta.5
Flows3_s Alias Porta.6
Flows4_s Alias Porta.7
Pw_r Alias Porta.3
Sens1_s Alias Porta.2
Sens2_s Alias Porta.1
Sens3_s Alias Porta.0
Sens4_s Alias Portk.7
''____________________________
Int_rfid Alias Int2
'Tx_rfid Alias
Key_a Alias Pind.4
Key_b Alias Pind.5
Key_c Alias Pind.6
Key_d Alias Pind.7
Key_r Alias Pine.4
Key_int Alias Int4
'#############################################
'-------------- Main Board pin configuration--------------------
Motor1 Alias Portl.0
Motor2 Alias Portl.1
Motor3 Alias Portl.2 '
Motor4 Alias Portl.3
Motor5 Alias Portl.4
'----------------------------------
Valv1 Alias Portl.5
Valv2 Alias Portl.6
Valv3 Alias Portl.7
Valv4 Alias Porte.3
'----------------------------------
Sens1 Alias Pinf.2
Sens2 Alias Pinf.3
Sens3 Alias Pinf.4
Sens4 Alias Pinf.5
Sens5 Alias Pinf.6
Sens6 Alias Pinf.7
Sens7 Alias Pink.0
Sens8 Alias Pink.1
Sens9 Alias Pink.2
Sens10 Alias Pink.3
Sens11 Alias Pink.4
Sens12 Alias Pink.5
Sens13 Alias Pink.6
'Sens14 Alias Pine.0
Sens15 Alias Pine.1
'_________________________________
Sim1_int Alias Int5
Pw_key Alias Porta.6
Flows_r Alias Pinh.3
Flows_l Alias Pinh.4
Flowm Alias Pinh.2
'################################################# ##############################
'_________________________ declare constants____________________________________
Const Key_up = 9 'esharegare ro be bala dar kepad
Const Key_down = 12 'esharegare ro be paeen dar kepad
Const Enter = 15 'adade kelide enter bar roye keypad
Const Mode_manual = 1 'adade mode manual bar roye keypad
Const Mode_gsm = 2 'adade mode gsm bar roye keypad
Const Mode_auto = 3 'adade mode automatic bar roye keypad
Const Key_setting = 14
Const Key_cancel = 10
Const Key_set = 0
'------------------------------------------------------------
'ds1307 config
Const Ds1307w = &HD0
Const Ds1307r = &HD1
'################################################# ##############################
'================================================= ==============================
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'_____________pin in/out configuration------------------------------------------
Config Porta = Output
Config Portc.6 = Output
Config Portc.7 = Output
Config Portd.4 = Input
Config Portd.5 = Input
Config Portd.6 = Input
Config Portd.7 = Input
'Config Porte.0 = Input
Config Porte.1 = Input
Config Porte.3 = Output
Config Porte.4 = Input
Porte.4 = 1
Config Porte.6 = Output
Config Portf = &B00000011
Config Porth.2 = Input
Config Porth.3 = Input
Config Porth.4 = Input
Config Portj = Output
Config Portk = Output
Config Portl = Output
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'-------------------------DECLARE FUNCTIONS and sub rootines--------------------
Declare Sub Key_pad 'be dast avardane adade feshar dade shode dar keypad
Declare Sub Manual_mode ' zir barname mode dasti
Declare Sub Gsm_mode ' zir barname entekhabe mode payamaki(GSM)
Declare Sub Automatic_mode
Declare Sub Timer_mode_setting 'zir barname tanzime timerha
Declare Sub Timer_setting 'tanzimat har timer be sorate jodagane
Declare Sub Tanzime_zaman 'tanzim kardan saat baraye halate timer setting
Declare Sub Smart_mode 'zir barname halate smart
Declare Sub Smart_mode_sttings 'zir barname mode automatic
Declare Sub Mode_a_seting 'taghire tanzimate halate smart mode A
Declare Sub Mode_b_seting 'taghire tanzimate halate smart mode B
Declare Sub Mode_c_seting 'taghire tanzimate halate smart mode C
Declare Sub Mode_d_seting 'taghire tanzimate halate smart mode D
'----------------------------------------------------------------------------
'for sim800
Declare Sub Deleting
Declare Sub Gsm_action
'################################################# ##############################
'________________________declare variables______________________________________
Dim Key As Byte 'adde be dast amade dar keypad
Dim System_mode As Byte 'entekhabe halate(mode) amalkarde system
Dim Neshangar As Byte 'mahale gharar gereftane neshangare Mouse
Dim Time_motor1_on(8) As Byte 'zamanhaye roshan shodane motore 1
Dim Time_motor2_on(8) As Byte 'zamanhaye roshan shodane motore 2
Dim Time_motor3_on(8) As Byte 'zamanhaye roshan shodane motore 3
Dim Time_motor4_on(8) As Byte 'zamanhaye roshan shodane motore 4
Dim Time_motor5_on(8) As Byte 'zamanhaye roshan shodane motore 5
Dim Time_valv1_on(8) As Byte 'zamanhaye roshan shodane valve 1
Dim Time_valv2_on(8) As Byte 'zamanhaye roshan shodane valve 2
Dim Time_valv3_on(8) As Byte 'zamanhaye roshan shodane valve 3
Dim Time_valv4_on(8) As Byte 'zamanhaye roshan shodane valve 4
Dim Time_motor1_of(8) As Byte 'zamanhaye khamoosh shodane motore 1
Dim Time_motor2_of(8) As Byte 'zamanhaye khamoosh shodane motore 2
Dim Time_motor3_of(8) As Byte 'zamanhaye khamoosh shodane motore 3
Dim Time_motor4_of(8) As Byte 'zamanhaye khamoosh shodane motore 4
Dim Time_motor5_of(8) As Byte 'zamanhaye khamoosh shodane motore 5
Dim Time_valv1_of(8) As Byte 'zamanhaye khamoosh shodane valve 1
Dim Time_valv2_of(8) As Byte 'zamanhaye khamoosh shodane valve 2
Dim Time_valv3_of(8) As Byte 'zamanhaye khamoosh shodane valve 3
Dim Time_valv4_of(8) As Byte 'zamanhaye khamoosh shodane valve 4
Dim A3_state As Bit 'vaziat faal ya gheyre faal bodane sharte 3 dar mode A tavasote karbar
Dim Time_b1 As Integer 'taeen zamane baraye sharte 1 dar mode_b
Dim B2_state As Byte 'vaziate sharte B-2 dar mode smart
Dim B3_state As Byte 'vaziate sharte B-2 dar mode smart
Dim Timer_on_of As Bit 'entekhabe mode timer dar bakhshe tanzime zaman
Dim Daghighe As Byte 'entekhabe daghighe dar bakhsh tanzime zaman
Dim Saat As Byte 'entekhabe saat dar bakhshe tanzime zaman
Dim Valve_number As Byte 'entekhabe shomare valve dar bakhshe tanzime zaman
Dim Timer_number As Byte 'entekhabe shomare timer dar bakhshe tanzime zaman
Dim Show As Bit 'entekhabe nemayesh ya aadam nemayesh dar barname Main
Show = 1
Dim Smart_mode_state As Bit 'in moteghayer moshakhas mikonad dar halate automatic T smart faal bashad ya kheyr
Smart_mode_state = 0
B2_state = 4
B3_state = 8
'-------------------------------------------------------------------------------
'sim 800 dimension
Dim Uart_in(80) As Byte 'voroodi uart kham
Dim Sh_data_uart As Byte 'shomarande tedade dataye voroodi
Dim Aizan_shomar As Byte 'shomarande tedad aizanha
Dim Sh_soton As Byte 'tabdile adad be reshte
Dim Char As String * 1 'shomarande karaktere payame voroodi
Dim Sh_payam As Byte
Dim Sh_shir_payam_adad As Byte '
Dim Command_payam As String * 1
Dim Sh_shir_payam As String * 1
Dim Adad_string(9) As String * 1
Adad_string(1) = "1"
Adad_string(2) = "2"
Adad_string(3) = "3"
Adad_string(4) = "4"
Adad_string(5) = "5"
Adad_string(6) = "6"
Adad_string(7) = "7"
Adad_string(8) = "8"
Adad_string(9) = "9"
Sh_data_uart = 1
'----------------------------------------------------------------------------------
' ds1307 timer
Dim _sec As Byte
Dim _seci_1 As Byte
Dim _min As Byte
Dim _hour As Byte
Dim _year As Word
Dim Weekday As Byte
Dim M_day As Word
Dim M_month As Word
Dim M_year As Word
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'################################################# ##############################
'----------------------------Main Program---------------------------------------
_sec = 00
_min = 34
_hour = 12
Gosub Settime
Do
Gosub Read_date_time
If _sec <> _seci_1 Then
Locate 4 , 1
Lcd " "
Locate 4 , 1
Lcd "TIME: " ; _hour ; ":" ; _min ; ":" ; _sec ; " "
_seci_1 = _sec
End If
Loop
'=======================
Gsmint:
Return
End
Check_card:
Return
End
'=======================
'************************************************* ******************************
'****************************** ****************
'WWW.ISEEE.IR ***************** READ DATE AND TIME ****************
'****************************** ****************
'************************************************* ******************************
Read_date_time:
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' start address in 1307
I2cstart ' Generate start code
I2cwbyte Ds1307r ' send address
I2crbyte _sec , Ack
I2crbyte _min , Ack ' MINUTES
I2crbyte _hour , Ack ' Hours
I2crbyte Weekday , Ack ' Day of Week
I2crbyte M_day , Ack ' Day of Month
I2crbyte M_month , Ack ' Month of Year
I2crbyte _year , Nack ' Year
I2cstop
_sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
M_day = Makedec(m_day) : M_month = Makedec(m_month) : _year = Makedec(_year)
M_year = 2000 + _year
Return
'************************************************* ******************************
'****************************** ****************
'WWW.ISEEE.IR ***************** SET TIME ****************
'****************************** ****************
'************************************************* ******************************
Settime:
_sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour)
I2cstart
Cls : Lcd "1" ' Generate start code
I2cwbyte Ds1307w
Lcd "2" ' send address
I2cwbyte 0 ' starting address in 1307
I2cwbyte _sec ' Send Data to SECONDS
I2cwbyte _min ' MINUTES
I2cwbyte _hour
Lcd "3" ' Hours
I2cstop
Return
دیدگاه