Menu

very low power 15 minute timer

2021-12-30
2022-01-02
1 2 > >> (Page 1 of 2)
  • Reginald Neale

    Reginald Neale - 2021-12-30

    I need to make a battery-operated alarm with a 12F1501. It will run at 31K clock speed. Looking for suggestions on the best way to implement this pseudo-code.

    Sleep until pushbutton is actuated.
    (Lock out pushbutton?)
    Output 50ms confirmation beep.
    Sleep for 5 minutes.
    Output one-second beep.
    Sleep for 5 minutes.
    Output two one-second beeps.
    Sleep for 5 minutes.
    Output three one-second beeps.
    Go back to sleep.

     
  • Anobium

    Anobium - 2021-12-30

    Step one. Select the correct chip.
    then, set that chip to 31k

    code.

    #DEFINE PUSHBUTTON porta.0 
    Dir PUSHBUTTON In
    #DEFINE SoundOut porta.1
    
    
    ..set other port as out
    
    Do
      Wait Until PUSHBUTTON = On
      Wait 5 ms
      Wait Until PUSHBUTTON = Off
      Tone 400, 1000
      Wait 5 m
      Wait 400, 1000
      ...
      etc.
      ....
    Loop
    
     
  • David Stephenson

    I take it that the device is going to be in sleep mode most of the time. In that case the push button needs to be on the interrupt pin to cause a wake up. Also as you are not using the LF version of this chip you should set the VREGPM before going into sleep mode (this will reduce current to less than a uA). Also if you want an accurate 5 minute delay an external clock crystal is the way to go rather than the LFINTOSC.

     
    • Reginald Neale

      Reginald Neale - 2021-12-31

      Yes. Unclear what is the current consumption difference between SLEEP and WAIT. I'm not using the LF version because the beeper needs 5V. Accuracy is not an issue. Interrupts look pretty complicated but if that's what needed I'll give it a try. This is a simple timer for my wife to use with her heating pad/ice pack for arthritis a couple of times a day.

       
      • Anobium

        Anobium - 2021-12-31

        For the difference.. get the meter out and measure.

        A simple program with Sleep as the one line of code and another with Wait 5 m will yield the first results.

        Is the current usage during Wait acceptable? If yes, then, why worry about interrupts.

         
  • Anobium

    Anobium - 2021-12-31

    The first thing is.. what chip is planned to be used.

     
  • Reginald Neale

    Reginald Neale - 2021-12-31

    I'm using 12F1501. Beeper needs 5V so I'm not using the LF version. Circuit with batteries will fit in a project box about 2X2X4 inches. Doesn't need to be super accurate.

     
  • Anobium

    Anobium - 2021-12-31

    Give this a test - this is a baseline - measure the current.

    You MUST replace the DAT file in your C:\GCB@Syn\GreatCowBasic\chipdata folder - the 31k oscillator was not set up. It is now!


    The program supports 31k, a switch on Porta.0 and a Beeper on Porta.1.

     

    Last edit: Anobium 2021-12-31
  • David Stephenson

    A few points..
    If you are using a piezo buzzer they work best at their resonance frequency (which is normally >400 Hz).
    Piezo buzzers seem to work on much lower voltage than specified (particularly if you drive them full wave).
    I'm not sure how "TONE" works but my feeling is that at a clock of 31kHz it will be struggling to hit a high note.

     
    • Anobium

      Anobium - 2021-12-31

      Once the power consumption is sorted then he can change the frequency, if required.

       

      Last edit: Anobium 2021-12-31
  • Reginald Neale

    Reginald Neale - 2021-12-31

    The piezo is self-oscillating, no tone code needed. It draws about 1mA at 5V and still produces sound at 3V, so I want to try the 12LF1501 after all. Is the dat file for 31kHz still an issue for that chip? Good point about the need for measuring the actual current to see the effect of SLEEP. I'll do that!
    Tried to compile and I get this error message : Error: No chip data file found for 12LF1501

     
    • Anobium

      Anobium - 2021-12-31

      ok re piezo.

      The LF works here. So, either check your code for a typo, or, post your code for our review.

       
      • Reginald Neale

        Reginald Neale - 2022-01-01

        I tried other clock speeds too; same "no chip dat file found for 12LF1501"
        Here's my test code:

         
    • Anobium

      Anobium - 2022-01-01

      The DAT file. Use the DAT in the latest patch.

      See https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/ for new DAT files.

      01/01/2022  1052    FIX DAT 31k Yes PIC Not required    Added support for 31k to 12(L)F1501 [1287]
      

      See here for the online release note https://1drv.ms/x/s!Ase-PX_n_4cvhJAysbPF3VJAnYaj3A?e=lgkZnV

      Enjoy

       

      Last edit: Anobium 2022-01-01
  • Reginald Neale

    Reginald Neale - 2022-01-01

    Thanks for all the help. This code runs, but weirdness remains. I re-compiled it at several different clock speeds. Only 16, 8 and 4MHz seem to work, and the timing is only correct at 16 MHz. I thought it was supposed to automatically adjust. It doesn't seem to run at all for the lower speeds that I need for low-current consumption.
    I think I installed the dat file but I'm a mac user and this is strange territory for me. Is there a line in the file that I can examine to see if it's the right one?

     
    • Anobium

      Anobium - 2022-01-01

      The compiler should handle the cases where the internal osc can be selected.

      What freq do not work? and, was the internal osc selected? The compiler report shows which osc has been selected.

       
  • Reginald Neale

    Reginald Neale - 2022-01-01

    1 MHz does not work. 31 KHz still does not work. I looked thru all the menu choices and did not see compiler report. How do I get there? Sorry for the newbie questions but that's what I am. I appreciate your patience. I'm using Low Pin Count Board and PicKIT 3 IF that helps.

     
    • Anobium

      Anobium - 2022-01-02

      What version of the compiler are you using?
      Share the top two lines of your ASM file.

      My guess. Is the Mac compiler needs updating as the image may be an old version. I only maintain the source code and the Windows version.

       
      • Reginald Neale

        Reginald Neale - 2022-01-02

        Not using the Mac compiler. I'm using Windows 10 on an ASUS laptop.
        2nd line asm file says: "Program compiled by Great Cow Basic (0.9 11/5/2014)"
        One of the CONFIG statements is "_FOSC_INTOSC" so it should be using the internal oscillator.

         
        • Anobium

          Anobium - 2022-01-02

          Please install the lastest software, and, and apply the latest patches. Your software is seven years out of date.

           
  • Reginald Neale

    Reginald Neale - 2022-01-02

    Mad some current measurements. with 4MHz clock draws 0.5 mA. Adding sleep command drops to about 30 uA but of course it hangs there without the interrupt.

     
  • Anobium

    Anobium - 2022-01-02

    Updated the software ?

     
    • Reginald Neale

      Reginald Neale - 2022-01-02

      Yes. Now I am using 0.98.07 2021-07-24 build 1005. How do I check to see if patches are installed correctly? Timing is now adjusting correctly for different clock speeds but 0.5 MHz is lowest speed that works. 0.031 still does not. I did copy the new DAT file into the chipdata folder.

       
      • Anobium

        Anobium - 2022-01-02

        See https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/ for the zip patch. Unpack to your install - mine is

        Compiler Version: 0.98.07 2021-11-15 (Windows 32 bit) : Build 1050

         
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.