Alarm using picaxe08m

Mike.

Member
Hello guys I have :

PICAXE08M AND DS1307

At the input(adc) the potentiometer is set...
Varying value of potentiometer will set appropriate alarm at output.

I have 100k potentiometer.
If I turn the potentiometer value to 20k then the alarm should give alert after 1hr.
If I turn the potentiometer value to 40k then the alarm should give alert after 2hr.
If I turn the potentiometer value to 60k then the alarm should give alert after 3hr.
If I turn the potentiometer value to 80k then the alarm should give alert after 4hr.
If I turn the potentiometer value to 100k then the alarm should give alert after 5hr.

thanks in advance friends..
 

eclectic

Moderator
Assuming the OP requires code, there are two problems.

1. 100k is very high. 10k is better.

2. 08M not 08M2? No built in I2C capacity
 

srnet

Senior Member
Ok I can use 10k and 08M2.

what other thing i will need..
A battery, download circuit, program lead, some resistors for a start.

I would start by connecting up the PICAXE and writing some code to set a variable to 1 - 5 depending on the position of the potentiometer.

As for what other stuff you need, you would have to provide a lot more detail of what it is you are trying to do.
 

Dippy

Moderator
Mike,

Check the reference to 'potentiometer' in Manual 3 page 28.

Then read up on ReadADC and ReadADC10 in Manual 2 (BASIC).

That should get you started.

Are you referring to the circuit.... the Manual3 reference shows you.
 

eclectic

Moderator
Just random thoughts.

Does the OP require five steps?

Or, a continuum of time values from minutes to hours?

If it's the latter, then

1. Set the clock, including the "ticks"
Then, re-purpose the sda and scl pins.

2. ReadADC and press "start"

3. Calculate the number of seconds required.

4. Count the "ticks"

5. Sound the "alarm"

e
 

JimPerry

Senior Member
No need to set the clock - just count the ticks 3600 for an hour - so no need to calculate - just look up the fixed period that matches the ADC range when Start is pressed.
 

jedynakiewicz

Senior Member
No need to set the clock - just count the ticks 3600 for an hour - so no need to calculate - just look up the fixed period that matches the ADC range when Start is pressed.
Following on from Jim's idea, why not set the hours with a simple BCD (Binary-Coded-Decimal) switch? You can use three pins for the BCD switch, giving you 1-8 hours; one pin to get the one-second pulse from the DS1307; one pin for the start switch and you have one pin left over for the alarm output. The problem with the potentiometer is that it does not latch. Alternatively, stick with the ADC idea but substitute a series of fixed-value resistors on a rotary switch. This would be much more definitive as you select the time.
 

JimPerry

Senior Member

PaulRB

Senior Member
Mike,

Setting the time with a potentiometer is not going to be very accurate. it will be difficult to set the time accurate to 1 minute over 10-60 minutes.
If this is acceptable, maybe you do not need the ds1307. You could use the picaxe's internal timer instead. See "time" function in manual part 2. I think the time resets to zero after 65536 seconds, but that is 18 hours, so it might be ok.

You will also need some kind of audible or visual alarm. What will that be?

Paul
 

PaulRB

Senior Member
You can use three pins for the BCD switch, giving you 1-8 hours; one pin to get the one-second pulse from the DS1307; one pin for the start switch and you have one pin left over for the alarm output.
I don't think the ds1307 outputs 1 second pulses by default. You have to send a command over i2c bus to enable that, so you would need 2 pins for that.

Paul
 

PaulRB

Senior Member
Mike, I think you should keep things simple for your first picaxe project.

This may be accurate enough, try it and see if it is acceptable. I think it might be.

Just connect a pushbutton and a piezo sounder to the picaxe. Forget the DS1307 for now. Each time the button is pressed, add 600 seconds to the required time and make a short beep (sound command). Then make a tick sound approximately every second (pulsout command) to show the timer is running. When the time is up, you can play a tune (play command).
 

nick12ab

Senior Member
I don't think the ds1307 outputs 1 second pulses by default. You have to send a command over i2c bus to enable that, so you would need 2 pins for that.
According to the datasheet:
Please note that the initial power-on state of all registers is not defined. Therefore, it is important
to enable the oscillator (CH bit = 0) during initial configuration.
However I find that the oscillator is never enabled on power-up (seconds are always $80) but that might be dependent on the actual chip.
 

hippy

Ex-Staff (retired)
However I find that the oscillator is never enabled on power-up (seconds are always $80) but that might be dependent on the actual chip.
That may depend on hardware and circuit configuration. If the DS1307 has been maintaining its time on battery backup then it's my understanding that the CH bit should be clear when main power is restored if it had previously been cleared.
 

nick12ab

Senior Member
That may depend on hardware and circuit configuration. If the DS1307 has been maintaining its time on battery backup then it's my understanding that the CH bit should be clear when main power is restored if it had previously been cleared.
Of course, but if it's on battery then when normal power is restored then that's not 'powering up' because it's already powered by the battery. However static electricity or other strong interference could cause the CH bit to become set again even when the chip is powered.
 

jedynakiewicz

Senior Member
I don't think the ds1307 outputs 1 second pulses by default. You have to send a command over i2c bus to enable that, so you would need 2 pins for that.

Paul
Paul, I was following on from Eclectic's concept of setting up the DS1307 and then repurposing the I2C pins. Anyway, a simple lithium cell in circuit would keep the DS1307, once set, producing 1 second ticks ad infinitum - or at least for 10yrs.
 

PaulRB

Senior Member
Paul, I was following on from Eclectic's concept of setting up the DS1307 and then repurposing the I2C pins. Anyway, a simple lithium cell in circuit would keep the DS1307, once set, producing 1 second ticks ad infinitum - or at least for 10yrs.
OK, yes you could do that, but would you want to risk it? What if your cell was a dud and gave up after a year? I suppose you could put jumpers on your PCB so that you could connect the picaxe pins to either the i2c bus or the potentiometer or bcd thumbwheel or whatever, allowing you to program the rtc after a cell replacement, then reload the timer program and change the jumpers back again. All a bit of a bother though! You would be better off using a 14m2 so the jumpers were not needed.

My main concern now is that with all our technical long winded discussions, we have frightened Mike away!

Mike, are you still out there?
 
Top