rtc DS1302 Help

Ho riscontrato alcuni problemi se non si inserisce la pila nel modulo RTC oppure se il contatto è incerto. Controlla!

cyberhs:
Ho riscontrato alcuni problemi se non si inserisce la pila nel modulo RTC oppure se il contatto è incerto. Controlla!

ho controllato la batteria .. 1V .. l'ho cambiata .. ma il problema non è cambiato ..
per contatto incerto quale intendi?

oggi pomeriggio ho provato il modulo sull'arduino uno di un mio amico .. senza modificare gli sketch ma spostando i pin sulla board .. non va ..
abbiamo provato anche la libreria presa da qua http://blog.trendsmix.com/?p=93 .. lo sketch è questo qua sotto:

/*
Example sketch for interfacing with the DS1302 timekeeping chip.

Copyright (c) 2009, Matt Sparks
All rights reserved.

http://quadpoint.org/projects/arduino-ds1302
*/
#include <stdio.h>
#include <string.h>
#include <DS1302.h>

/* Set the appropriate digital I/O pin connections */
uint8_t CE_PIN   = 8;
uint8_t IO_PIN   = 7;
uint8_t SCLK_PIN = 6;

/* Create buffers */
char buf[50];
char day[10];

/* Create a DS1302 object */
DS1302 rtc(CE_PIN, IO_PIN, SCLK_PIN);


void print_time()
{
  /* Get the current time and date from the chip */
  Time t = rtc.time();

  /* Name the day of the week */
  memset(day, 0, sizeof(day));  /* clear day buffer */
  switch (t.day) {
    case 1:
      strcpy(day, "Sunday");
      break;
    case 2:
      strcpy(day, "Monday");
      break;
    case 3:
      strcpy(day, "Tuesday");
      break;
    case 4:
      strcpy(day, "Wednesday");
      break;
    case 5:
      strcpy(day, "Thursday");
      break;
    case 6:
      strcpy(day, "Friday");
      break;
    case 7:
      strcpy(day, "Saturday");
      break;
  }

  /* Format the time and date and insert into the temporary buffer */
  snprintf(buf, sizeof(buf), "%s %04d-%02d-%02d %02d:%02d:%02d",
           day,
           t.yr, t.mon, t.date,
           t.hr, t.min, t.sec);

  /* Print the formatted string to serial so we can see the time */
  Serial.println(buf);
}


void setup()
{
  Serial.begin(9600);

  /* Initialize a new chip by turning off write protection and clearing the
     clock halt flag. These methods needn't always be called. See the DS1302
     datasheet for details. */
  rtc.write_protect(false);
  rtc.halt(false);

  /* Make a new time object to set the date and time */
  /*   Tuesday, May 19, 2009 at 21:16:37.            */
  Time t(2009, 5, 19, 21, 16, 37, 3);

  /* Set the time and date on the chip */
  rtc.time(t);
}


/* Loop and print the time every second */
void loop()
{
  print_time();
  delay(1000);
}

il risultato sulla seriale è questo:

 2000-00-00 00:00:00
 2000-00-00 00:00:00
 2000-00-00 00:00:00
 2000-00-00 00:00:00
 2000-00-00 00:00:00
 2000-00-00 00:00:00
 2000-00-00 00:00:00

Scusa,
ma se tu carichi così come è l'esempio del playground (allegato a questo mio post) SENZA modificarlo (occhio quindi a quali pin usare) ... che risultato ti da ? :roll_eyes:

Guglielmo

EDIT : Hai letto anche che : "The three pins for the interface should avoid to use the internal pull-up resistors of the Arduino. The DS1302 has internal pull-down resistors, and the CE and SCLK lines should be low when inactive.
Some schematics on the internet have pull-up resistors on the three interface lines. That is wrong. Other schematics use two 22pF with the crystal. That is also wrong. See the datasheet for full specifications and a circuit."

ds1302.zip (4.62 KB)

gpb01:
Scusa,
ma se tu carichi così come è l'esempio del playground (allegato a questo mio post) SENZA modificarlo (occhio quindi a quali pin usare) ... che risultato ti da ? :roll_eyes:

Guglielmo

EDIT : Hai letto anche che : "The three pins for the interface should avoid to use the internal pull-up resistors of the Arduino. The DS1302 has internal pull-down resistors, and the CE and SCLK lines should be low when inactive.
Some schematics on the internet have pull-up resistors on the three interface lines. That is wrong. Other schematics use two 22pF with the crystal. That is also wrong. See the datasheet for full specifications and a circuit."

ho caricato lo sketch che mi hai messo in allegato senza modifiche dato che i pin erano già corretti, questo è quello che mi mostra la seriale:

DS1302 Real Time Clock
Version 2, March 2013
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000
Time = 00:00:00, Date(day of month) = 0, Month = 0, Day(day of week) = 0, Year = 2000

Quindi ... ho lo hai collegato male o il modulo è guasto ... :roll_eyes:

Propendo più per la prima ipotesi, ma tutto è possibile ... XD

Ti è stato chiesto fin dall'inizio di mettere LO SCHEMA (il disegno) esatto dei collegamenti (non solo l'elenco dei pin che usi), ma ancora non lo hai fatto ... :roll_eyes:

Guglielmo

ecco lo schema .. semplice ma vedete come è collegato il tutto .. ovviamente i led hanno una resistenza da 200ohm che nello schema ho sottinteso

Ma il DS 1302 è montato su una scheda che hai comprato (è in tal caso cortesemente metti il link al prodotto) o hai preso l'integrato e lo hai messo tu su una breadboard ???

Guglielmo

si scusa, è un modulo gia completo .. comprato da qua:

Ok, quindi si suppone che abbia il giusto quarzo e sia collegato bene ...
... se stacchi TUTTO e colleghi SOLO il modulo e fai girare il programma del playground, non va ugualmente ?

Guglielmo

P.S. : Nel tuo schema immagino tu ... abbia sott'inteso anche l'alimentazione del modulo vero ? XD

gpb01:
P.S. : Nel tuo schema immagino tu ... abbia sott'inteso anche l'alimentazione del modulo vero ? XD[/i]

giusta osservazione :slight_smile: .. si tutto è alimentato dalla +5v dell'arduino ..
oggi pomeriggio ho provato con solo l'rtc e l'arduino di un mio amico e con una libreria di quelle sopra citate e dava sempre lo stesso problema .. domani mattina provo a collegarlo senza gli altri componenti ma con lo sketch che mi hai mandato prima ..
speriamo bene.

ho fatto altre prove adesso .. ho controllato con il tester se tutti i collegamenti erano corretti e lo sono, ho provato anche le piste sulla scheda rtc e sono corrette .. a questo punto l'ipotesi è che sia rotto .. mi consiglieresti un valido sostituto? Ho visto che molti usano il modulo con il ds1307 ..
ho trovato questo Shield DS 1307 modulo RTC real time clock I2C per Arduino/PIC - ART. CL12 | eBay ma vedo che ha molti piu pin dell'altro ..

Ha più pin perchè ha anche un chip eeprom

nid69ita:
Ha più pin perchè ha anche un chip eeprom

e come va utilizzato?

Tieni anche conto che gli RTC non sono tutti uguali ed hanno precisioni diverse:
Qui ne hanno parlato: Problema con controllore serra - #8 by leo72 - Software - Arduino Forum

nid69ita:
Tieni anche conto che gli RTC non sono tutti uguali ed hanno precisioni diverse:
Qui ne hanno parlato: Problema con controllore serra - #8 by leo72 - Software - Arduino Forum

bhe si li parlano di RTC precisi .. a me serve che funzioni e che costi più o meno poco .. anche se sbaglia di qualche minuto non è un problema, significherà che bagnerà il giardino in ritardo o in anticipo

rik93, vai tranquillo con il DS1307 ...

... è un muletto, banale da controllare (se fai un po' di ricerche sul forum troverai miei post che spiegano come usarlo SENZA usare nessuna libreria a lui dedicata, ma semplicemente la Wire per parlare con il suo bus I2C) e sufficientemente preciso (se non ti serve una cosa che spacca il millesimo di secondo :grin:) !

Guglielmo

Come dice @Guglielmo se non hai problemi di ritardi, quello di gaetano_f (venditore eBay conosciuto nel forum, molto valido) va bene. Poi ha anche un chip eeprom per poterci salvare sopra qualche info. Potrai provare poi a usarlo in seguito.

gpb01:
rik93, vai tranquillo con il DS1307 ...

... è un muletto, banale da controllare (se fai un po' di ricerche sul forum troverai miei post che spiegano come usarlo SENZA usare nessuna libreria a lui dedicata, ma semplicemente la Wire per parlare con il suo bus I2C) e sufficientemente preciso (se non ti serve una cosa che spacca il millesimo di secondo :grin:) !

Guglielmo

grazie mille per l'aiuto .. ora lo acquisto e speriamo che sia questo il problema e non l'arduino, anche se improbabile.
Grazie ancora a tutti

rik93:

nid69ita:
Ha più pin perchè ha anche un chip eeprom

e come va utilizzato?

I chip EEPROM I2C si interfacciano via I2C con la lib Wire e si usano per memorizzare dati che non devono andare persi una volta tolta l'alimentazione, ad esempio parametri di configurazione del circuito oppure letture eseguite dallo stesso.