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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
Step one. Select the correct chip.
then, set that chip to 31k
code.
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.
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.
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.
The first thing is.. what chip is planned to be used.
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.
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
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.
Once the power consumption is sorted then he can change the frequency, if required.
Last edit: Anobium 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
ok re piezo.
The LF works here. So, either check your code for a typo, or, post your code for our review.
I tried other clock speeds too; same "no chip dat file found for 12LF1501"
Here's my test code:
Have you installed the patch? Your code works here.
https://sourceforge.net/p/gcbasic/discussion/579125/thread/2c6dcb6b8e/?limit=25#003e/cd9c
The DAT file. Use the DAT in the latest patch.
See https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/ for new DAT files.
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
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?
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.
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.
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.
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.
Please install the lastest software, and, and apply the latest patches. Your software is seven years out of date.
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.
Updated the software ?
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.
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