Jump to content

  • Log In with Google      Sign In   
  • Create Account

Photo

Probleme de incepatori


  • Please log in to reply
822 replies to this topic

#31 OFFLINE   naghi32

naghi32

    Nou venit

  • Membri
  • Pip
  • 61 posts

Posted 25 March 2010 - 01:27 PM

Multumesc, se pare ca am inteles gresit, o sa bag mai adanc nasul in documentatie !

Cu_reclama

Cu_reclama
  • Membri

#32 OFFLINE   stefan_k

stefan_k

    Membru

  • Membri
  • PipPip
  • 553 posts

Posted 25 March 2010 - 01:48 PM

1) ai inteles gresit ! 8Kb e memnoria flash , microcontrolerul mergand pana la 20Mhz sau chiar 25Mhz asa cum le overclockez eu in mod curent iar 8Mhz e valabil doar pentru varianta de putere mica adica cu L , cele cu P conform datasheet merg pana la 16Mhz cu cristal quartz extern


Partial corect, dar nu ai citit complet ce a intrebat omul. Omul intreaba specific de ATMEGA8L-8PU, cel cu L in coada, si cu doi de 8 in denumire, din care al doilea e frecventa maxima de lucru garantata de producator, asa cum bine a inteles si naghi32. PU e doar capsula, DIP cu 28pini in cazul de fata.

Pt naghi: daca nu ai nevoie de functionare la tensiune mica (2.7V), atunci poti renunta la varianta cu L si sa iei varianta "normala", de 5V si max 16MHz - atmega8-16pu.
Iar daca vrei sa urci pana la 20MHz (sau cum fac unii, overclock la 25...), mergi pe seria urmatoare, gen atmega88-20pu.

Vezi ca are intern si un oscilator Rc calibrat care merge de la 1Mhz si pina la 8Mhz ( valoarea lui fiind programabila in rage-ul mentionat ) si nu are nevoie de cristal de quartz extern


Adevarat, dar depinde de aplicatie. Daca are nevoie de comunicatie seriala de ex, se recomanda totusi cuartz extern (oscilatorul intern are toleranta prea mare).

#33 OFFLINE   danzup

danzup

    Membru avansat

  • Membri
  • PipPipPipPip
  • 2,016 posts

Posted 25 March 2010 - 01:54 PM

[quote name="stefan_k"][quote name="danzup"]1) ai inteles gresit ! 8Kb e memnoria flash , microcontrolerul mergand pana la 20Mhz sau chiar 25Mhz asa cum le overclockez eu in mod curent iar 8Mhz e valabil doar pentru varianta de putere mica adica cu L , cele cu P conform datasheet merg pana la 16Mhz cu cristal quartz extern[/quote]

Partial corect, dar nu ai citit complet ce a intrebat omul. Omul intreaba specific de ATMEGA8L-8PU, cel cu L in coada, si cu doi de 8 in denumire, din care al doilea e frecventa maxima de lucru garantata de producator, asa cum bine a inteles si naghi32. PU e doar capsula, DIP in cazul de fata.

Pt naghi: daca nu ai nevoie de functionare la tensiune mica (2.7V), atunci poti renunta la varianta cu L si sa iei varianta "normala", de 5V si max 16MHz - atmega8-16pu.
Iar daca vrei sa urci pana la 20MHz (sau cum fac unii, overclock la 25...), mergi pe seria urmatoare, gen atmega88-20pu.

[quote]Vezi ca are intern si un oscilator Rc calibrat care merge de la 1Mhz si pina la 8Mhz ( valoarea lui fiind programabila in rage-ul mentionat ) si nu are nevoie de cristal de quartz extern[/quote]

Adevarat, dar depinde de aplicatie. Daca are nevoie de comunicatie seriala de ex, se recomanda totusi cuartz extern (oscilatorul intern are toleranta prea mare).[/quote]
Corect !

#34 OFFLINE   naghi32

naghi32

    Nou venit

  • Membri
  • Pip
  • 61 posts

Posted 25 March 2010 - 01:58 PM

Avand in vedere ca sunt incepator nu ma intereseaza frecvente foarte mari, desi presupun ca este nevoie daca imi trece prin cap sa incerc sa fac ceva in genul ceasurilor acelea cu motor ( propeller clock )

#35 OFFLINE   lorik199

lorik199

    Membru evoluat

  • Membri
  • PipPipPipPipPip
  • 2,749 posts
  • Locatie:Tg.neamt/Suceava

Posted 29 March 2010 - 07:51 PM

deci sa va mai deranjez inca odata, am gasit un proiect foarte simplu si care ar promite rezultate bune
http://www.mikrocont...et/topic/152966
cer ajutorul cuiva mai avansat daca poate modifica programul pt lcd de 1x16 caractere, el acum fiind pt 2x8

#36 OFFLINE   danzup

danzup

    Membru avansat

  • Membri
  • PipPipPipPip
  • 2,016 posts

Posted 30 March 2010 - 10:14 AM

deci sa va mai deranjez inca odata, am gasit un proiect foarte simplu si care ar promite rezultate bune
http://www.mikrocont...et/topic/152966
cer ajutorul cuiva mai avansat daca poate modifica programul pt lcd de 1x16 caractere, el acum fiind pt 2x8

Uite aici :

#37 OFFLINE   lorik199

lorik199

    Membru evoluat

  • Membri
  • PipPipPipPipPip
  • 2,749 posts
  • Locatie:Tg.neamt/Suceava

Posted 30 March 2010 - 02:08 PM

multumesc mult, o sa fac zilele astea montajul si va tin la curent cu detaliile

#38 OFFLINE   naghi32

naghi32

    Nou venit

  • Membri
  • Pip
  • 61 posts

Posted 30 March 2010 - 02:49 PM

Din pacate cei de la adelaida m-au dezamagit si nu au ceea ce ma intereseaza si nici nu stiu cand vor aduce.
Ma interesau niste Atmega80-20 si attiny13, dar nu au nici un fel, stiti unde as putea comanda pe net asa ceva ? nici pe e-piese.ro nu au pe stoc asa ceva. multumesc ( sunt din cta ) si daca gasesc in acelasi loc un SN74HC244 ar fii perfect :) e pentru programator.

#39 OFFLINE   ole

ole

    Membru

  • Membri
  • PipPip
  • 341 posts

Posted 30 March 2010 - 04:54 PM

Din pacate cei de la adelaida m-au dezamagit si nu au ceea ce ma intereseaza si nici nu stiu cand vor aduce.
Ma interesau niste Atmega80-20 si attiny13, dar nu au nici un fel, stiti unde as putea comanda pe net asa ceva ? nici pe e-piese.ro nu au pe stoc asa ceva. multumesc ( sunt din cta ) si daca gasesc in acelasi loc un SN74HC244 ar fii perfect :) e pentru programator.


Incearca la conex la bucuresti. trimit prin posta. Preturile in schimb sunt destul de mari. eu am luat de la ei mega8 la vreo 7-8lei/buc.

#40 OFFLINE   iulian2010

iulian2010

    Membru

  • Membri
  • PipPip
  • 146 posts

Posted 31 March 2010 - 04:08 AM

Salutare,

Referitor la proiectul cu submeniuri am facut si eu un cod de test. Pentru a intra in Meniu se apasa butonul o singura data, apoi tot printr-o singura apasare se acceseaza submeniurile. Daca se tine apasat butonul vreo 4 sec intra automat in meniul secret. Ca sa iasa din meniul secret se apasa butonul aprox 1 sec.

$regfile = "m8def.dat"
$crystal = 4000000
$hwstack = 32
$swstack = 10
$framesize = 40

Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.1 , Rs = Portd.0

Dim A As Byte
Dim Nr As Byte
Dim Buton_apasat As Word

Config Portc.2 = Input
Set Portc.2
Buton Alias Pinc.2

Declare Sub Submeniu1()
Declare Sub Submeniu2()
Declare Sub Submeniu3()
Declare Sub Submeniu4()
Declare Sub Submeniu5()

' Selectare Meniu
Cls
Waitms 500
Cursor Off
Locate 1 , 1
Lcd "Selectare meniu "
Locate 2 , 1
Lcd " Apasa Butonul! "

Meniu:
Do
Debounce Buton , 0 , Apasare_buton , Sub

If A = 1 Then
Incr Nr
If Nr > 4 Then Nr = 1
A = 0
Cursor Off
Locate 1 , 1
Lcd "MENIU           "
Locate 2 , 1

If Nr = 1 Then Lcd "  Submeniu1     "
If Nr = 2 Then Lcd "  Submeniu2     "
If Nr = 3 Then Lcd "  Submeniu3     "
If Nr = 4 Then Lcd "  Submeniu4     "
'If Nr = 5 Then Lcd "  Submeniu5     "

Waitms 100
End If
Loop

Bitwait Buton , Set

Select Case Nr
Case 1 : Call Submeniu1()
Case 2 : Call Submeniu2()
Case 3 : Call Submeniu3()
Case 4 : Call Submeniu4()
End Select


' ********** Submeniu1
Sub Submeniu1()

End Sub


' ********** Submeniu2
Sub Submeniu2()

End Sub


' ********** Submeniu3
Sub Submeniu3()

End Sub

' ********** Submeniu4
Sub Submeniu4()

End Sub


' ********** Submeniu5
Sub Submeniu5()
Do
Locate 1 , 1
Lcd "Meniu secret    "
Locate 2 , 1
Lcd "  Submeniu5     "
Wait 1
If Buton = 0 Then
Wait 1
Goto Meniu
End If
Loop
End Sub


Apasare_buton:

Buton_apasat = 0
Do
Incr Buton_apasat
Waitms 1
If Buton_apasat > 3000 Then
Call Submeniu5()
End If
A = 1
Loop Until Buton = 1


#41 OFFLINE   yo6pir

yo6pir

    Electronist

  • Membri
  • PipPip
  • 882 posts
  • Locatie:Târgu-Mures

Posted 01 April 2010 - 07:11 PM

Iulian2010,
am incercat softul propus de tine, cel cu meniu secret, este OK. As avea totusi ceva de adaugat, faptul ca in acel meniu secret nu pot executa nimic, deoarece refresh-ul acelei subrutine este de 1 sec. si orice pun acolo se misca foarte greu. Am pus sa citeasca o intrare ADC si un alt buton si nu prea merge OK din cauza refresh-ului. Am marit refresh-ul la 300ms si se misca mai repede dar tot nu e convenabil. Daca te poti uita putin peste program si sa mai modifici ceva acolo e foarte bine. Oricum am filtrat deja ideea ta de acolo si-mi prinde bine la urmatorul meu program. E vorba de folosirea procedeului de numarare a delay-ului de 1ms pentru a creea o intarziere la rutina debounce a butonului, in loc de folosirea Timer1 in cazul meu si intreruperea de program. Dar orice idee este bine-venita si numai asa invatam. OK, toate bune si mai vorbim,
Ovidiu.

#42 OFFLINE   iulian2010

iulian2010

    Membru

  • Membri
  • PipPip
  • 146 posts

Posted 02 April 2010 - 11:46 PM

Simnakovi,
Codul de mai sus a fost doar o idee, pe langa cele ale colegilor de forum Danzup si Ratza.
Poate codurile de mai jos iti sunt de folos tot ca idei numai. Voi incerca si eu cand am timp sa fac o optimizare la codul de care ai nevoie.

Sarbatori fericite tuturor!

' Simplu click, Dublu click si Click lung
' In:  Pinb.0: Buton pus la ground
' Out: PortC.0: Led rosu    'lumineaza cu click scurt
' Out: PortC.1: Led galben   'lumineaza cu click lung
' Out: PortC.2: Led verde  'lumineaza cu dublu click

$regfile = "m8def.dat"
$crystal = 4000000

Config Portc = Output
Led_rosu Alias Portc.0
Led_galben Alias Portc.1
Led_verde Alias Portc.2

Config Portb.0 = Input
Portb.0 = 1
Buton Alias Pinb.0

Dim Buton_apasat As Byte
Const Buton_apasat_lung = 100
Const Buton_apasat_2ori = 20
Dim Click As Byte
Const Scurt = 1
Const Lung = 2
Const Dublu = 3

Do
  Debounce Buton , 0 , Apasare_buton , Sub
  Select Case Click
  Case Scurt:
      Led_rosu = 1
      Led_galben = 0
      Led_verde = 0
      Click = 0
      Wait 1
  Case Lung:
      Led_rosu = 0
      Led_galben = 1
      Led_verde = 0
      Click = 0
      Wait 1
  Case Dublu:
      Led_rosu = 0
      Led_galben = 0
      Led_verde = 1
      Click = 0
      Wait 1
  End Select
  'Portc = 0
Loop



Apasare_buton:
  Buton_apasat = 0
  Do
    Incr Buton_apasat
    Waitms 10
  Loop Until Buton = 1 Or Buton_apasat = Buton_apasat_lung

  If Buton_apasat = Buton_apasat_lung Then
    Click = Lung
  Else
    Buton_apasat = 0
    Do
      Incr Buton_apasat
      Waitms 10
    Loop Until Buton = 0 Or Buton_apasat = Buton_apasat_2ori

    If Buton_apasat = Buton_apasat_2ori Then
      Click = Scurt
    Else
      Click = Dublu
    End If
  End If
Return

End


Config Timer1 = Counter , Prescale = 64                    'keyevents (10 Hz)
 On Timer1 Checkkeys

 Do

 Loop

Checkkeys:
Timer1 = Timer1_default
If Pind.6 = 0 Then
  If Key_up_state = 0 Then
    Key_up_state = 1
  Else
    Incr Key_up_count
  End If
Else
  If Key_up_state = 1 Then
    'from 0 - 500ms
    If Key_up_count > 0 And Key_up_count <= 5 Then
       ' shot press
       Key_up_count = 0
    End If
' after 600ms
    If Key_up_count > 6 Then
      ' long press
       key_up_count = 0
    End If
  End If

End If

If Pind.5 = 0 Then
  If Key_down_state = 0 Then
    Key_down_state = 1
  Else
    Incr Key_down_count
    ' after 3 seconds of pressing
    If Key_down_count > 30 Then
      Key_down_state = 0
      Key_down_count = 0
    End If
  End If
Else
  If Key_down_state = 1 Then
   ' from 0 - 500ms
    If Key_down_count > 0 And Key_down_count <= 5 Then
      Call Decrement
      To_confirm = 1
      Key_down_state = 0
      Key_down_count = 0
    ' from 600ms - 2.9 seconds
    Else
      Key_down_state = 0
      Key_down_count = 0
    End If
  End If
End If
Return


#43 OFFLINE   naghi32

naghi32

    Nou venit

  • Membri
  • Pip
  • 61 posts

Posted 04 April 2010 - 09:48 AM

Tocmai ce mi-a ajuns un aTmega8535 si o sa incep sa ma joc cu el.
Hristos a inviat !

#44 OFFLINE   iulian2010

iulian2010

    Membru

  • Membri
  • PipPip
  • 146 posts

Posted 08 April 2010 - 10:35 PM

Adevarat a Inviat!

Simnakovi,
Poti sa arunci o privire si pe codul lui Ben Zijlstra.

' Dynamic Single Button Menu - Ben Zijlstra / Theo Kleijn - april 2007

$sim                                                        'it is ready for the simulator, but you have to work around the buttonpresses….

'some housekeeping

$regfile = "m32def.dat"
$crystal = 16000000

$hwstack = 128
$swstack = 128
$framesize = 128

'things can be tested in the simulator, put a 1 for test and a 0 for the real world

Const Dubug = 1                                             '1 for debugging / simulator

'here the declaration of the subroutines that are used

Declare Sub Menu
Declare Sub Buzzer
Declare Sub Readmenu
Declare Sub Pick_item
Declare Sub Pick_option
Declare Sub Option101
Declare Sub Option808

'and here the global variables that are used

Dim M(9) As String * 30
Dim Mx(9) As String * 30
Dim Menu1 As String * 255
Dim O(2)as String * 30
Dim Teller As Byte
Dim Exitmenu As Byte , Exitflag As Byte , X As Byte

'hardware depended, a LCD. 16 x 2 and 20 x 2 can be used.

Config Lcd = 20 * 2
Config Lcdmode = Port
Config Lcdbus = 4
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , _
        Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.0

Initlcd

'the single button connected to PIN A.1 and a buzzer connected to PORT A.2

Buttonup Alias Pina.1
Beepact Alias Porta.2
Config Beepact = Output

Cls
Home

' and here we go for the real stuff, a call to the menu-routine

Call Menu
End

Sub Menu
Local Tl As Long
Call Buzzer
Call Readmenu
Exitmenu = 0
Do
   For X = 1 To 9
      Tl = 0

' get the menu-items, split them on the # sign and put them in array MX()

      Teller = Split(m(x) , Mx(1) , "#")

'skip the empty menu-items

      If Mx(1) = "                " Then

'check if we are in the debug / simulator mode, waits are short, or in the real world, normal waits

         #if Dubug
            Tl = 99
         #else
            Tl = 299999
         #endif
      Else
         Cls
         Home

'put the menu-items on the LCD and keep them moving….

         Lcd Mx(1)
      End If

' wait for a key-press, if nothing is press carry on to the next menu-item

      Do
         Incr Tl
         Debounce Buttonup , 0 , Pick_item , Sub
         #if Dubug
             Loop Until Tl = 100
         #else
             Loop Until Tl = 300000
         #endif
   Next X

'keep doing this until the exit menu item has been selected

Loop Until Exitmenu = 1
End Sub

Sub Pick_item
'this subroutine is called when a menu-item is selected
Local Tl As Long
   ' beep
   Call Buzzer
   If Right(mx(2) , 2) = "10" Then
 ' check if the exit menu is pressed
      Exitmenu = 1
      Exit Sub
   End If
   Restore Mnu
  'we have stored the selected menu-item in an array and the second part of this array contains the 'data-line'
  'we have to read to get the options of this menu-item
   For X = 1 To Val(mx(2))
      Read Menu1
   Next X
   Teller = Split(menu1 , M(1) , "_")
   Exitflag = 0
   Do
      For X = 1 To 9
         Tl = 0
         Teller = Split(m(x) , O(1) , "#")
 'skip the empty menu-options
          If O(1) = "                " Then
            #if Dubug
                 Tl = 99
            #else
                 Tl = 299999
            #endif
         Else
            Home
            Lowerline
 'put the option on the screen
          Lcd O(1)
         End If
         Do
 'and wait for a keypress when the right option appears
            Incr Tl
            Debounce Buttonup , 0 , Pick_option , Sub
            Print Tl
            #if Dubug
                Loop Until Tl = 100
            #else
                Loop Until Tl = 300000
            #endif
      Next X
   Loop Until Exitflag = 1
End Sub

Sub Pick_option
   Call Buzzer
'if the last option is selected, the exit option clear the screen and set the exitflag. Returning to the menu-items.
   If Right(m(x) , 1) = "9" Then
      Cls
      Home
      Exitflag = 1
      Call Readmenu
   End If
   Select Case Right(m(x) , 3)
       'here all numbers of all selected options appear. Action can be taken here. Only two options are used now.
       Case "101" : Call Option101
       'case etcetera
       Case "808" : Call Option808
   End Select
End Sub

'routine to read the datalines, and split them on the "_" sign
Sub Readmenu
   Restore Mnu
   Read Menu1
   Teller = Split(menu1 , M(1) , "_")
End Sub

'beep routine
Sub Buzzer
Reset Beepact
Waitms 100
Set Beepact
End Sub

'one of the selections calls this routine as an example
Sub Option101
'take action here and return to menu
End Sub

'and another one the selections calls this routine as an example
Sub Option808
'take action here and return to menu
End Sub

Mnu:
Data "Menuitem 1      #2_Menuitem 2        #3_                  #4_Menuitem 4        #5_Menuitem 5        #6_Menuitem 6        #7_Menuitem 7        #8_Menuitem 8        #9_Exit menu         #10"

Data "Option 11       #101_                #102_Option 13       #103_Option 14       #104_                #105_Option 16       #106_Option 17       #107_Option 18       #108_Exit Options    #109"
Data "Option 21       #201_Option 22       #202_Option 23       #203_Option 24       #204_Option 25       #205_Option 26       #206_Option 27       #207_Option 28       #208_Exit Options    #209"
Data "Option 31       #301_Option 32       #302_Option 33       #303_Option 34       #304_Option 35       #305_Option 36       #306_Option 37       #307_Option 38       #308_Exit Options    #309"
Data "Option 41       #401_Option 42       #402_Option 43       #403_Option 44       #404_Option 45       #405_Option 46       #406_Option 37       #407_Option 48       #408_Exit Options    #409"
Data "Option 51       #501_Option 52       #502_Option 53       #503_Option 54       #504_Option 55       #505_Option 56       #506_Option 57       #507_Option 58       #508_Exit Options    #509"
Data "Option 61       #601_Option 62       #602_Option 63       #603_Option 64       #604_Option 65       #605_Option 66       #606_Option 67       #607_Option 68       #608_Exit Options    #609"
Data "Option 71       #701_Option 72       #702_Option 73       #703_Option 74       #704_Option 75       #705_Option 76       #706_Option 77       #707_Option 78       #708_Exit Options    #709"
Data "Option 81       #801_Option 82       #802_Option 83       #803_Option 84       #804_Option 85       #805_Option 86       #806_Option 87       #807_Option 88       #808_Exit Options    #809"


Cu_reclama

Cu_reclama
  • Membri

#45 OFFLINE   yo6pir

yo6pir

    Electronist

  • Membri
  • PipPip
  • 882 posts
  • Locatie:Târgu-Mures

Posted 09 April 2010 - 09:18 PM

Da, interesant programul dar ocupa cam mult loc, si eu nu am lucrat inca cu asa exemplare mari cum e Atmega32. Te cred, in 32Kb de memorie de program iti permiti sa risipesti 12% (aprox 3,8Kb!) pentru rutina de comanda a butonului. Dar intr-un Atmega8 cum folosesc eu de obicei, cu doar 8Kb de memorie nu prea incape si rutina de comanda a butonului( butoanelor) si programul in sine. Oricum mersi de info si este utila pentru invatare. Toate bune si mai vorbim, 73!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users