Hello,
I'm currently working on a project related to solar trackers. I have developed functions which are based on time in which the tracker will move. I'm only familiar with the "MC9S12DT256B" microcontroller as thats the board I've used during my studies at school. My question is: How can a microcontroller tell time? I know there are timers, but I've also read stuff about external clock sources and "Real Time Clock with Embedded Crystal". Which series of microcontroller should I be looking into? Are they attachable onto such microcontrollers? Any suggestions would be appreciated. Thank you.
EDKEdwin
Hello EDKEdwin, and welcome to the forum.
Depending on the expected complexity the project, and of your code, you may find that an 8-bit device (MC9S08 family) may be adequate for your task. This will provide a lower cost solution, possibly using a lower pin count device, and is likely to give a lower overall current draw, if this be important for the project. Migrating from the 16-bit device to 8-bits should not be a significant issue if you are already programming in C.
If using an external RTC device, the interface chosen should be either SPI or IIC (sometimes referred to as I2C). Most MCUs have one or both of these interfaces. The Intersil device linked within your post uses IIC. The coding for a SPI device will usually be simpler and easier to implement than IIC.
It is also possible to "build-in" the RTC functionality within the MCU code, provided you use an accurate external crystal for the MCU (probably 32.768 kHz). With this approach, you might wakeup the MCU from a low current STOP mode at accurate one second intervals in order to update the time and date values. The MCU chosen should contain a RTC module suitable for this purpose. Obviously, the coding would be more complex for this solution.
If using an external crystal for either an external RTC device, or the MCU, small errors in the crystal frequency must be taken into account, for accurate time-keeping. For an external RTC device, the crystal frequency would likely need to be trimmed using a variable capacitor. Of course, this additional complexity is not necessary if using an RTC device containing an integral crystal. The Intersil device would have a basic accuracy of about 13 seconds per month.
With the coded RTC approach, it would be possible to periodically correct for crystal frequency errors, without the need to trim the crystal. If necessary, it may even be possible to compensate for frequency errors due to temperature (using the internal temperature sensor within the MCU).
Regards,
Mac