Show Posts
Pages: 1 ... 76 77 [78] 79 80 ... 101
1156  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 15, 2011, 05:02:55 am
I could get the unix time, convert it to days, and subtract most of  the days to make say Aug 1 2011 the datum , then I will have more manageable number to play with for many years to come.....
1157  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 15, 2011, 01:36:45 am
right, I was getting confused by changing it to binary, but I can keep it decimal.
1158  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 15, 2011, 12:53:20 am
That was the plan originally Bob, but I I was put off by the 10 digit length of the number, but I think I can do it now
1159  Using Arduino / Storage / Re: EEPROM overwite previous data? days elapsed on: August 14, 2011, 05:35:07 pm
OK I have my event logger basically running, but I now have to calculate the number of days since the last event. ( max 99 )

Without using a lookup table for months days and leap years etc, if I can find how to convert the previous event date to unix time, I could simply subtract it from the current unix time to give me elapsed seconds, and divide by 60*60*24

I can get the current unix time with the time.h library with time_t now() , but I cannot see how to give it another date to calculate from?

Any ideas ?

I could go back to my original idea of splitting the unix code for the previous event, into bytes and saving them in the RTC ram, but its a big number ( 10 digits decimal )
1160  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 14, 2011, 01:30:56 pm
Thanks, yes I got it going like that, now I am doing my manipulations ( and seem to have reset everything to 0 but it doesnt matter, its actually coming right at last !

Code:

#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68
byte    date_month;
byte    month ;
byte    year;
byte prevdate ;
byte prevmonth ;
byte prevyear ;
byte prevbest ;

int trigger = 7;

void setup () {
 
   Wire.begin(); // no address, we are master
  Serial.begin (9600);  
pinMode ( trigger, INPUT );
digitalWrite ( trigger, HIGH);   //   sets pin 7 as trigger with pullup

//                                        update real time at bootup Read the day of month, month, year
   // Reset the register pointer  
    Wire.beginTransmission(0x68);  
    Wire.send(0x04);  // to day of the month
    Wire.endTransmission();  

    Wire.requestFrom(0x68,3 );  
 //   seconds = Wire.receive();  
 //   minutes = Wire.receive();  
 //   hours = Wire.receive();  
 //   day_week = Wire.receive();  
    date_month = Wire.receive(); // sends back current month  
    month = Wire.receive();  // and this
    year = Wire.receive();   // and this
  //  sqwe = Wire.receive();

   Serial.print ("bootup date_month " );
    Serial.println (date_month, HEX);
       Serial.print ("bootup month " );
    Serial.println (month, HEX);
       Serial.print ("bootup year " );
    Serial.println (year, HEX);

}

void loop () {
// ****************************************

if ( trigger == LOW ) { checkdate () ;}

// **********************************************************************
// Read the first 4 bytes of RAM
    // Reset the register pointer  
    Wire.beginTransmission(0x68);  
    Wire.send(0x08);  // to start of RAM
    Wire.endTransmission();  

    Wire.requestFrom(0x68,4 );  // Read back first four RAM addresses
  prevdate = Wire.receive(); // or whatever you decide to the data
  prevmonth = Wire.receive();
  prevyear= Wire.receive();
  prevbest = Wire.receive();  

 Serial.print ("prev date " );
    Serial.println (prevdate, HEX);
       Serial.print ("prev month " );
    Serial.println (prevmonth, HEX);
       Serial.print ("prev year year " );
    Serial.println (prevyear, HEX);

 Serial.print ("prev best " );
    Serial.println (prevbest, HEX);
// ****************************************************************************
 // Write the first 4 bytes of RAM
   // Reset the register pointer  
    Wire.beginTransmission(0x68);  
    Wire.send(0x08);  // to start of RAM
    Wire.send (prevdate); // or whatver you decide to call the data
    Wire.send (prevmonth);
    Wire.send (prevyear);
    Wire.send (prevbest);
    Wire.endTransmission();
    
} // end loop

void checkdate () {
  
  // Read the day of month, month, year
   // Reset the register pointer  
    Wire.beginTransmission(0x68);  
    Wire.send(0x04);  // to day of the month
    Wire.endTransmission();  

    Wire.requestFrom(0x68,3 );  
 
    date_month = Wire.receive(); // sends back current month  
    month = Wire.receive();  // and this
    year = Wire.receive();   // and this
 

   Serial.print ("todays date_month " );
    Serial.println (date_month, HEX);
       Serial.print ("todays month " );
    Serial.println (month, HEX);
       Serial.print ("todays year " );
    Serial.println (year, HEX);
}  // end checkdate function


1161  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 14, 2011, 12:25:42 pm
Thanks Bob,  I can actually understand most of that !!!

I will be using it in a stand alone board, so the keyboard shortcuts were getting me confused.

Which parts go before set-up and which in loop ?
1162  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 14, 2011, 07:27:50 am
I am getting really confused ,  all I need to do is use the days, months and years from the RTC date  = " currdate"  and 4 bytes of data from the ram ( 07H - 0AH ) ?  of the DS1307.

I think I can do all the manipulation, but then I want to occasionally write the updated data to the 4 bytes,  without disturbing the preset time .

I cant believe how  I am struggling with this  !  Anybody got a working simple sketch that I can modify?

1163  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 14, 2011, 12:40:30 am
Right,  slept on it and decided to run it slower ( I have a somewhat suspect usb connection sometimes ) so I changed it to 9600 and it works !

Now I shall try modifying it for my project  Thanks again !
1164  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 13, 2011, 02:18:53 am
I have 2 Arduinos, one runs on port13 and the other on 27, which is handy when I have them both on for wireless/data links.

I have drawn out ( my printer died yesterday ) the memory map of the 1307, and the addresses for each byte say 00H  to 07H, so I was wondering where the F and E and C  come from?

Yes the symbols appear in short bursts every 5 seconds.

Its definitely something my end :-)  I am going groggy with all this, and have had about 8 hours sleep since Wednesday, so I think I might do some assembly and give my mind a break !  I have 3 projects on the go at once suddenly !
1165  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 13, 2011, 01:09:28 am
I am still getting oã1š.}¢bzŽÿlc1š.}¢bzŽÿlc1dÞ~¢c{Žÿ  when I switch on.

I set my port 27 that I am using to 57600.

Where does the F0xx   E0xx C0xx  come from ?
1166  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 13, 2011, 12:01:24 am
That looks great, don't now how you are going to get time for fencing now your a moderator !

I will try that sketch out when I have had my morning coffee.

The extra byte I need to save is historically the best number of days between events, which could have been 5 events ago, but its simply compared to the latest one at an event time, and the largest is then stored as the best.
1167  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 12, 2011, 06:28:10 pm
BTW Rob,  The Bobuino with bells, whistles, inter-cooler and turbo looks really cool !

I don't like to just cut'n'paste without trying to understand the code, I have put some comments on your code to see if I understand it :-
Code:

// Reset the register pointer                          //  because the DS1307 sequences through all the addresses ?
    Wire.beginTransmission(RTC_address);         // this would be 0x68 , the address for all DS1307s ?
    Wire.send(0x00);                                        // starts the sequence back at 00 ( seconds and CH ) ?
    Wire.endTransmission();

// Now read the current time registers
    Wire.requestFrom(RTC_address,8 );    //  imports current time and control in bcd format, sequencing through as above ?
    seconds = Wire.receive();                 //  extract 1 byte from above, 1 nibble tens seconds, one units seconds  ?
    minutes = Wire.receive();                 // and so on
    hours = Wire.receive(); 
    day_week = Wire.receive(); 
    date_month = Wire.receive(); 
    month = Wire.receive(); 
    year = Wire.receive(); 
    sqwe = Wire.receive();

// Reset the register pointer                   
    Wire.beginTransmission(RTC_address); 
    Wire.send(0x08);  // RAM 0x08-0x3F      // advance the pointer to the start of the eeprom or battery ram ?
    Wire.endTransmission();

// Write it to RAM 
    Wire.beginTransmission(RTC_address,8);  //   I dont need time,  but need to save previous best ( 0-99 )
    Wire.send(seconds); 
    Wire.send(minutes);   
    Wire.send(hours);   
    Wire.send(day_week);   
    Wire.send(date_month);   
    Wire.send(month);   
    Wire.send(year);   
    Wire.send(sqwe);
    Wire.endTransmission();
1168  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 12, 2011, 05:44:32 pm
Thanks Rob

What must I change ( apart from the Serial ) to get the main part working with the normal usb?

Just remove the HEX from all the Serialprints ?

I get      ÿ?ñn¢³30 ¿<ðn¢³30 ¿>ðo£322¡ÿ>ñn£°23aß?ño£°23áÿ?ñ  at the moment on the monitor
1169  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 12, 2011, 01:48:53 pm
Thanks Rob

I will have a look at that now
1170  Using Arduino / Storage / Re: EEPROM overwite previous data? on: August 12, 2011, 11:03:04 am
Thanks Rob,  I wondered about that, is that the RC register they talk about in the datasheet?

I can store the previous best number ( 0-99) preferably in 2 bytes ( so I can just use each one - tens and units - easily for the display.)  Although I still have to compare it to  the current elapsed days to see which is the "best"

The date can be yyyy mm dd  or seconds since 1970 .  so I don't know the best way to try to store it.

If I store it in seconds since 1/1/1970 I can easily divide down the difference between latest and stored seconds to get elapsed days, but I still will need to display the previous date after a power down.....?
Pages: 1 ... 76 77 [78] 79 80 ... 101