Show Posts
Pages: [1] 2 3 ... 32
1  Using Arduino / Interfacing w/ Software on the Computer / Re: Easy to get started with freeware programing language for windows on: August 16, 2014, 06:01:03 pm
Here you have an example to see how easy it is the use of lazarus for communicate with arduino:
http://www.laboelectronique.be/english/laz_serial_ang.html
2  Using Arduino / Interfacing w/ Software on the Computer / Re: Easy to get started with freeware programing language for windows on: August 16, 2014, 05:56:12 pm
I use lazarus, an opensource IDE for coding in pascal languaje.

http://www.lazarus.freepascal.org/

A good point is that you could write the code once, and to compile for different OS: linux, windows,...

You will need to add extra components for serial communication with arduino, althought it works for both usb or bluettoth comm ports, such as 5dpo or similar (http://wiki.freepascal.org/5dpo

I had very good experiences working with this software if you know pascal (not far from c).

Enjoy!
3  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 13, 2014, 11:04:24 am
BTW,

Here you have other library what could be used with DS3231 RTC:
https://github.com/MrAlvin/RTClib

It is a modification of the famous RTCLib what include more functions some of them focused on DS3231 RTC.
It comes with different examples for this (and others) RTC, so, maybe it could be useful for others.

Cheers,
4  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 13, 2014, 10:57:04 am
I finally located otherlibrary for ds3231 RTC, what mades easy what i am loking for, but also saving memory.

This is the library i located: http://kevinrye.net/resources/E-Paper-Clock-Source-V1.zip from an interesting webpage of an arduino user what develop many interesting proyects:
http://kevinrye.net/
He designed this library for his e-ink paper clock.

Just for your interest, i leave here his library, and my code, where you could see what i did with it.

Thanks so much guys for your ideas and comments! I will apply what i learned from you in my future projects.
Cheers!
5  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 11, 2014, 05:43:02 pm
@Cattledog

Thanks so much for your explanations and example pieces of code. I really appreciate.

My problem is that my knowledge at this level of coding is pretty poor.... One of my task in the to-do-list is to learn about data transfer to be able to use this kind of coding (to do things like this one you explain or, to write-read an eeprom). Read and write bits is at this moment out of my knowledge limits... this is why i ever use libraries... But to have this knowledge will allow to me to modify libraries to use only the procedures i require, or directñy communicate with devices at this low level.

Anyway, i really appreciate your ideas, and i will save this information for my next learning steps. THANKS!!
6  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 11, 2014, 04:49:06 pm
Not to late at all!!

I tested your I2CScanner code, and it is great!

This is what it returns from the DS3231 reading:
Quote
Dump of NVRAM content (19 bytes) from I2C device at address 0x68 (104)
The information is apply only for chip DS3231, partially for chips DS1337 and DS1307 (and maybe for another similar chips)
0x00 Seconds             = 45
0x01 Minutes             = 32
0x02 Hours               = 21
0x03 Weekday             = 1
0x04 Day                 = 11
0x05 Month/Century       = 8
0x06 Year                = 2014
0x07 Alarm 1 Seconds     = 0
0x08 Alarm 1 Minutes     = 80
0x09 Alarm 1 Hours       = 80
0x0A Alarm 1 Day&Date    = 80
0x0B Alarm 2 Minutes     = 0
0x0C Alarm 2 Hours       = 0
0x0D Alarm 2 Day&Date    = 0
0x0E Control             = 11100
0x0F Control/Status      = 1001
0x10 Aging Offset        = 0
0x11 Temperature MSB+LSB = 30.75°C

Then, it seems that my testing  code to set the alarm is not working:
Code:
Clock.setA2Time(0, 0, 0, 0b111, 0, false, false)
(to have an alarm each minute to testing purposes)

and neither the real code i want to establish:
Code:
Clock.setA1(0,0,0,0, 0b1100, 0, false, false);
(to have an alarm each hour o'clock)
This one because of the unreal values of hours, minutes and seconds of alarm 1 (80, 80, 80).

7  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 11, 2014, 02:40:26 pm
Thanks @cattledogs

I already have this library, but i didn´t have an example to configure an alarm, what seems to be more easy.

My problem is that i am out of memory, so, by the use of DS3232RTC library (and the required time library), as well as the new full DS3231 library, i completelly fill the memory of the arduino, and my code does not upload.

For that reason i am using the other simple library, what leaves to me 4 Kb to allow my code to work. So, my unique problem at this stage is to have runing the alarm... what is my pain now.

Anyway, thanks so much for the example code, because it is so interesting and useful. i am sure i will use it in other projects.

@el_supremo,
Thanks so much. However, i still do not have it working... It is killing me. I post here my code (still many things need to be pulished). Could you see what i am doing wrong?
Thanks!
8  Using Arduino / Programming Questions / Re: Pinchangeint does not work on pin 2 on: August 11, 2014, 07:12:04 am
You are right!

It was my fault to assume it was the same for both uno and mega boards.
Thanks for your explanations.
9  Using Arduino / Programming Questions / Re: Pinchangeint does not work on pin 2 on: August 10, 2014, 04:14:30 pm
Oh, really?

I beleave you, but there are many examples on internet and this forum where the people use the pinchageint also in digital pin 2 .. i assumed that this should also work in arduino mega2560 boards.

Anyway, i used the normal interrupt in my code inpin 2 together with oinchangeint in other pins, and everything seems to work, so, solved!!

Thanks @MarkT
10  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 10, 2014, 02:31:34 pm
Trying to apply the previous ideas, i wrote this function:
Code:
void SetNewAlarm(){
  Clock.setA2Time(0, 0, 0, 0b111, 0, false, false);
  Clock.turnOnAlarm(2);
}

The idea is to trigger the alarm once per minute (for testing purposes), but nothing happends... the alarm is not triggered.
i use an attachinterrupt function to capture the alarm from the rtc.

I added a 0 before the b111 because  otherwise the code does not compile.

What is wrong?
11  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 10, 2014, 12:01:04 pm
Thanks @el_supremo,

Now i see what bytes means, and the meaning of the table:

So, if i am right, for the different options in the table i should set the bytes such as:
Quote
Alarm 1:
b1111            Alarm once per second
b1110          Alarm when seconds match
b1100         Alarm when minutes and seconds match
b11000     Alarm when hours, minutes, and seconds match
0b0000  Alarm when date, hours, minutes, and seconds match
1b0000    Alarm when day, hours, minutes, and seconds match

Alarm 2:
b111           Alarm once per minute (00 seconds of every minute)
b110         Alarm when minutes match
b100       Alarm when hours and minutes match
0b000  Alarm when date, hours, and minutes match
1b000   Alarm when day, hours, and minutes match

About to clear the A1F and A2F, i suposse that you are talking about to add this function to the code depending of if the used alarm was 1 or 2:
Quote
Clock.turnOffAlarm(1);
Clock.turnOffAlarm(2);

Am i right?
12  Using Arduino / Programming Questions / Pinchangeint does not work on pin 2 on: August 10, 2014, 06:06:39 am
I have a DS3231 RTC what triggers alarm. I what the alarm pin of the rtc connected to digital pin 2 on an arduino mega2560 board. I use this library:
https://github.com/jarzebski/Arduino-DS3231

When i test the "intalarm" code from the example folder, it works great.

However, when i add the Pinchangeint library to the code and modify to trigger the alarms from the RTC, nothing happens.
I checked in the forum for others, but they seems to  have the pinchangeint working in digital pin 2. So, why it does not work for me?

Any idea?

This is the working code:
Code:
#include <Wire.h>
#include <DS3231.h>

DS3231 clock;
RTCDateTime dt;
boolean isAlarm = false;
boolean alarmState = false;
int alarmLED = 24;

void alarmFunction()
{
  Serial.println("*** INT 0 ***");
  isAlarm = true;
}

void setup()
{
  Serial.begin(9600);
  
  // Initialize DS3231
  Serial.println("Initialize DS3231");;
  clock.begin();
 
  // Disarm alarms and clear alarms for this example, because alarms is battery backed.
  // Under normal conditions, the settings should be reset after power and restart microcontroller.
  clock.armAlarm1(false);
  clock.armAlarm2(false);
  clock.clearAlarm1();
  clock.clearAlarm2();

  // Manual (Year, Month, Day, Hour, Minute, Second)
  //clock.setDateTime(2014, 4, 25, 0, 0, 0);

  // Set Alarm1 - Every 20s in each minute
  // setAlarm1(Date or Day, Hour, Minute, Second, Mode, Armed = true)
  clock.setAlarm1(0, 0, 0, 10, DS3231_MATCH_S);

  // Attach Interrput 0. In Arduino UNO connect DS3231 INT to Arduino Pin 2
  attachInterrupt(0, alarmFunction, FALLING);

  // Setup LED Pin
  pinMode(alarmLED, OUTPUT);
}

void loop()
{
  dt = clock.getDateTime();
  Serial.println(clock.dateFormat("d-m-Y H:i:s - l", dt));
  if (isAlarm)
  {
    digitalWrite(alarmLED, alarmState);
    alarmState = !alarmState;
    clock.clearAlarm1();
  }
  delay(1000);
}

and this one is the code what doesn´t work:
Code:
#include <Wire.h>
#include <DS3231.h>
#include <PinChangeInt.h>

DS3231 clock;
RTCDateTime dt;
boolean isAlarm = false;
boolean alarmState = false;
int alarmLED = 24;
const int selectPin = 2;

void alarmFunction()
{
  Serial.println("*** INT 0 ***");
  isAlarm = true;
}

void setup()
{
  Serial.begin(9600);
  
  // Initialize DS3231
  Serial.println("Initialize DS3231");;
  clock.begin();
 
  // Disarm alarms and clear alarms for this example, because alarms is battery backed.
  // Under normal conditions, the settings should be reset after power and restart microcontroller.
  clock.armAlarm1(false);
  clock.armAlarm2(false);
  clock.clearAlarm1();
  clock.clearAlarm2();

  // Set Alarm1 - Every 10s in each minute
  // setAlarm1(Date or Day, Hour, Minute, Second, Mode, Armed = true)
  clock.setAlarm1(0, 0, 0, 10, DS3231_MATCH_S);

  // Attach Interrput 0. In Arduino UNO connect DS3231 INT to Arduino Pin 2
  pinMode(selectPin, INPUT); digitalWrite(selectPin, HIGH);
  PCintPort::attachInterrupt(selectPin, &alarmFunction, FALLING);

  // Setup LED Pin
  pinMode(alarmLED, OUTPUT);
}

void loop()
{
  dt = clock.getDateTime();
  Serial.println(clock.dateFormat("d-m-Y H:i:s - l", dt));
  if (isAlarm)
  {
    digitalWrite(alarmLED, alarmState);
    alarmState = !alarmState;
    clock.clearAlarm1();
  }
  delay(1000);
}

I know that the interrupt funcion contains a Serial.print, what is not a good thing. The example comes with this function. I deleted this line but the problem remains, and it works in the first code.

The code compiles, but it only shows the date and time.. when the time rise  10 seconds, do nothing.
Any idea?

Thanks!
13  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 10, 2014, 04:17:53 am
Thanks @el_supremo,

But this is exactly my problem. I know the table from the datasheet, and also from the library, but i do not know how to move  from the teory to the practice.

I found a quite good and new library where it is to easy to do it:
https://github.com/jarzebski/Arduino-DS3231

However, i can´t use it because it is so heavy for my settings. My code is so long, and i cant use this library because it completely fill the memory. Then, i use this other library what is lighter:
http://hacks.ayars.org/2011/04/ds3231-real-time-clock.html

Then, to set the alarm, the library have these functions:

Quote
void DS3231::setA1Time(byte A1Day, byte A1Hour, byte A1Minute, byte A1Second, byte AlarmBits, bool A1Dy, bool A1h12, bool A1PM)

void DS3231::setA2Time(byte A2Day, byte A2Hour, byte A2Minute, byte AlarmBits, bool A2Dy, bool A2h12, bool A2PM)

Firs, i don´t know how to fill the second part of each funcion ( byte AlarmBits, bool A1Dy, bool A1h12, bool A1PM and byte AlarmBits, bool A2Dy, bool A2h12, bool A2PM), and second, it seems to me that i need to set the day, hour, minute, (and second in case of the Alarm 1), each time the alarm is triggered. The problem is at the end of the day. if time now is 23h, and i must to set the next alarm to the 00:00h of the next day, i must add a day to the actual date, and if i am at the last day of the month? I must take this also into account to calculate the numbers of days in the present month?

It is really such as complex?

So, you can see that i am completely lost.
14  Using Arduino / Programming Questions / Re: Example needed for DS3231 AT24C32 IIC Precision RTC on: August 09, 2014, 05:36:10 pm
I also use this device, and i need to set an alarm to be triggered each hour o´clock (minutes = 0; seconds = 0).

I don´t undersand how to do it exactly, if i can set once the alarm in my code, or it require to be setted each time it was trigetter in order to be ready for the next hour...

So, any help will be wellcome!
15  Using Arduino / Programming Questions / Re: Problem compiling code with DS3231 library on: August 09, 2014, 01:42:48 pm
OMG!!  smiley-red

yes, i had,  but i changed the name of the library folder to "DS3231_old". Now i see it was not enough! I completely removed the old library and t works perfect!

Thanks so much!
Pages: [1] 2 3 ... 32