Show Posts
Pages: 1 ... 74 75 [76] 77 78 ... 98
1126  Using Arduino / Networking, Protocols, and Devices / Re: DS1307 won't work... Everything is hooked up properly on: August 11, 2011, 06:25:38 am
I too am completely lost now with this dang RTC,  I have done some searches, and there seems to be so many different ideas of how to try and use the DS1307 with Arduino !
There are more posts on this than on Blinking LEDs!!!  :-)

I have a small board with the DS1307, 3.2v battery,  Xtal  right on the pins, decoupling on the 5v, 10k pull ups on the  SCL and ADA pins.

I have tried several sketches just to set the time and read it, I have removed the settings in setup and uploaded again, but each time I get random results, sometimes just everything switching from 00-000-00 00;00;00  to the correct time for a few seconds.

And Crossroads, your "simple" sketch is way over my "Global Newbie"  head I am afraid :-)

This was the result from the latest attempt using the DS1307 library example from Álvaro Justen aka Turicas;
Code:
Please enter date and time in the format "YYYY-MM-DD HH:MM:SS D",
Where D is the number of the day of week (0 = Sunday, 6 = Saturday).
Example: 2011-04-23 02:25:27 6
Date and time set!
Reading data from RTC...
20165-08-11 12:58:00 - day of week: Friday
2000-00-00 00:00:00 - day of week: Sunday
2000-00-00 00:00:00 - day of week: Sunday
2011-08-11 12:58:03 - day of week: Friday
2011-08-11 12:58:04 - day of week: Friday
20165-165-165 12:58:05 - day of week: Friday
2000-00-00 00:00:00 - day of week: Sunday
2011-08-11 12:58:07 - day of week: Friday
2011-08-11 12:58:08 - day of week: Friday
2011-08-11 12:58:09 - day of week: Friday
2000-00-00 00:00:00 - day of week: Sunday
2000-00-00 00:00:00 - day of week: Sunday
2011-08-11 12:58:12 - day of week: Friday

anybody have a failsafe equivalent to Blink without delay for DS1307 chips !

the code for above is :
Code:
/*
This example firstly waits for Serial input and then sets date and time on DS1307
Real-Time Clock based on what user sent.
Secondly it reads the date and time from DS1307 Real-Time Clock
and send this information to your PC using USB/Serial (like the ReadDate example).
Make the connections below, upload the code and open Serial Monitor.

Made by Álvaro Justen aka Turicas

Pin connections on DS1307 module:

[DS1307] <--> [Arduino]
5V       <--> 5V
GND      <--> GND
SQW      <--> (not connected)
SCL      <--> Analog Input 5
SDA      <--> Analog Input 4

This software is free software.
*/

#include <Wire.h>
#include <DS1307.h>

char dateTime[22];
int RTCValues[7], i = 0, year, month, dayOfMonth, dayOfWeek, hour, minute,
    second;

void setup() {
    Serial.begin(9600);
    Serial.println("Please enter date and time in the format \"YYYY-MM-DD HH:MM:SS D\",");
    Serial.println("Where D is the number of the day of week (0 = Sunday, 6 = Saturday).");
    Serial.println("Example: 2011-04-23 02:25:27 6");
    DS1307.begin();

    while (i < 21) {
        if (Serial.available()) {
            char c = Serial.read();
            dateTime[i] = c;
            i++;
        }
    }
    dateTime[i] = '\0';

    year = 10 * (dateTime[2] - 48) + (dateTime[3] - 48);
    month = 10 * (dateTime[5] - 48) + (dateTime[6] - 48);
    dayOfMonth = 10 * (dateTime[8] - 48) + (dateTime[9] - 48);
    dayOfWeek = (dateTime[20] - 48);
    hour = 10 * (dateTime[11] - 48) + (dateTime[12] - 48);
    minute = 10 * (dateTime[14] - 48) + (dateTime[15] - 48);
    second = 10 * (dateTime[17] - 48) + (dateTime[18] - 48);

    DS1307.setDate(year, month, dayOfMonth, dayOfWeek, hour, minute, second);
    Serial.println("Date and time set!");
    Serial.println("Reading data from RTC...");
}

void loop() {
    DS1307.getDate(RTCValues);
    sprintf(dateTime, "20%02d-%02d-%02d %02d:%02d:%02d", RTCValues[0],
            RTCValues[1], RTCValues[2], RTCValues[4], RTCValues[5],
            RTCValues[6]);
    Serial.print(dateTime);
    Serial.print(" - day of week: ");
    Serial.println(fromNumberToWeekDay(RTCValues[3]));

    delay(1000);
}
1127  Using Arduino / Storage / Re: SD card error - SOLVED on: August 09, 2011, 10:12:14 pm
You might be right there Rob,
If you have got the microSD in the adaptor working reliably, you are miles ahead.

I will try a separate 3.3v supply when I have one hooked up on the bench again ( and scope the supply as it is first )
1128  Using Arduino / Storage / Re: SdFat and big SD cards on: August 09, 2011, 08:52:54 am
FWIW     I have been able to pick up 256Mb cards cheap from camera repair shops, they always seem to have some in the drawer.
They are the only things that work in my message anouncer.
1129  Using Arduino / Storage / Re: SD card error - SOLVED on: August 09, 2011, 08:47:05 am
Hi Rob,

Did you come right with your SD cards?  I have had problems using any card other than the old  256 Mb ones, but all the latest ones like the 2 Gb and micro SD with adaptor fail after a while. ( weeks or a month )

I changed the 125 chip and it made no difference.

I have resorted to buying old smaller cards from camera repair shops !
1130  Using Arduino / Installation & Troubleshooting / Re: saving to new file each time ? on: July 13, 2011, 04:19:36 am
Thanks,  thats what I will set up then.

It is about time I had a tidy up, every time theres a new Arduino version, I just copy all the libraries and examples into it and work from there.

1131  Using Arduino / Installation & Troubleshooting / saving to new file each time ? on: July 11, 2011, 09:38:42 pm
I have done a search and cant find a reason why, when I want to save a file that I am working on, it says some files are read-only, save to a new file.

Its not always, sometimes it saves as normal windows .

I have put up with it til now, but sometimes you might make just one small change, and have to save it to  a new name each time.... ?
1132  Using Arduino / Storage / Re: New version of the SdFat SD card library on: July 07, 2011, 10:38:35 am

I only see the problem when I plug the chip into the project, so I have no serialPrint info.

The cards are running at   BitRate   =  352 Kbs
                                     A sample =  16 bit
                                     Chan =        1 mono
                                     samp rate = 22 KHz
                                     audio       =  PCM

I am OK with using 125 Mb older cards, but some might like to store larger/more audio files ?

The micro cards in the adapter look very cute , I wonder if they behave differently in a socket designed for them ?
1133  Using Arduino / Storage / Re: New version of the SdFat SD card library on: July 07, 2011, 07:10:28 am
I am still having fun and games with the SD cards using the waveHC library, that you suggested was best for audio files.

I am using the card to store 9 prerecorded messages of about 4 seconds each ( about 100k file size )

I have just looked at another couple of prototypes that I made that have failed, and it turns out that on the one card, it would only read tracks 1 to 9 , and cut off on track6,       and on the other it only reads tracks 6 to 8 !
Both of these cards ( Kingston and Patriot ) are micro SD cards in a SD adaptor.  I found another similar one and that only plays tracks 7 8 and 9.

I have tried them at 8 MHz and 4 MHz with the same result.  The Vcc line is decoupled right at the pins of the reader.

A normal SD type ( which our local computer shop no longer stocks ) seems OK.

I scratched  round the family for any old 128  Mb  cards they might have laying around, and they all work OK ....


Should I update anything in the libraries while I am at it ?
1134  Using Arduino / LEDs and Multiplexing / dead key on keypad library ? on: June 30, 2011, 02:45:18 pm

I started posting about a problem I had with KeyPad, where one key was not working, but just typing it up gave me the clue, so I will just mention it in case others have the same problem.

The unit is a remote control, using VirtualWire driving the transmitter.  I reallocated the default transmit pins ( data and PTT ) to 15 and 13 to suit my layout.

Being only a transmitter I completely forgot that VirtualWire also allocates pin 11 as the default vw_set_rx_pin, which I had as set as one of the columns in KeyPad.

Reallocating the vw_set_rx_pin to a spare pin cured it of course.
1135  Using Arduino / Networking, Protocols, and Devices / Re: HT12E library on: June 29, 2011, 02:49:41 am


Good tips, I will try them
1136  Using Arduino / Networking, Protocols, and Devices / Re: HT12E library on: June 29, 2011, 12:43:39 am
Right, but actually, would it not be possible for the compiler to spot that particular error quite easily?  and say " that ain't gonna get to 3 to start counting"

Or if you have the perennial   if ( a=0 )  instead of a==0  ,    it could nudged you and say "are you sure you want to make a be zero right now?"

Or perhaps us old farts should pay more attention to what we are typing, but I get carried away when I can see the code in my head, and just want to test it.
1137  Using Arduino / Networking, Protocols, and Devices / Re: HT12E library sorted ! on: June 28, 2011, 03:57:13 pm

Its working now,  some idiot typed   for ( int n =0; n>=3; n++ )   instead of  for ( int n =0; n<=3; n++ )   smiley-eek-blue

1138  Using Arduino / Programming Questions / Re: what is permitted in a switch case? on: June 28, 2011, 03:53:22 pm


You wont believe how many times I overlooked that while going through for ==  etc !

It now works of course....  what a great forum !
1139  Using Arduino / Programming Questions / Re: what is permitted in a switch case? on: June 28, 2011, 03:39:26 pm
LOL  -   I really can't believe I did that !!    smiley-red

Thanks a lot
1140  Using Arduino / Programming Questions / what is permitted in a switch case? on: June 28, 2011, 02:55:38 pm
  Is it OK to run functions and for () functions inside various cases of a switch structure ?

These functions  redtens ();  zero();  and   one();   all run OK on their own, but the code just doesn't run the switch statement....  heres a bit of the code:-


Code:
break;
      case 2:
        ////////////////////////////////////   send all this 4 times with pilot and sync bit
        for ( int n =0; n>=3; n++ ){
          redtens ();  //  sends tile and customer number for red tens
          zero();
          one();
          zero();
          zero();       
          digitalWrite(dataPin, LOW );

        break;
      case 3:
Pages: 1 ... 74 75 [76] 77 78 ... 98