Very mixed results/phenomena with battery logging

For problems with Gamebuino itself, NOT your project

Very mixed results/phenomena with battery logging

Postby lastfuture » Sat Jul 19, 2014 1:05 pm

Hi,

I was trying to find out how different things affected the battery so I took the battery logger example and modified it slightly to have the backlight on, play notes constantly, and other variations.

I'm having freezes and very mixed results with the battery logger though. Here's what happened:

Once the original unmodified battery logger example ran for 12 hrs and a couple of minutes, then it froze playing a shrill sound out of the speaker out of nowhere. The log only contained 5 values (ending at 4099 mV) but a few minutes before it froze I saw the seconds still ticking up on screen. What could have happened here? did the Battery.txt get overwritten mid-freeze and it didn't write all values back?

Once it ran for 4+ hours then froze silently, the log having only 12 entries ending at 4028 mV. That version of the logger also output the cpu load on screen, the logging was unchanged.

Two times it ran until the battery went flat, both times playing a new gb.sound.playNote every frame, once with and once without backlight and both displaying cpu load on screen, unmodified logging. When I returned to the device the "no battery" message was on the screen both times, so I assume it didn't freeze but ran through. The log seems plausible as well: 19 entries ending at 3557 and 21 entries ending at 3506 mV.

I wonder why two of my four attempts resulted in freezes. The screen was frozen with the last thing displayed, the other time it was completely blank. I'd love to know what to do to increase reliability, I'm going to use Gamebuino in projects for which I'd like to minimize failure. I'd also love to use some form of logging in my projects.

What all four measurements had in common was that I configured arduino to rotate the screen 180 degrees, and I manually went in and changed the startup sound to
const uint16_t startupSound[] PROGMEM = {0x238,0x7849,0x1468,0x0000};
to make it more Game Boy like and I zeroed out the gamebuinoLogo[], simply replacing all ones with zeroes, just to mess around.

I'm assuming none of these are responsible for the weird behavior though.

Any ideas?
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Very mixed results/phenomena with battery logging

Postby rodot » Sat Jul 19, 2014 1:34 pm

Mmh, to me it's likely to come from the micro SD card library. I were you I would try to ran the battery logger with everything related to the micro SD card commented out. I would also run the all in one example of the tinyFat library to check if it's reliable and compatible (there is some weird compatibility issues with micro SD cards).
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Very mixed results/phenomena with battery logging

Postby lastfuture » Sat Jul 19, 2014 2:29 pm

I'll try your suggestions, I'll also try another Micro-SD card if the included one misbehaves.
I have a 4 GB one that I don't use, is that within limits? I can't remember if the maximum size supported was 4 GB or something else
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Very mixed results/phenomena with battery logging

Postby rodot » Sat Jul 19, 2014 2:36 pm

The bootloader only support FAT16, which means that your micro SD card must be 2GB or less.
I just want to make sure that the problem comes from the micro SD card (and not the formatting, the bootloader or something else) if it's the case I'll send you a replacement one.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Very mixed results/phenomena with battery logging

Postby lastfuture » Sat Jul 19, 2014 2:58 pm

I've also had problems with tinyFATs all in one demo.
I can execute commands but at some point it just stops and I have to turn Gamebuino off and on. Sometimes when trying to write a line of text into a file, sometimes when trying to list files, sometimes when trying to view contents of files in text mode...

If this is not supposed to happen I'll have to test with another SD card to find out if it's the card or anything else. I have no micro SD below 4 GB, can I make my 4 GB one appear smaller? (by partitioning it or by dd'ing some special thing?)
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Very mixed results/phenomena with battery logging

Postby lastfuture » Sat Jul 19, 2014 3:07 pm

Next I'll try the SD-disabled battery logger.
I've kept as much of the sketch intact as I could in case it's the buffer or anything else:
Code: Select all
//#include <tinyFAT.h> //requires the tinyFAT library. You can download it here : http://www.henningkarlsen.com/electronics/library.php?id=37
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

char buffer[7];

void setup(){
  gb.begin();
  gb.titleScreen(F("Battery logger"));
  gb.backlight.automatic = false;
  gb.backlight.set(0);
  gb.display.clear();
  gb.display.persistence = true;

  //if (file.initFAT() == NO_ERROR){
  if (1){
    gb.display.println(F("SD init OK"));
    gb.display.update();
  }
  else{
    gb.display.clear();
    gb.display.print(F("No SD card"));
    gb.display.update();
    while(1);
  }
  delay(1000);

  //if(!file.exists("BATTERY.TXT")){
  if(1){
    //file.create("BATTERY.TXT");
    gb.display.println(F("BATTERY.TXT created"));
  }

  //if(file.openFile("BATTERY.TXT", FILEMODE_TEXT_WRITE) == NO_ERROR){
  if(1){
    gb.display.println(F("BATTERY.TXT opened"));
    gb.display.update();
    //file.writeLn("I will log battery voltage every 10 minutes");
  }
  else{
    gb.display.clear();
    gb.display.println(F("Can't open BATTERY.TXT"));
    gb.display.update();
    while(1);
  }
  delay(1000);
}

void loop(){
  if(gb.update()){
    if((gb.frameCount%(20*60*10)) == 64){ //every 10 minutes
      itoa(gb.battery.voltage, buffer, 10);
      //file.writeLn(buffer);
    }
    if((gb.frameCount%20) == 0){
      gb.display.clear();

      gb.display.print(gb.battery.voltage);
      gb.display.println("mV");

      gb.display.println(F("Running for"));
      gb.display.print(gb.frameCount/20/60/60);
      gb.display.print(":");
      gb.display.print((gb.frameCount/20/60)%60);
      gb.display.print("\"");
      gb.display.println((gb.frameCount/20)%60);
    }
  }
}


Battery is at 3847 mV, this is going to take a while now :) let's hope nothing freezes. I've removed the SD just to make extra sure
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Very mixed results/phenomena with battery logging

Postby lastfuture » Sat Jul 19, 2014 11:43 pm

P.S.: Damn you for including such a capable battery, 8 hours and it's only down to 3602 mV. I'm going to sleep :D
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Very mixed results/phenomena with battery logging

Postby lastfuture » Mon Jul 21, 2014 7:16 pm

I've let it run the battery down two times with the battery logger version that has all SD functions and the FAT library removed, and it ran down without any freezes until the "no battery" screen appeared. So I guess it's something SD related.

I found a 1 GB Micro SD card when searching through my drawers but I was unable to format it in a way that the Gamebuino SD Loader would like it.

The VERY strange thing is: If I insert it and press C while starting it actually flashes the loader onto Gamebuino from that 1 GB card but then it displays "Insert SD card and restart." If I insert the card that was included with the Gamebuino the loader it flashed from the 1 GB card reads the Gamebuino-included 128 Meg card. Very strange! The loader was definitely not on the Gamebuino before I started it pressing C. I've confirmed that a few times because I thought I had accidentally flashed it on there using the card that works, but it's definitely coming from the card the loader then can't deal with.

Edit: Here's a demonstration video to back up my claims because I sure as hell wouldn't believe it if I read it:


I've tried several ways to format it with FAT16 (using Mac OS):
1) partition it to FAT32 in Disk Utility with a master boot record and 1 partition at full size of the SD card, then in the terminal use sudo newfs_msdos -F 16 /dev/disk2s1 to format the partition to FAT16 (disk2s1 being the partition on the SD card). I thought that would work because the card that came with Gamebuino also seems to have one partition
2) partition it with only empty space in Disk Utility and in the terminal use sudo newfs_msdos -F 16 /dev/disk2 to format the card itself with FAT16 (disk2 being the device of the card itself)

Version 1 looks identical to the Gamebuino-provided card structurally as far as I can tell, version 2 is the one with which I noticed it did flash the loader that then refused to utilize the card.

If anyone has any other suggestions on formatting the 1 GB card on a Mac so that Gamebuino takes it I'd be very grateful to know how.
lastfuture
 
Posts: 29
Joined: Mon Jul 14, 2014 7:20 pm

Re: Very mixed results/phenomena with battery logging

Postby rodot » Tue Jul 22, 2014 7:32 am

This is because the loader uses the tinyFat library which is incompatible with some micro SD card, whild the bootloader is compatible. That's why your are able to load loader.hex using the bootloader but then get "insert micro SD card". I'm rewriting the loader with a different SD library to broaden the Gamebuino's compatibility.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Very mixed results/phenomena with battery logging

Postby Tiash » Tue Jul 22, 2014 9:16 am

lastfuture wrote:I've tried several ways to format it with FAT16 (using Mac OS):
1) partition it to FAT32 in Disk Utility with a master boot record and 1 partition at full size of the SD card, then in the terminal use sudo newfs_msdos -F 16 /dev/disk2s1 to format the partition to FAT16 (disk2s1 being the partition on the SD card). I thought that would work because the card that came with Gamebuino also seems to have one partition
2) partition it with only empty space in Disk Utility and in the terminal use sudo newfs_msdos -F 16 /dev/disk2 to format the card itself with FAT16 (disk2 being the device of the card itself)


From Mac OS, to format SD card use this command:
Code: Select all
diskutil partitionDisk /dev/disk1 1 MBRFormat "MS-DOS FAT16" "GAMEBUINO" 120M
User avatar
Tiash
 
Posts: 18
Joined: Sat Jul 12, 2014 7:28 am
Location: Italy

Next

Return to Installation & Troubleshooting

Who is online

Users browsing this forum: No registered users and 18 guests

cron