Main Site Documentation

Cerbuino RTC help


#1

Hi all,

I’ve been playing around with my shiny new Cerbuino Bee, and I’m making a lot of progress. Now the time has come where I need a real time clock. Can anybody advise on how to connect the crystal and 3V battery? I’m a solid programmer, but somewhat of an electronics novice.

Cheers.


#2

Hi ThirdHorizon,

welcome to the forums. Obviously nobody does know otherwise they may have answered you the first time. I’ll take a look at the schematics and see what I can see and will post back here shortly


#3

OK, here goes.

VBAT pin appears to be on the Adruino header in the regular position. According to the image, the silkscreen shows it at “BAT”, right on the end of the header run near LED2. That needs to be connected to your coin cell’s + side. While talking about the coin cell, do you have a standard holder for it?

Then you need to solder the RTC crystal onto the correct location. Here’s where I struggle, because it doesn’t seem that there are pads to install it (like there are on the Hydra or Cerb40 for example). Gus/GHI team might have to tell us what pins you need to solder these to.


#4

The RTC pins are exposed on the arduino-headers. We will detail this in the wiki.


#5

Ah, if I understand the schematic, it looks like it’s pins D4 and D5. I’ll look out for the wiki update.

Yes, I have a standard holder for the coin cell.

Thanks Gus and Brett!


#6

Any updates on this, Gus?


#7

I forgot about it, sorry :slight_smile: Will pass it on to the right person to work on it.


#8

They are D3 (PC14) and D4 (PC15). Not D4, D5


#9

I have a cerbuino that I would like to stop setting the current time. If I have a crystal and a battery. Do I need anything else? I have been reading confusing items about certain caps, etc. Please clear this up for me.


#10

The wiki was greatly improved since this post was made. Please take a look http://wiki.tinyclr.com/index.php?title=Cerb-Family


#11

Thanks for the update on the wiki pages for the RTC. I have a couple of questions

  1. The Photos of the Cerberus seem to show the crystal being added between c10 and c11 and there are 2 sets of instructions regarding the caps themselves at c10 and c11. The text above says "Replace the C21 & C22 caps of Cerb40 (caps C10 & C11 on Cerberus). These need to be replaced with 8pF. " and the caption on the Photo says “The capacitors seen here on the Cerberus in these images are 18 pF each.” again looking at the photo, it appears like the caps are the ones the system came with.

Do caps c10 and c11 need replaced on the Cerberus when adding the Crystal?

  1. Once I have made the hardware changes, which library is the RealTimeClock in?

Thanks in advance,
Tal_McMahon


#12

Hi Tal_McMahon,

For Question number 1, providing that the Caps on your particular board are indeed 18 pF, then you should not really need to replace them unless you are experiencing some issues with the RTC. As the caption specified those were indeed 18 pF. If you are experiencing any unexplained issues with the RTC not functioning as expected, then you should replace the Caps with the recommended 8pF Caps as these are implied in the processor’s datasheet.

The answer for question 2 is GHI.OSHW.Hardware.


#13

I have a cerbuino. I placed two AA batteries across the batt and gnd pins of the cerbuino. I have placed a crystal (digikey part ser3205, 32.7680khz, 6.0pf) across digital io pins d3 and d4 of the cerbuino. I added the following code to the main of my applicaiton. The time is not set. The RTC is reporting the time being in year 1980, etc. Can you point me in a direction to get it working. Not sure what to try next.

    public static void Main()
    {
        Debug.Print("Starting Cerbuino");

        RTC.SetTime(new DateTime(2012, 10, 25, 12, 20, 0, 0)); // Set once to set the RTC.
        DateTime dt = RTC.GetTime(); // Get RTC time.
        Utility.SetLocalTime(dt); // Set system clock.

#14

Judging from your picture, the crystal may not be making a very good connection for the RTC to stabilize. I would suggest to maybe solder the crystal to extension pins like a header or to some kind of large wire to make a better connection.


#15

Also see this page on the wiki (http://wiki.tinyclr.com/index.php?title=Cerb-Family#Real_Time_Clock) for an image of what I mean about using extension wires to connect the RTC Crystal.


#16

Thanks I fixed the crystal and the battery as suggested. When I re-ran I got the same results. Year still 1980. I then browsed the RTC class in GHI.OSHW.Hardware and saw the Initialize method. Then I added the call to RTC.Initialize and then the date was set. Year now 2012. Then I played around with the methods and I now am not sure if I really need the call to Initialize.

BTW: I think the crystal was not seen by the cerbuino until I soldered the legs to a wire. Thanks for the suggestion Aron!

So Now I realize the year is correct but the day is not. It is exactly 21 days behind. Very weird! Anyway here is the code I have now

        //RTC.Initialize();
        //RTC.SetTime(new DateTime(2012, 10, 25, 15, 24, 0)); // Set once to set the RTC.
        Utility.SetLocalTime(RTC.GetTime().AddDays(21)); // Set system clock.

Does anyone have an idea why the AddDays(21) is needed? and if the RTC.Initialize is needed?


#17

There is a bug in the Library Function that does not return the correct date. We will be fixing that bug soon for an upcoming release of the OSHW SDK.

As for Initialize, I believe it only needs to be called once to initialize the RTC registers. Once the registers are active, as long as there is proper power to the VBAT, the registers stay active until total power shutdown including the backup battery.


#18

My RTC date is also off, by six days for some odd reason. And yes, you only call Initialize() once. Call it again and you’ll lose data. I’m using this code…

DateTime rtcDate = GHI.OSHW.Hardware.RTC.GetTime();
if (rtcDate.Year < 2013)
{
GHI.OSHW.Hardware.RTC.Initialize();
}

Utility.SetLocalTime(GHI.OSHW.Hardware.RTC.GetTime().AddDays(6));


#19

What version of the firmware are you using?


#20

This is the firmware I have…

ClrInfo.clrVersion: 4.2.0.0
ClrInfo.clrVendorInfo: Copyright GHI Electronics, LLC
ClrInfo.targetFrameworkVersion: 4.2.0.0
SolutionReleaseInfo.solutionVersion: 4.2.3.3
SolutionReleaseInfo.solutionVendorInfo: Copyright © GHI Electronics, LLC
SoftwareVersion.BuildDate: Nov 19 2012
SoftwareVersion.CompilerVersion: 410462

It appears to be using the Day of Week instead of the Day when I call GHI.OSHW.Hardware.RTC.SetTime

I looked online and eventually found this page detailing the fix of this bug…
http://ghiopensource.codeplex.com/SourceControl/changeset/22347

So then I checked the version of my GHI.OSHW.Hardware.dll and found I was on 4.2.3.0 instead of 4.2.3.1. I simply removed the DLL from my list of references, re-added it and wala … Eveything is working.