Programming DS3231 with alarms for standalone use

PCCODER

New Member
Hi

I see using PICAXE Editor 6 there is a RTC wizard.
I was wondering how do I modify the code to add a alarm at 9am and 7pm seven days a week with using the output register INTCN and pin INT/SQW.

Also it is easy to use a 8M2 or 14M2 to load the program into the DS3231 and then remove the chip. so the DS3231 runs on its own and changes
outputs on the INT/SQW pin when the alarm conditions are met. DS3231 will be supplied with backup battery and 5v supply so it say programed once done.

Thanks for your help in advance.
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

Reading the DS3231 datasheet it seems setting the alarms times should be easy enough, just requires the right data bytes to be written to the alarm time registers and a few control bits to be set in other registers. There may be example code for doing that on the forum and/or members can probably help with that.

I might be wrong because I haven't used a DS3231 but it doesn't seem it is possible to program the DS3231 for standalone use. The way I read it is, once an alarm has matched, the INT/SQW alarm output remains asserted until the appropriate bits in the registers are cleared (A1F,A2F), and that could only be done over the I2C bus, and would need a PICAXE attached to do that.

It might be possible to use the INT/SQW signal to power-on a PICAXE which then simply clears the appropriate bits to minimise power consumption to an absolute minimum.

Added : An additional issue is how the clock responds to daylight saving time and even slightly drifting out of sync with real world time which could make having PICAXE attached mandatory.
 

PCCODER

New Member
Thanks hippy and westaust55 for your replies.

So I must have read it incorrectly as I thought when the alarm conditions were met and then output pin INT/SQW went low for a time and then returned to normal.

You are right hippy, it looks like that the alarm flag needs to be cleared by the microcontroller to reset the output INT/SQW which gets updated every second.

Also to clear the A1F,A2F registers do I need to use both SDA and SCL or can I just use one. I say this as I only have one pin spare. otherwise I will need to deploy another 8M2 micro

Makes the design more complex and I just got started using the Flowchart programming via PICAXE Editor 6.
 

Hemi345

Senior Member
You'll need to use both SDA and SCL (they're mutually dependent). Can you possibly use the Serial Out pin (leg 7) for an output to free up both SDA and SCL? If not, you may need to step up to a 14M2.

Show us a circuit schematic of your design and I'm sure you'll get a bunch of suggestions to making this work.
 

hippy

Technical Support
Staff member
It might help to describe what you are attempting to achieve, what your project will do, what outputs and inputs it will have, rather than detail how you are currently trying to achieve it.

You appear to have two input switches (SW1,SW2) and those could be combined into a single analogue input signal using a few resistors to free up a pin. The clock's INT/SQW pin could perhaps be combined with those as well, freeing up another.

Striving to use the smallest PICAXE is often a false economy with the cost of the effort of trying to achieve that greatly outweighing moving to a larger, more appropriate, easier to use PICAXE.
 

PCCODER

New Member
Hi

It is a blind controller I am making.
sw1 and sw2 are inputs from another board which has a touch control (TTP224), power supply is from a 5v regulated supply.
sig,5v,0v is the servo connecter.
programming connector is for the 8m2 for programming.
jack is the programming jack.
pin 5 and pin 6 is free.

on the ds3231
there is a battery disconnect jumper.
power disconnect jumper.
also pins for external connection for SCL and SDL, OV (many remove them if I connect chip directly to 8m2)

I was going to use the ds3231 to controller the opening of the blinds in the morning and closing at night in case I forgot to close them.
also sw1 and sw2 are used to manuals control the blinds to your liking.
 
Top