Časovač s nízkou spotrebou
Minútky napájané z batérie CR2032 a s MCU TMP47P242VN
ChaN, 19.10.2009-00:00







V konštrukcii je použitý nízkopríkonový MCU Toshiba TMP47P242VN.
Ide o 4-bitový MCU s 2kB OTP ROM a 128 bytovou RAM pamäťou.
MCU zvláda napájanie v rozsahu 2,7 až 6V a odber má 2mA (VCC=5.5V; 4.2 MHz) a iba 500nA (VCC=5.5V) v hold móde.
Datasheet nájdete u nás:TMP 47P242VN

Schéma časovača


Čas sa nastavuje pomocou kódových prepínačov (SW2, SW3, SW4) v rozsahu 1 až 999 sec. Po nastavení sa časovanie spúšťa a zastavuje tlačítkom (SW1).
Časovač má vyvedené signály (otvorený kolektor) N.O., N.C. a O.S., pre ovládanie externých zariadení.
Záťaž maximálne 30 mA.

Odber pri napájaní z batérie CR2032, je 100nA a batéria by mala vydržať 2000 hodín.

Schválne, k akým odberom by sme sa vedeli dostať dnes ?

Zdrojový kód:
  1.  
  2. ;
  3. ; ƒ~ƒjƒ^ƒCƒ}[
  4. ;
  5.  
  6.         name    aaa
  7.  
  8. $include(tlcs47.h)
  9.  
  10. ;***********************************************************************
  11. ; ‚q‚`‚l—̈æ’è‹`        00h ` 0Fh / 90h ` FFh
  12.  
  13.         dseg    rel ddd
  14.         org     0       ; zero page ram
  15.  
  16. Count:  res     3       ; minute down counter
  17. State:  res     1       ; 0:stop, 1:run, 2:time out beep
  18.  
  19.         org     90h
  20. HLsav:  res     2
  21.  
  22.  
  23. ;       <<MEMORY MAPPED REGISTERS>>     org     0f4h    ; timer counter 1
  24. TC1:    res     3
  25.         org     0f8h    ; timer counter 2
  26. TC2:    res     3
  27.         org     0fch    ; rom data pointer
  28. DTC:    res     3
  29.         org     0ffh    ; stack pointer
  30. SPW:    res     1
  31.  
  32.  
  33. ;***********************************************************************
  34. ; ƒvƒƒOƒ‰ƒ€ƒR[ƒh
  35.  
  36.         cseg    rel ccc
  37.  
  38.         org     00h
  39. init:
  40.         ld      a,#0ch          ; init SP
  41.         st      a,SPW
  42.         out     #1100b,%P01     ; init ports
  43.         out     #0000b,%P09
  44.  
  45.         cmpr    State,#1        ; ƒXƒ^[ƒg^ƒXƒgƒbƒv ?
  46.         testp   zf
  47.         bs      m_stop
  48.         test    cf
  49.         bs      sleep
  50.  
  51.         clr     %P07,1          ; Ý’莞ŠÔ“ǂݍž‚Ý
  52.         ld      hl,#Count
  53.         in      %P00,a
  54.         subr    a,#-1
  55.         st      a,@hl+
  56.         in      %P04,a
  57.         subr    a,#-1
  58.         st      a,@hl+
  59.         in      %P08,a
  60.         subr    a,#-1
  61.         st      a,@hl+
  62.         set     %P07,1
  63.  
  64.         st      #1,State        ; ƒJƒEƒ“ƒgŠJŽn
  65.         out     #0011b,%P01     ; SW on
  66.         call    beep
  67.  
  68. counter:                        ; ƒJƒEƒ“ƒgƒ_ƒEƒ“ƒ‹[ƒv
  69.         ld      hl,#Count
  70.         dec     @hl
  71.         bs      wait60
  72.         st      #9,@hl+
  73.         dec     @hl
  74.         bs      wait60
  75.         st      #9,@hl+
  76.         dec     @hl
  77.         bs      wait60
  78.         bs      timeout
  79. wait60: ld      hl,#TC1         ; 60•b‘Ò‚¿
  80.         st      #nll(-1465),@hl+
  81.         st      #nlh(-1465),@hl+
  82.         st      #nhl(-1465),@hl+
  83.         dec     l
  84.  w60l:  call    click
  85.         ld      a,@hl
  86.         cmpr    a,#0
  87.         bs      w60l
  88.         bs      counter
  89.  
  90.  
  91. timeout:; ƒ^ƒCƒ€ƒAƒEƒg
  92.         st      #2,State
  93.         out     #1100b,%P01     ; SW off
  94.         out     #1100b,%P02     ; O.S. on
  95.         ld      hl,#-150        ; 10•b–‚炷
  96.  tmol:  call    beep
  97.         inc     l
  98.         bs      tmol
  99.         add     h,#1
  100.         bs      tmol
  101.         out     #1111b,%P02     ; O.S. off
  102.         bs      sleep
  103.  
  104. m_stop: ; ƒJƒEƒ“ƒg’âŽ~
  105.         call    beep
  106.         call    beep
  107.         call    beep
  108.  
  109. sleep:  ; ‘Ò‹@ƒ‚[ƒh‚É“ü‚é
  110.         st      #0,State
  111.         ld      a,#0101b        ; enter hold mode, wait for reset!
  112.         out     a,%P10          ;
  113.  
  114.  
  115. click:  ; ŒvŽžƒNƒŠƒbƒN‰¹
  116.         ld      a,TC1
  117.         and     a,#7
  118.         cmpr    a,#1
  119.         bs      clcr
  120.         ld      a,#0
  121.         out     #0111b,%P02
  122.         out     #1011b,%P02
  123.  clcp:  out     #1111b,%P02
  124.         out     #1111b,%P02
  125.         out     #1111b,%P02
  126.         inc     a
  127.         bs      clcp
  128.         out     #0111b,%P02
  129.         out     #1011b,%P02
  130.         out     #1111b,%P02
  131.  clcw:  ld      a,TC1
  132.         and     a,#7
  133.         cmpr    a,#1
  134.         testp   zf
  135.         bs      clcw
  136.  clcr:  ret
  137.  
  138.  
  139. beep:   ; ’P”­ƒr[ƒv
  140.         xch     hl,HLsav
  141.         ld      a,#1000b        ; set timer 1, 391Hz
  142.         out     a,%P1C
  143.  
  144.         ld      hl,#TC1         ; 1/30•b–‚炷
  145.         st      #-13,@hl+
  146.         ld      a,@hl
  147.  bpl1:  set     %P02,3
  148.         clr     %P02,2
  149.         nop
  150.         nop
  151.         cmpr    a,@hl
  152.         set     %P02,2
  153.         clr     %P02,3
  154.         testp   zf
  155.         bs      bpl1
  156.         set     %P02,3
  157.  
  158.         ld      hl,#TC1         ; 1/30•b‹x‚Þ
  159.         st      #-13,@hl+
  160.         ld      a,@hl
  161.  bpl2:  cmpr    a,@hl
  162.         testp   zf
  163.         bs      bpl2
  164.  
  165.         ld      a,#1001b        ; set timer 1, 24.41Hz
  166.         out     a,%P1C
  167.         xch     hl,HLsav
  168.         ret
  169.  
  170.  
  171.         end
  172.  


Celkový pohľad na časovač



Preklad: EdizonTN (vysypaný čaj upratal google translator)
Zverejnené so súhlasom autora.
Homepage projektu: http://elm-chan.org/works/timer/report.html


tento článok je z mikroZONE
( https://www.mikrozone.sk/pluginy/content/content.php?content.27 )