Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need real time clock

Status
Not open for further replies.

MikeMl

Well-Known Member
Most Helpful Member
I need a module which has a single output: high when the "time of day minute" divided by two is even, low when the "time of day minute" divided by two is odd. I am assuming that the minute runs 0-59.

The accuracy of the time keeping should be comparable to a wristwatch, or could be auto-setting from WWVB.

Anybody have something that would work "off the shelf", or do I have to use one of these and an Arduino?
 
I odnt know of a chip that'll do that, but there is a Ds3231 which is a temp compensated accurate clock, and has a configurable 1 hz o/p, it and a 4040 and a few diodes could be rigged up to give 1 pulse every 2 minutes.
 
I would definitely favor the DS3231 over the DS1307. As Dr. Pepper said, it's temperature compensated, so it's very high accuracy. In over a year of operation, one of these I'm using in a clock has drifted by less than 2 minutes.
 
I odnt know of a chip that'll do that, but there is a Ds3231 which is a temp compensated accurate clock, and has a configurable 1 hz o/p, it and a 4040 and a few diodes could be rigged up to give 1 pulse every 2 minutes.

My requirement is that the output changes when the "time-of-day minute" rolls from say 11:39:59 to 11:40:00
 
As you only want accuracy 'comparable to a wrist watch' a simple PIC with a 32KHz clock crystal on TMR1 would easily do what you require, it's trivial to set it to generate an interrupt every second, and simply invert an I/O pin in the ISR.

There's no reason to keep count of anything, not even the seconds, so it can just toggle the pin and that's it.

You're unlikely to find anything 'off the shelf' as it's a pretty obscure requirement.
 
You can certainly use a DS3231 and, specifically, its alarms which can be set to once a minute. Doing so (with the alarms) pretty much means also using a controller and I2C. You don't need a full blown board like an Arduino, a cheap picaxe 08m2 would work fine.

Edit: the solution offered by Nigel makes much more sense as long as you are just interested in an interval-based signal rather than an accurate RTC rollover.
 
As you only want accuracy 'comparable to a wrist watch' a simple PIC with a 32KHz clock crystal on TMR1 would easily do what you require, it's trivial to set it to generate an interrupt every second, and simply invert an I/O pin in the ISR.

There's no reason to keep count of anything, not even the seconds, so it can just toggle the pin and that's it.

You're unlikely to find anything 'off the shelf' as it's a pretty obscure requirement.
What is a wrist watch's accuracy anyways?
 
I need a module which has a single output: high when the "time of day minute" divided by two is even, low when the "time of day minute" divided by two is odd. I am assuming that the minute runs 0-59.
that's easier than you think, assuming you have BCD or binary parallel output lines, just take the "1" output from the minutes, and invert it.
 
Edit: the solution offered by Nigel makes much more sense as long as you are just interested in an interval-based signal rather than an accurate RTC rollover.

It's pretty simple to do a full clock calendar as well, but that didn't seem required from what he's said.

In fact there's even a MicroChip application note that uses a PIC as an I2C slave clock/calendar - sort of a home made DS1307 :D

As far the DS1307/3231 goes, you could obviously use that in conjunction with a processor, but for simple once per second toggling there doesn't seem much point?. What I usually do with the DS's is set them up to output one second pulses, and use that as an interrupt input to the PIC (which then would read the DS in the ISR and update the display) - you could use that interrupt to toggle the I/O pin as I suggested above. However, it seems a waste of a DS chip?.
 
It's pretty simple to do a full clock calendar as well, but that didn't seem required from what he's said.

In fact there's even a MicroChip application note that uses a PIC as an I2C slave clock/calendar - sort of a home made DS1307 :D

As far the DS1307/3231 goes, you could obviously use that in conjunction with a processor, but for simple once per second toggling there doesn't seem much point?. What I usually do with the DS's is set them up to output one second pulses, and use that as an interrupt input to the PIC (which then would read the DS in the ISR and update the display) - you could use that interrupt to toggle the I/O pin as I suggested above. However, it seems a waste of a DS chip?.

Agreed. The TS did make mention of a specific need, but maybe just to describe the function.
My requirement is that the output changes when the "time-of-day minute" rolls from say 11:39:59 to 11:40:00

I have had good success using the 3231 to make time-based switches to do stuff every XX minutes or once a night - that kind of thing and they work well.

I wonder too if using the 50/60 Hz line frequency (after a step down transformer) as the source of the pulses that could be counted with a few other chips.
I remember making a binary clock (a picture is in https://www.electro-tech-online.com...te-air-inlet-and-air-outlet-to-a-case.155583/) using that 60 Hz line and it kept time pretty darn well, until you turned it off. ;)
 
I wonder too if using the 50/60 Hz line frequency (after a step down transformer) as the source of the pulses that could be counted with a few other chips.
I remember making a binary clock (a picture is in https://www.electro-tech-online.com...te-air-inlet-and-air-outlet-to-a-case.155583/) using that 60 Hz line and it kept time pretty darn well, until you turned it off. ;)

Mains frequency is an excellent choice for time keeping, as it's kept very accurate long term - historically they used to correct it during the night, speeding up or slowing done the mains to correct it. I remember old pictures of power stations with two clocks, one a highly accurate clock, the other mains driven, so they could compare the two and correct the mains one.
 
I recently viewed the highly accurate loran signal using my 'scope set to trigger from the line, to my surprise it was pretty stable.
 
I want to use the WSPR ham-radio digital mode on HF (1.8 to 18MHz) to compare two antennas. WSPR transmits on low power (a Watt) and the signals are heard all over the world and reported via the internet. A WSPR transmission lasts just under 2 min, and starts +-1sec at 0, 2, 4, ..., 58 minutes past the hour.

The transmission is generated by a program that runs on a PC. The timing is based on the PC's time of day clock. All transmission start at the beginning of a two-minute period, last two minutes, and the PC is busy decoding transmissions from other stations for a couple of two minute periods before transmitting again.

The radio that is making the transmission is controlled via USB by the PC.

Here is what I would like to do:

Using the RTC and an Arduino, I will control an antenna RF switching relay, based on time of day. If the two min period is odd, I will select antenna A. If the two min period is even, I will select antenna B. I will let the WSPR program run for up to 24 hours at a time, and then download hundreds of spots from all over the world as a text file.

Since every spot is timestamped, it should be relatively easy to parse the file to separate the spots based on the odd or even period (which antenna was used) when they were transmitted. Since each spot includes an SNR, it should be possible to draw conclusions about which antenna is better (more gain, efficient, directive).

If I was more of a PC programmer, I suspect I could write a PC program that would toggle a bit in some serial port in step with the two min periods based on the RTC in the PC, but that program would have to run in the background concurrently with the WSPR application.

Whatever I do using the Arduino approach must have a provision for "setting" the RTC to actual time, +-1sec.
 
As you only want accuracy 'comparable to a wrist watch' a simple PIC with a 32KHz clock crystal on TMR1 would easily do what you require, it's trivial to set it to generate an interrupt every second, and simply invert an I/O pin in the ISR.

There's no reason to keep count of anything, not even the seconds, so it can just toggle the pin and that's it.

You're unlikely to find anything 'off the shelf' as it's a pretty obscure requirement.

I have lost the ability to program pics, but use Arduinos all the time. I wonder if the untrimmed crystal in a standard Atmega-based Arduino mini would be close enough not to drift +-1 sec in a 48 hour period?

I could use a momentary push button to sync the Arduino code to WWV. Only problem is that I can only do that once every four minutes:(

Maybe I could just use this function:


millis() [Time]
Description
Returns the number of milliseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days.
Syntax
time = millis()
Parameters
Nothing
Returns
Number of milliseconds since the program started (unsigned long)
 
Last edited:
If you are going to go the Arduino route, I would suggest a DS3231 RTC. They can be had for a few bucks and you can use a time server to set the clock and be done with it, for the most part.

Reading the time is plenty easy, especially if you just want to check minutes when seconds goes to zero. If you wanted to be fancy, you could use interrupts, but if all your program is doing is switching a relay, you don't even need to do that.

Edit: I should add if you don't have wifi to set the clock, you can probably use the current PC at compile time to set it - seems like I have done that before.
 
Last edited:
I used a Wemos mini to fetch the time from the internet via WiFi every 15 mins. Then used millis() to keep time. Spot on accuracy but WiFi needed.

Mike.
 
Get yourself a cheap wwvb receiver & rig up your arduino to decode the time using it, just mod the code to toggle an o/p every odd minute.
Hurry up though they are chucking wwvb in the skip soon, I odnt know what you guys will use to sync the country securely when that happens.
 
i keep the machine i use for SDR work (including WSPR/JT65) synced using a cron job that runs "ntpdate time.nist.gov" every 30 minutes
 
i keep the machine i use for SDR work (including WSPR/JT65) synced using a cron job that runs "ntpdate time.nist.gov" every 30 minutes

I am not trying to sync the PC. I am trying devise a method of flipping an antenna relay to select different antennas based on when a given transmission was made...
 
Are you transmitting or receiving? Which ever it is, can you use the previous packet to decide which aerial to use for the next?

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top