Jump to content
ELFORUM - Forumul Electronistilor
fratello

Ceas simplu cu Atmega 8 - ajutor, va rog !

Recommended Posts

Va salut si La multi ani ! Sa aveti un An Nou 2016 asa cum vi-l doriti !!!

 

=======

O data cu trecerea la IPTV si schimbarea receiverului Dolce, am ramas fara ceas :) ....

Asa ca am cautat o schema cat mai simpla si cat mai precisa de ceas electronic cu display LED. Din experienta mea cu microcontrolerele Microchip, stiu ca Atmega sunt mai bune la acest capitol, permitand montarea unui cristal extern de 32768 kHz. Zis si facut ! Am gasit si am facut aceasta schema : http://www.tehnari.ru/f170/t61589/

Varianta cu rezistente pe iesirile Atmega 8...Merge impecabil, sunt foarte multumit de precizie !!!

DAR ... am o singura (mica) nemultumire : orele pana la 10 sunt afisate si cu cifra zero in fata. Din pacate codul sursa pentru aceasta schema nu este disponibil.

Asa ca am mai cautat si am gasit o alta schema (vedeti atasament) care are si codul sursa, in Bascom AVR. Intrucat sunt "zero" la programare in acest limbaj, apelez la bunavointa celor care cunosc limbajul, pentru a modifica programul astfel incat cifra zero sa nu mai fie afisata ...sperand ca si acest ceas are aceeasi precizie ca cel descris anterior.

Multumesc anticipat pentru orice raspuns !

Ceas_Atmega_8.zip

Share this post


Link to post
Share on other sites

Salut,

Din experienta mea cu microcontrolerele Microchip, stiu ca Atmega sunt mai bune la acest capitol, permitand montarea unui cristal extern de 32768 kHz.

sunt off-topic, stiu, voiam doar sa-ti spun ca stii gresit. Poti folosi si picurile cu oscilator de 32768 (conectat intre T1OSI si T1OSO) + timer1 ca sa faci un ceas.

 

Citat din foaia de catalog a 16f627a (pagina 53)

 

7.4  Timer1 OscillatorA crystal oscillator circuit is built in between pins T1OSI (input) and T1OSO (amplifier output). It is enabled by setting control bit T1OSCEN (T1CON<3>). It will  continue to run during Sleep. It is primarily intended for a 32.768 kHz watch crystal.

Share this post


Link to post
Share on other sites
Sub Refresh   Comm = &B1000 : Dp = 0 : Temp = _hour  10 : Call Send   Comm = &B0100 : Dp = 1 : Temp = _hour Mod 10 : Call Send   Comm = &B0010 : Dp = 0 : Temp = _min  10 : Call Send   Comm = &B0001 : Dp = 0 : Temp = _min Mod 10 : Call SendEnd Sub

ar trebui sa fie ceva de genul

Sub Refresh   Comm = &B1000 : Dp = 0    if _hour < 10 then Temp = 10  : REM e ultimul element adaugat: ar trebui stinse toate - 0 sau 1 toate...   else Temp = _hour  10   end if   Call Send   Comm = &B0100 : Dp = 1 : Temp = _hour Mod 10 : Call Send   Comm = &B0010 : Dp = 0 : Temp = _min  10 : Call Send   Comm = &B0001 : Dp = 0 : Temp = _min Mod 10 : Call SendEnd Sub'....

si adaugat un nou element in Segdata cu toate ledurile stinse (depinde cum se stinge cu 1 sau 0)

Segdata:Data &B11000000 , &B11111001 , &B10100100 , &B10110000Data &B10011001 , &B10010010 , &B10000010 , &B11111000Data &B10000000 , &B10010000 , &B00000000

L.E. : E prima data cand m-am uitat peste Bascom, asa ca e doar ideea, s-ar putea sa nu compileze...

Edited by crispus

Share this post


Link to post
Share on other sites

Incearca sa compilezi codul de mai jos:

'---------------------------------------------------------------'Simple Digital Clock With Multiplex 7-Segment <Digiclk.bas>'Programmer: Behnam Zakizadeh ([email protected]) AVR64.com'Compiler : BASCOM 1.11.9.1'Creation Date: Sep 21, 2009 (1388.06.30)'Copyright: (C) 2009 By www.avr64.com'License: This Is A Free Firmware, Ver: 1.00 (Comm. Anode)'---------------------------------------------------------------$regfile = "m8def.dat"$crystal = 1000000                                'Internal RC$hwstack = 64$swstack = 64$framesize = 64'RTCConfig Clock = Soft , Gosub = SecticEnable InterruptsTime$ = "12:00:00"'I/OConfig Portd = Output                             'A-G (Data)Config Portc = Output                             'Comm. AnodeConfig Pinb.0 = Input                             'Hour KeyConfig Pinb.1 = Input                             'Minute KeyConfig Pinb.2 = Output                            'Blink Sec'Set Pullup Resistor For Setting Key'sSet Portb.0Set Portb.1'AliasesDataport Alias PortdComm Alias PortcHour_key Alias Pinb.0Min_key Alias Pinb.1Second_led Alias Portb.2'VariablesDim Temp As ByteDim Temp2 As ByteDim Scnd As ByteDim Rtc_run As ByteDim S As BitDim Dp As Bit'DeclarationDeclare Sub KeyscanDeclare Sub RefreshDeclare Sub SendDeclare Sub Wait4keyDeclare Sub Blink_sec'Wait 4 RTC StartComm = &H0F                                       'PromptDo   If Rtc_run > 0 Then Exit DoLoop'Main Prog Start Here:Do   Call Keyscan   Call Refresh   Call Blink_secLoopEndSub Keyscan   If Hour_key = 0 Then      Incr _hour      If _hour > 23 Then _hour = 0      Call Wait4key   End If   If Min_key = 0 Then      Incr _min      If _min > 59 Then _min = 0      Call Wait4key   End IfEnd SubSub Refresh   Comm = &B1000 : Dp = 0 : Temp = _hour  10  	if (Temp<>0) Then 	Call Send 	End If   Comm = &B0100 : Dp = 1 : Temp = _hour Mod 10 : Call Send   Comm = &B0010 : Dp = 0 : Temp = _min  10 : Call Send   Comm = &B0001 : Dp = 0 : Temp = _min Mod 10 : Call SendEnd SubSub Send   Dataport = Lookup(temp , Segdata)   If Dp = 1 Then      Portd.7 = S    Else      Portd.7 = 1   End If   Waitms 4   Dataport = &HFFEnd SubSub Wait4key   For Temp2 = 1 To 25      Call Refresh   NextEnd SubSub Blink_sec   Incr Scnd   If Scnd > 63 Then Scnd = 0   If Scnd > 0 And Scnd < 31 Then      S = 1   Else      S = 0   End IfEnd SubSegdata:Data &B11000000 , &B11111001 , &B10100100 , &B10110000Data &B10011001 , &B10010010 , &B10000010 , &B11111000Data &B10000000 , &B10010000, &B00000000Sectic:Incr Rtc_runReturn

Share this post


Link to post
Share on other sites

@ Liviu M : Exprimarea a fost gresita, mea culpa ... Intr-adevar ai dreptate ! Dar, desi am mai dezbatut acest subiect cu ani in urma, chiar si pe acest forum, dar si pe forumul PBP,  nu am reusit, in PIC BASIC PRO, sa scriu un soft care sa evite complet "flicker" -ul displayului LED. Cel putin nu cu oscilator de 4 MHz (intern). Sunt constient ca in alte limbaje de programare se poate !!!

@ Crispus : Multumesc !

@ Nico_2010 : Multumesc !

Stiu ca nu-i frumos ...dar nu am Bascom-ul :( ... Il poate compila cineva ?

Share this post


Link to post
Share on other sites

...

Stiu ca nu-i frumos ...dar nu am Bascom-ul :( ... Il poate compila cineva ?

Am incercat sa compilez, dar imi da ceva eroare.

Nici eu nu sunt asa de priceput la Bascom.

Poate te ajuta alt coleg, poate chiar nico_2010 care a facut modificarea in soft.

 

Posted Image

Edited by GeoMar

Share this post


Link to post
Share on other sites

Salut si La Multi Ani tuturor forumistilor

Am compilat codu am incercat si in proteus o simulare si se pare ca functioneaza,sper ca si  in montaj o sa fie ok

hex compilat.zip

Share this post


Link to post
Share on other sites

@ Liviu M : Exprimarea a fost gresita, mea culpa ... Intr-adevar ai dreptate ! Dar, desi am mai dezbatut acest subiect cu ani in urma, chiar si pe acest forum, dar si pe forumul PBP,  nu am reusit, in PIC BASIC PRO, sa scriu un soft care sa evite complet "flicker" -ul displayului LED. Cel putin nu cu oscilator de 4 MHz (intern). Sunt constient ca in alte limbaje de programare se poate !!!

 

 

 Pentru ceas iti recomand seria PIC16F150x au oscilator intern de 16Mhz, eu comand cu unu-l un ceas matrice alcatuit din 25 de colane si 7 randuri fara nici o problema.

 

 Pentru precizie totusi ar merge un DS1307 chinezii il dau cu preturi de la 1.5$ gata facute cu soclu, baterie,etc.. 

Edited by bandi12

Share this post


Link to post
Share on other sites

scuze am compilat pe cel postat din folderu zip iar cel postat de nico2010 nu se poate compila pentru ca da eroare

Share this post


Link to post
Share on other sites

Multumesc tuturor pentru suport !

Sa speram ca va rezulta totusi o varianta functionala !

Edited by fratello

Share this post


Link to post
Share on other sites

Revin ...

Am eliminat eroarea de la compilare, scriind astfel comanda care crea probleme : "   If Temp<>0 Then Call Send  "

Cel putin in simulare (nu vad insa de ce nu si in realitate) functioneaza cf. asteptarilor !

Multumesc, inca o data !

 

 

post-175951-0-76956500-1451937513_thumb.jpg

Edited by fratello

Share this post


Link to post
Share on other sites

...inca o nelamurire :

Sub Blink_sec   Incr Scnd   If Scnd > 63 Then Scnd = 0

Ceasul numara 64 secunde ?!

Share this post


Link to post
Share on other sites

Asa se pare! Ai un ceas cu "personalitate".

Modifica "63" cu "59" si ai rezzolvat problema.

Nu te pot ajuta cu compilarea, la serviciu nu am BASCOM

Share this post


Link to post
Share on other sites

Asa voi face ! Multumesc mult pentru ajutor !

Dupa realizare si testare, voi posta rezultatele. Numai bine, tuturor !

Share this post


Link to post
Share on other sites

"fratello" lasa secundele asa cum sint, vor fi afisate corect.

 

 

Atasez si eu o varianta in care ora "12 noaptea" este afisata 00:00 si nu 0:00.

'---------------------------------------------------------------'Simple Digital Clock With Multiplex 7-Segment <Digiclk.bas>'Programmer: Behnam Zakizadeh ([email protected]) AVR64.com'Compiler : BASCOM 1.11.9.1'Creation Date: Sep 21, 2009 (1388.06.30)'Copyright: (C) 2009 By www.avr64.com'License: This Is A Free Firmware, Ver: 1.00 (Comm. Anode)'---------------------------------------------------------------$regfile = "m8def.dat"$crystal = 1000000       'Internal RC$hwstack = 64$swstack = 64$framesize = 64'RTCConfig Clock = Soft , Gosub = SecticEnable InterruptsTime$ = "12:00:00"'I/OConfig Portd = Output       'A-G (Data)Config Portc = Output       'Comm. AnodeConfig Pinb.0 = Input       'Hour KeyConfig Pinb.1 = Input       'Minute KeyConfig Pinb.2 = Output       'Blink Sec'Set Pullup Resistor For Setting Key'sSet Portb.0Set Portb.1'AliasesDataport Alias PortdComm Alias PortcHour_key Alias Pinb.0Min_key Alias Pinb.1Second_led Alias Portb.2'VariablesDim Temp As ByteDim Temp2 As ByteDim Scnd As ByteDim Rtc_run As ByteDim S As BitDim Dp As Bit'DeclarationDeclare Sub KeyscanDeclare Sub RefreshDeclare Sub SendDeclare Sub Wait4keyDeclare Sub Blink_sec'Wait 4 RTC StartComm = &H0F       'PromptDo   If Rtc_run > 0 Then Exit DoLoop'Main Prog Start Here:Do   Call Keyscan   Call Refresh   Call Blink_secLoopEndSub Keyscan   If Hour_key = 0 Then      Incr _hour      If _hour > 23 Then _hour = 0      Call Wait4key   End If   If Min_key = 0 Then      Incr _min      If _min > 59 Then _min = 0      Call Wait4key   End IfEnd SubSub Refresh   Comm = &B1000 : Dp = 0 : Temp = _hour  10      If Temp = 0 And _hour > 0 Then Goto Salt      Call Send      Salt:   Comm = &B0100 : Dp = 1 : Temp = _hour Mod 10 : Call Send   Comm = &B0010 : Dp = 0 : Temp = _min  10 : Call Send   Comm = &B0001 : Dp = 0 : Temp = _min Mod 10 : Call SendEnd SubSub Send   Dataport = Lookup(temp , Segdata)   If Dp = 1 Then      Portd.7 = S    Else      Portd.7 = 1   End If   Waitms 4   Dataport = &HFFEnd SubSub Wait4key   For Temp2 = 1 To 25      Call Refresh   NextEnd SubSub Blink_sec   Incr Scnd   If Scnd > 63 Then Scnd = 0   If Scnd > 0 And Scnd < 31 Then      S = 1   Else      S = 0   End IfEnd SubSegdata:Data &B11000000 , &B11111001 , &B10100100 , &B10110000Data &B10011001 , &B10010010 , &B10000010 , &B11111000Data &B10000000 , &B10010000Sectic:Incr Rtc_runReturn

Si hex-ul:  DIGICLK.rar

 

modificati extensia din *.rar in *.hex

Edited by nickrvl

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.