Chronodot and LoL Shield conflict HELP!

Tick Tock Clock Kits

Moderators: adafruit_support_bill, adafruit

Chronodot and LoL Shield conflict HELP!

Postby GoolGaul » Wed May 16, 2012 12:09 pm

Hey all,

I am using a chronodot and a LoL Shield, and using the associated Charlieplex library and a host of different RTC libraries.

With ANY RTC example sketch, when I #include the Charllieplex library and add the required "LedSign::Init();" command to the setup(), the sketch crashes. When I '//' out the LedSign::Init(); command, the sketches all proceed properly.

The below attached code is not mine, it was written by Eric Ayars. I amusing it as it is the simplest way to show the problem I am having....

Code: Select all
}

void loop() {
   // send what's going on to the serial monitor.
   // Start with the year
   Serial.print("2");
   if (Century) {         // Won't need this for 89 years.
      Serial.print("1");
   } else {
      Serial.print("0");
   }
   Serial.print(Clock.getYear(), DEC);
   Serial.print(' ');
   // then the month
   Serial.print(Clock.getMonth(Century), DEC);
   Serial.print(' ');
   // then the date
   Serial.print(Clock.getDate(), DEC);
   Serial.print(' ');
   // and the day of the week
   Serial.print(Clock.getDoW(), DEC);
   Serial.print(' ');
   // Finally the hour, minute, and second
   Serial.print(Clock.getHour(h12, PM), DEC);
   Serial.print(' ');
   Serial.print(Clock.getMinute(), DEC);
   Serial.print(' ');
   Serial.print(Clock.getSecond(), DEC);
   // Add AM/PM indicator
   if (h12) {
      if (PM) {
         Serial.print(" PM ");
      } else {
         Serial.print(" AM ");
      }
   } else {
      Serial.print(" 24h ");
   }
   // Display the temperature
   Serial.print("T=");
   Serial.print(Clock.getTemperature(), 2);
   // Tell whether the time is (likely to be) valid
   if (Clock.oscillatorCheck()) {
      Serial.print(" O+");
   } else {
      Serial.print(" O-");
   }
   // Indicate whether an alarm went off
   if (Clock.checkIfAlarm(1)) {
      Serial.print(" A1!");
   }
   if (Clock.checkIfAlarm(2)) {
      Serial.print(" A2!");
   }
   // New line on display
   Serial.print('\n');
   // Display Alarm 1 information
   Serial.print("Alarm 1: ");
   Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);
   Serial.print(ADay, DEC);
   if (ADy) {
      Serial.print(" DoW");
   } else {
      Serial.print(" Date");
   }
   Serial.print(' ');
   Serial.print(AHour, DEC);
   Serial.print(' ');
   Serial.print(AMinute, DEC);
   Serial.print(' ');
   Serial.print(ASecond, DEC);
   Serial.print(' ');
   if (A12h) {
      if (Apm) {
         Serial.print('pm ');
      } else {
         Serial.print('am ');
      }
   }
   if (Clock.checkAlarmEnabled(1)) {
      Serial.print("enabled");
   }
   Serial.print('\n');
   // Display Alarm 2 information
   Serial.print("Alarm 2: ");
   Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);
   Serial.print(ADay, DEC);
   if (ADy) {
      Serial.print(" DoW");
   } else {
      Serial.print(" Date");
   }
   Serial.print(' ');
   Serial.print(AHour, DEC);
   Serial.print(' ');
   Serial.print(AMinute, DEC);
   Serial.print(' ');
   if (A12h) {
      if (Apm) {
         Serial.print('pm');
      } else {
         Serial.print('am');
      }
   }
   if (Clock.checkAlarmEnabled(2)) {
      Serial.print("enabled");
   }
   /* display alarm bits
   Serial.print('\n');
   Serial.print('Alarm bits: ');
   Serial.print(ABits, DEC);
   */

   Serial.print('\n');
   Serial.print('\n');
   delay(1000);

   // Display the time once more as a test of the getTime() function
   Clock.getTime(year, month, date, DoW, hour, minute, second);
   Serial.print(year, DEC);
   Serial.print(month, DEC);
   Serial.print(date, DEC);
   Serial.print(DoW, DEC);
   Serial.print(hour, DEC);
   Serial.print(minute, DEC);
   Serial.println(second, DEC);
}
GoolGaul
 
Posts: 10
Joined: Fri Feb 24, 2012 10:17 pm

Re: Chronodot and LoL Shield conflict HELP!

Postby adafruit_support_bill » Wed May 16, 2012 12:18 pm

the sketch crashes

What do you mean by "crashes"? What are the symptoms?
User avatar
adafruit_support_bill
 
Posts: 16055
Joined: Sat Feb 07, 2009 9:11 am

Re: Chronodot and LoL Shield conflict HELP!

Postby GoolGaul » Wed May 16, 2012 12:20 pm

oops, here is the whole sketch...

Code: Select all

/*
DS3231_test.pde
Eric Ayars
4/11

Test/demo of read routines for a DS3231 RTC.

Turn on the serial monitor after loading this to check if things are
working as they should.

*/

#include <DS3231.h>
#include <Wire.h>
#include <Charliplexing.h>

DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;

byte year, month, date, DoW, hour, minute, second;

void setup() {
 
//  LINE BELOW KILLS THE SKETCH 
//       LedSign::Init();                   // sketch only runs while this is commented out

     // Start the I2C interface
   Wire.begin();
   // Start the serial interface
   Serial.begin(9600);

}

void loop() {
   // send what's going on to the serial monitor.
   // Start with the year
   Serial.print("2");
   if (Century) {         // Won't need this for 89 years.
      Serial.print("1");
   } else {
      Serial.print("0");
   }
   Serial.print(Clock.getYear(), DEC);
   Serial.print(' ');
   // then the month
   Serial.print(Clock.getMonth(Century), DEC);
   Serial.print(' ');
   // then the date
   Serial.print(Clock.getDate(), DEC);
   Serial.print(' ');
   // and the day of the week
   Serial.print(Clock.getDoW(), DEC);
   Serial.print(' ');
   // Finally the hour, minute, and second
   Serial.print(Clock.getHour(h12, PM), DEC);
   Serial.print(' ');
   Serial.print(Clock.getMinute(), DEC);
   Serial.print(' ');
   Serial.print(Clock.getSecond(), DEC);
   // Add AM/PM indicator
   if (h12) {
      if (PM) {
         Serial.print(" PM ");
      } else {
         Serial.print(" AM ");
      }
   } else {
      Serial.print(" 24h ");
   }
   // Display the temperature
   Serial.print("T=");
   Serial.print(Clock.getTemperature(), 2);
   // Tell whether the time is (likely to be) valid
   if (Clock.oscillatorCheck()) {
      Serial.print(" O+");
   } else {
      Serial.print(" O-");
   }
   // Indicate whether an alarm went off
   if (Clock.checkIfAlarm(1)) {
      Serial.print(" A1!");
   }
   if (Clock.checkIfAlarm(2)) {
      Serial.print(" A2!");
   }
   // New line on display
   Serial.print('\n');
   // Display Alarm 1 information
   Serial.print("Alarm 1: ");
   Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);
   Serial.print(ADay, DEC);
   if (ADy) {
      Serial.print(" DoW");
   } else {
      Serial.print(" Date");
   }
   Serial.print(' ');
   Serial.print(AHour, DEC);
   Serial.print(' ');
   Serial.print(AMinute, DEC);
   Serial.print(' ');
   Serial.print(ASecond, DEC);
   Serial.print(' ');
   if (A12h) {
      if (Apm) {
         Serial.print('pm ');
      } else {
         Serial.print('am ');
      }
   }
   if (Clock.checkAlarmEnabled(1)) {
      Serial.print("enabled");
   }
   Serial.print('\n');
   // Display Alarm 2 information
   Serial.print("Alarm 2: ");
   Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);
   Serial.print(ADay, DEC);
   if (ADy) {
      Serial.print(" DoW");
   } else {
      Serial.print(" Date");
   }
   Serial.print(' ');
   Serial.print(AHour, DEC);
   Serial.print(' ');
   Serial.print(AMinute, DEC);
   Serial.print(' ');
   if (A12h) {
      if (Apm) {
         Serial.print('pm');
      } else {
         Serial.print('am');
      }
   }
   if (Clock.checkAlarmEnabled(2)) {
      Serial.print("enabled");
   }
   /* display alarm bits
   Serial.print('\n');
   Serial.print('Alarm bits: ');
   Serial.print(ABits, DEC);
   */

   Serial.print('\n');
   Serial.print('\n');
   delay(1000);

   // Display the time once more as a test of the getTime() function
   Clock.getTime(year, month, date, DoW, hour, minute, second);
   Serial.print(year, DEC);
   Serial.print(month, DEC);
   Serial.print(date, DEC);
   Serial.print(DoW, DEC);
   Serial.print(hour, DEC);
   Serial.print(minute, DEC);
   Serial.println(second, DEC);
}
GoolGaul
 
Posts: 10
Joined: Fri Feb 24, 2012 10:17 pm

Re: Chronodot and LoL Shield conflict HELP!

Postby GoolGaul » Wed May 16, 2012 12:33 pm

What do you mean by "crashes"? What are the symptoms?


the sketch just stops doing anything...

What led me to using all example stuff is that I didn't trust my programming. So when I set up an indication


In the sketch shown, all the Serial Monitor shows it "20"...

If I comment out the LedSign::Init(); the sketch runs fine.
GoolGaul
 
Posts: 10
Joined: Fri Feb 24, 2012 10:17 pm

Re: Chronodot and LoL Shield conflict HELP!

Postby adafruit_support_bill » Wed May 16, 2012 12:40 pm

Looks like LedSign.init() does some timer setup. You may have a timer conflict with one of your other libraries. Jimmie Rogers is the creator of the LoL shield and author of the library. He might be able to offer more insight into the problem: http://jimmieprodgers.com/
User avatar
adafruit_support_bill
 
Posts: 16055
Joined: Sat Feb 07, 2009 9:11 am

Re: Chronodot and LoL Shield conflict HELP!

Postby adafruit_support_rick » Wed May 16, 2012 12:43 pm

Looks like you are not calling Clock.init(), and I don't think you should be calling Wire.begin().

LedSign.Init() sets up Timer2. Are you doing anything else with Timer2?
User avatar
adafruit_support_rick
 
Posts: 2905
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Chronodot and LoL Shield conflict HELP!

Postby GoolGaul » Wed May 16, 2012 2:04 pm

The RTC libraries don't do anything with timer1/2. They are all just read and write routines to various addresses on the Chronodot.

When I run an example sketch for either Chalieplexing or RTC stuff, adding in only the minimum code to make the other component work, and INITing causes the conflict.

Considering that these 2 items seem to be a natural fit, I am surprised that no one else has had this issue...
GoolGaul
 
Posts: 10
Joined: Fri Feb 24, 2012 10:17 pm

Re: Chronodot and LoL Shield conflict HELP!

Postby adafruit_support_rick » Wed May 16, 2012 2:21 pm

What Chronodot library are you using?
User avatar
adafruit_support_rick
 
Posts: 2905
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Chronodot and LoL Shield conflict HELP!

Postby Stephanie » Wed May 16, 2012 2:39 pm

Another thing to look into is you might be running out of ram in the Arduino. It doesn't take much to fill up 2kB and if you're not looking for it, the sorts of problems it can lead to can seem like almost anything.
User avatar
Stephanie
 
Posts: 286
Joined: Sat Dec 11, 2010 12:17 am
Location: Canada

Re: Chronodot and LoL Shield conflict HELP!

Postby adafruit_support_rick » Wed May 16, 2012 3:02 pm

Good point, Stephanie. The LOLShield library does use quite a bit of RAM. But that should all be statically allocated whether he calls LedSign_Init() or not. I didn't spot any mallocs in Charlieplexing.cpp…

According to GoolGaul:
In the sketch shown, all the Serial Monitor shows it "20"...

So that means that it didn't actually hang in LedSign_Init() - it got past that and hung up someplace early in loop(), after he prints the Century. My guess is that it actually hangs in Clock.getYear(), which is the first place he actually calls the DS3231 library (that's why I was wondering what library he's using - the DS3231 library I found on GitHub doesn't have a getYear() member).

If this RTC library is doing malloc's when getYear is called, then it's entirely possible that the system could be running out of RAM.
User avatar
adafruit_support_rick
 
Posts: 2905
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Chronodot and LoL Shield conflict HELP!

Postby Stephanie » Wed May 16, 2012 7:18 pm

The reason I was thinking about running out of ram was seeing all those Serial.print("text") statements in there. All that text ends up in ram. Combined with the Charlieplex library which I've used, and learned it can take up a bunch of ram itself.

I'm not familiar with that particular DS3231 library either, but it's got to be doing some Wire writes then doing Wire reads so it might be trying to allocate ram for those operations.
User avatar
Stephanie
 
Posts: 286
Joined: Sat Dec 11, 2010 12:17 am
Location: Canada

Re: Chronodot and LoL Shield conflict HELP!

Postby GoolGaul » Wed May 16, 2012 7:26 pm

I got the library from this page: https://profiles.google.com/118318051758925338163/buzz/4BsbTeBScFk

It's all short routines, that either read or write a single byte at a time from the ds3231.


I'm still baffled. i don;t know about malloc, but I am going to read up on that now.

If I trim out some stuff that I don't need from the Library, could that help?

As a side note, I changed the original Charlieplex library that I am call in my project to only have 72 LED instead of the 126 that the library can control. that smaller array being declared eat up about 40% less RAM than the original array. I still get the same crash.

There always is the ability control my LEDs without using the library, but I tinkered with that a bit, and the charlieplex lib looks much better... less jittery.

I
GoolGaul
 
Posts: 10
Joined: Fri Feb 24, 2012 10:17 pm

Re: Chronodot and LoL Shield conflict HELP!

Postby adafruit_support_rick » Wed May 16, 2012 8:46 pm

Not a bad looking library, actually. I don't think that's your problem.
I think Stephanie nailed it. Start commenting out Serial.print() statements until it starts working for you.
User avatar
adafruit_support_rick
 
Posts: 2905
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Chronodot and LoL Shield conflict HELP!

Postby GoolGaul » Wed May 16, 2012 10:11 pm

yeah, the Chronodot library is a nice, clean, well-documented library.

The author responded to my question within the hour too - gotta love that!

I'm going to comment out some Serial.print()'s and see what happens.

I'll post an update for sure...

and a big thanks to all
GoolGaul
 
Posts: 10
Joined: Fri Feb 24, 2012 10:17 pm

Re: Chronodot and LoL Shield conflict HELP!

Postby GoolGaul » Thu May 17, 2012 9:04 am

On the RAM angle, i commented out HUGE sections of the DS3231 test sketch pointed out above, and in the process, took out dozens of Serial.print commands.

I did have to add in 2 for debugging. I put a Serial.print before and after the LedSign::init();
The pre-init line prints, the post init line doesn't.

again, the sketch seems to not progress beyond LedSign::init();

I also commented out the clock.getyear() to no avail.
It doesn't seem to be a bug in either sketch, I'm convinced it's some kind of conflict between the 2.


There is no "Clock Init" of any kind. The library doesn't need to be started or init'ed because it's all pre-addressed writes/reads.
The lib. doesn't use any Timers nor Interrupts.

I still can't believe that I am the only person to use these 2 rockin products together.
GoolGaul
 
Posts: 10
Joined: Fri Feb 24, 2012 10:17 pm

Next

Return to Clocks

Who is online

Users browsing this forum: No registered users and 1 guest

Stuff to buy from the Adafruit store and links to product documentation!


New Products [103]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]