clock

67 views
Skip to first unread message

zet....@gmail.com

unread,
Apr 19, 2021, 5:23:03 PM4/19/21
to jallib
LS
I hope someone can help me.
Does a library excist with timezone Amsterdam so the microprocessor can use it to send an order to start or stop a device every day at the same time? 
ZetWeeh

Oliver Seitz

unread,
Apr 20, 2021, 2:05:17 AM4/20/21
to jal...@googlegroups.com
Hi Zet,

that question is in fact a lot of questions. 

A microcontroller in general does not know anything about time. It has no operating system, which makes things more complicated in some cases, but helps a lot when speaking about speed and reliability.

Libraries can assist with dealing with things an operating system does on a "standard computer".

If you're speaking about "time zones", you need to know what time it is. Usually, a computer knows the time using internet time servers, or radio clocks, or GPS receivers. A microcontroller by itself doesn't have any of these.

A microcontroller has its system frequency generator, which can be a crystal, or an internal rc oscillator. You can choose at which frequency your microcontroller should run, with 8 bit PICs today up to 64MHz. The controller can count the pulses of that frequency. If you want to run something now and tomorrow at the same time, just run it now and then wait for 64000000*24*60*60 pulses, then run again. The controller doesn't need to know what time it is for that purpose.

If you do want to have a clock time, there are date/calendar libraries to help you to transform that clock pulses in a human-readable time, but you will also need to set the clock every time you're starting the controller.

If you're using the internal frequency generator, it's not guaranteed
to be very accurate, it can be around 2% (=half an hour per day) fast or slow.

Greets,
Kiste


Am Montag, 19. April 2021, 23:51:58 MESZ hat zet....@gmail.com <zet....@gmail.com> Folgendes geschrieben:
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/5b7be137-cda7-47c7-a198-5914804ebf85n%40googlegroups.com.

Rob CJ

unread,
Apr 20, 2021, 3:44:13 AM4/20/21
to jal...@googlegroups.com
Hi Zet,

In addtion to this. If you want to use a clock with your microcontroller you can either use a clock-ic for that (like a DS3231) or you build a clock in software but as Oliver said, you need a crystal on your microcontroller and not use the internal oscillator.

BTW. It is possible to run a PIC on a 32 kHz crystal. That makes it very easy 🙂.

Kind regards,

Rob


Van: 'Oliver Seitz' via jallib <jal...@googlegroups.com>
Verzonden: dinsdag 20 april 2021 08:05
Aan: jal...@googlegroups.com <jal...@googlegroups.com>
Onderwerp: Re: [jallib] clock
 

Eur van Andel

unread,
Apr 20, 2021, 3:45:10 AM4/20/21
to jal...@googlegroups.com
Hi Zet

Olivier Seitz has said a lot of useful things about keeping time already. I can add that some  PIC18Fs have hardware real time clocks, some even with support for a 32kHz watch crystal on special pins. This will be accurate to minutes per year. 

Keeping time is of no use without syncing. That also holds for calendars. Syncing is so important for agriculture that several ancient civilisations spent insane amounts of work erecting huge stones to sync their calendars with the orbit of the planet. 

If you want to sync your time, you need to connect to a network. I do this in several ways:

- with an RN171 wifi module, which is end-of-life, so not recommended
- with an ESP32 which is cheap but overkill
- with a SIM800L GSM module, which needs a SIM card

SIM cards with data prices of €0.01/MB can be bought for €10 at keepgo.com
The SIM800L can be bought on AliExpress for €2
I wrote a library for the SIM800, which I can add to jallib if you are interested. The SIM800 is 2G only, so your country should still support that. Europe does. 

The mobile network knows both the time, the time zone and the local DST. (Daylight Savings Time)

A low cost solution could be a local “Stonehenge” with a narrow slit and a small solar cell that gives a good signal in direct sunlight. This would require a fixed location for the hardware and an unobstructed view to (a part of) the southern sky. You will also have to do some astronomical calculations. The Druids in England did those 5000 years ago, without the internet, so that won’t be too hard. 

You will be on solar time and syncing with a calendar will be hard, next to impossible. So when the DST kicks in will be unknown. 


On 19 Apr 2021, at 23:23:03, zet....@gmail.com <zet....@gmail.com> wrote:

Does a library excist with timezone Amsterdam so the microprocessor can use it to send an order to start or stop a device every day at the same time? 


---
Fiwihex B.V. Wierdensestraat 74, NL7604BK Almelo, Netherlands
tel+31-653-286573




zet....@gmail.com

unread,
Apr 23, 2021, 5:31:19 AM4/23/21
to jallib
Hi
Thanks for all the information.
I have to read a lot.
Till then I buy a cheap timer in the shop on the corner.
Peter

Op dinsdag 20 april 2021 om 09:45:10 UTC+2 schreef Eur van Andel:

vsurducan

unread,
Apr 23, 2021, 5:40:29 AM4/23/21
to jal...@googlegroups.com
Eur, an analog clock which does tic-tac, shows accurate time twice per day. It does not need synch. :)
The real question is how we do know that the network time is accurate indeed? It is synchronized with an atomic clock? :)
best wishes,

--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.

Oliver Seitz

unread,
Apr 23, 2021, 5:48:10 AM4/23/21
to jal...@googlegroups.com

An analog clock with hands usually *never* shows the right time, unless it doesn't run, only then it shows the correct time twice a day.

And no, the internet time is not synced to an atomic clock, but to a network of atomic clocks around the world.

Greets,
Kiste



Am Freitag, 23. April 2021, 11:40:30 MESZ hat vsurducan <vsur...@gmail.com> Folgendes geschrieben:
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/CAM%2Bj4qsTho1s-%3D_nve92Y2qnaRZx5-5orXG7gY1MVYCgg_6WEg%40mail.gmail.com.

vsurducan

unread,
Apr 23, 2021, 10:12:11 AM4/23/21
to jal...@googlegroups.com
Kiste, correctly said about analog (I've missed a "not" in front of "tic-tac") . However we lived with that for more than 2000 years (trully.. much more) and we are alive...I think we can live as well without synch on embedded systems.
Bresenham's (and Eur knows that) assure about +/-10s...+/-20s error per month error after a reasonable quick calibration from an ordinary crystal. Using TCXO or VCTCXO goes this error below +/-10s. That was verified on various projects I did.
Of course it's easiest if you do not need to do any calibration.
best wishes!

rob...@hotmail.com

unread,
Nov 7, 2021, 4:34:33 AM11/7/21
to jallib
Hi all,

This is an older post but I want to give you an update on this. ZetWeeh sent me a GPS Module (thanks ZetWeeh), the NEO-6M from which I made small library to extract the GPS time and date. This seems to work fine but as said it is a GPS module so it offers much more functionality than date and time only. I could upload this limited library to Jallib with only these time and date features. Updating it with the other GPS features will take much more time and I wonder if anybody has any plans to use GPS (location) with a PIC. If not then I will upload this library to Jallib.

Kind regards,

Rob


Op vrijdag 23 april 2021 om 16:12:11 UTC+2 schreef vasile:

rob...@hotmail.com

unread,
Nov 14, 2021, 8:18:56 AM11/14/21
to jallib
Hello all,

Just for fun I created a GPS Real Time Clock with the NEO-6M JAL library since the sample file I created was just to show that it works.

BTW. It the library and the sample file needs to be uploaded to Jallib. For now I will not implement the GPS location functionality, only the GPS time and GPS data are implemented in this library.

The GPS Real Time Clock project can be found at Instructables where you also find the video that shows that it works correctly, see https://www.instructables.com/JAL-GPS-Real-Time-Clock/

Kind regards,

Rob


Op zondag 7 november 2021 om 10:34:33 UTC+1 schreef rob...@hotmail.com:

vsurducan

unread,
Nov 14, 2021, 12:39:12 PM11/14/21
to jal...@googlegroups.com
Cool Rob!
GPS can be used for designing high precision disciplined oscillators replacing the rubidium oscillators. They have only one disadvantage, they need an external antenna to catch at least three satellites... A very long story (but an interesting one) is here:

Rob CJ

unread,
Nov 17, 2021, 1:22:14 PM11/17/21
to jal...@googlegroups.com
Hi Vasile,

Thanks. I saw the article but a bit long story as you already mentioned.

The library (and the demo) was meant to show that you can get the time - and date - from some external source (like in this case GPS).
 
Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens vsurducan <vsur...@gmail.com>
Verzonden: zondag 14 november 2021 18:38

Aan: jal...@googlegroups.com <jal...@googlegroups.com>
Onderwerp: Re: [jallib] clock
Reply all
Reply to author
Forward
0 new messages