Show Posts
Pages: [1] 2 3 ... 415
1  Development / Other Software Development / Re: Update to TimeAlarms Library - thread for discussing beta testing on: March 17, 2014, 09:04:07 am
I'm also quite late, but it seems there is a bug with repeating timers at midnight.

If I set this: Alarm.alarmRepeat(0,0,0, FUNC_STUFF);

The Alarm is always disabled and I cannot enable it.

The library considers midnight to be at the end of the day, try:
Alarm.alarmRepeat(24,0,0, FUNC_STUFF);
2  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: March 17, 2014, 08:02:54 am

I tried some thing like this.. but on my lcd display i recieve only the current time and a "on"  when  the switch is not pressed it shows current time then after 1s delay a "on".
when i press the button switch for some times the current time stays on the display untill i release the switch. it doesnt changes the display to "on" when the switch is not pressed. when i release the switch old routine comes back.

i couldnt get the duration.


You are close but there are some errors in your code. You are using buttonState instead of buttonPin in your digitalRead function. Also, you have declared two event variables, one at the beginning of loop and the other in the code that handles the state where the digitalRead is high.  Move the time_t event declaration to the top of the sketch where your other global variables are declared and remove  time_t from the line where you set event= now() . You can read the arduino reference pages on declaring variables and variable scope for more on this issue.

The issues you are having are not related to the time libraries so I suggest that start a  new thread to discuss  your project and post a link here so I and others can follow.
3  Development / Other Software Development / Re: Update to TimeAlarms Library - thread for discussing beta testing on: March 17, 2014, 04:04:05 am
… I wish you could combine Jack Christensen TimeZone with your Time libraries.

I have not seen that library but will have a look. If that library currently works with the time library, would there be any functional benefit in combining them?

I have been having problems with multiple copies of your Time libraries across the web.

The time.cpp file has version information in the header along with a brief description of the changes. My latest version has edits dated 24 March 2012.

Having a standard way to determine a library version and capabilities is one of a number of improvements being discussed for Arduino libraries by the Arduino developer community.
4  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: March 16, 2014, 01:15:52 pm
Basically I am a beginner to arduino. It has been a interesting process for me,
Can you tell me how can I get the duration between a button switch on and off.?
Special thanks for your quick response.

There are many ways to do this but if an Arduino pin can monitor the state of the machine then one approach is to capture the time of the event of a pin going high or low using the code posted earlier. Subtracting the time between these events gives you the on and off times. Accumulating the on time and off times should give you the information that you need.

I suggest you experiment with a simple sketch that reads an input connected to a switch and totals the times between the high and low transitions and prints the current switch state, time since previous change of switch state, and total accumulated times in each state to the serial port. 
5  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: March 15, 2014, 02:38:20 am
Hi Samly_dixon, Its not clear on what you want to do and I did not see the code that you are trying to get working. Can you say more about exactly what you want to test with the if statement when a button is pressed.
I noticed that you have created functions to return the current hours, minutes and seconds. These functions already exist as follows:   seconds(), minutes() , hours().
You have a function named duration that has the following comment:
   //function to find the variance b/w start time n stop time
But it is not clear which argument is the start time and which is the stop time. It would be clearer if you used descriptive names for your variables instead of: ms, mp,hd, md etc.

To find the difference between two times, use the time_t returned from the now()function. For example:
Code:
time_t event = now();
// … some time later
long duration = now() – event; // the duration since the event in seconds
6  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: March 05, 2014, 09:42:43 am
I'm having trouble with rewriting my alarms. I'm switching on 12 lamps with separate timers ...


One thing you can try  is to replace the Alarm.write with a call to Alarm.free with the ID you want to change and then call Alarm.create with the new time.  Alarm.write sets the alarm time and activates the alarm but it does not update the scheduler.

Otherwise, there is a lot going on there and It’s difficult to see exactly what is happening with the alarms. Can you create a simple test sketch that just handles the alarm rescheduling and see if that works as expected.
7  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: February 16, 2014, 08:13:10 am
Note that I updated to posted code  to  so the minute tests for greater than or equal to the day start minute.
8  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: February 16, 2014, 07:48:43 am
here is another approach to determining if its day or night:

Code:
time_t startOfDay;
time_t startOfNight;

void setup()
{
  startOfDay = timeToSeconds(6,30,0); // Hour,Min,Secs for start of day
  startOfNight = timeToSeconds(18,30,0); // Hour,Min,Secs for start of Night
}

boolean isDaytimeNow()
{
    time_t t = timeToSeconds(hour(), minute(), second());
    return (t >= startOfDay && t < startOfNight);     
}

time_t timeToSeconds(time_t H, time_t M, time_t S)
{
 return (H * SECS_PER_HOUR) + (M * SECS_PER_MIN) + S;
}
9  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: February 16, 2014, 07:18:22 am
Good point!

try something like this:
Code:
boolean isDaytimeNow()
{
  // in this example, day starts at 6:30AM and ends at  6:30 PM
  int startDayHour = 6; // 6 am
  int startDayMinute = 30;
  int endDayHour = 18; // 6PM
  int endDayMinute = 30;

  int thisHour = hour();
  int thisMinute = minute();

  boolean result = false;

  // the following determines if the current hour and minute times are within
  // the day start and end times
  if( thisHour >= startDayHour) {
    if( thisHour == startDayHour){
      result = thisMinute >=  startDayMinute;
    }
    else{
      if( (thisHour < endDayHour) || (thisHour == endDayHour && thisMinute < endDayMinute) ){
        result = true;
      }
    }                
  }
  return result;
}

like my previous post, this is untested but hopefully will get you going in the right direction

Edit: changed  test for minutes from:
    thisMinute >  startDayMinute
 to
     thisMinute >=  startDayMinute;  // test for greater than or equal to
10  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: February 16, 2014, 04:38:39 am
Hello spyking,

If you want to know if the current time is day or night, you could do something like the following function. In this example, day starts at 6AM and ends at 6PM:
Code:
//returns true if it is day time now
boolean isDaytimeNow()
{
  // in this example, day starts at 6AM and ends at  6 PM
  int startDayHour = 6; // 6 am
  int endDayHour = 18; // 6PM
 
  int thisHour = hour();
 
  // the following determines if the current hour is within the day start and end times
  return thisHour >= startDayHour && thisHour < endDayHour; 
}
Calling that function will return true if its day and false if its night
Here is the code extended to support to start and end times of any hour and minute:
Code:
//returns true if it is day time now
boolean isDaytimeNow()
{
  // in this example, day starts at 6:30AM and ends at  6:30 PM
  int startDayHour = 6; // 6 am
  int startDayMinute = 30;
  int endDayHour = 18; // 6PM
  int endDayMinute = 30;
 
  int thisHour = hour();
  int thisMinute = minute();
 
  // the following determines if the current hour and minute times are within
  // the day start and end times
  return thisHour >= startDayHour &&
         thisMinute >= startDayMinute &&
         thisHour < endDayHour &&
         thisMinute < endDayMinute; 
}

I guess that what you are looking to do is to set the daytime flag at at startup and then toggle this off and on using the alarms, perhaps something like this:
Code:
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h>
#include <TimeAlarms.h>

boolean daytime;

// Alarm times
tmElements_t dtm,ntm;

void setup()
{
  setSyncProvider(RTC.get);   // the function to get the time from the RTC
  //Day
  dtm.Hour = 6;
  dtm.Minute = 30;
  dtm.Second = 0;

  // Night
  ntm.Hour = 18;
  ntm.Minute = 30;
  ntm.Second = 0;

  // Set up Alarms
  Alarm.alarmRepeat(dtm.Hour,dtm.Minute,dtm.Second, Day);
  Alarm.alarmRepeat(ntm.Hour,ntm.Minute,ntm.Second, Night);
}

void loop()
{
}

void Day()
{
  Serial.println("Day");
  daytime = true;
}

void Night()
{
  Serial.println("Night");
  daytime = false;
}

//returns true if it is day time now
boolean isDaytimeNow()

  int thisHour = hour();
  int thisMinute = minute();
 
  // the following determines if the current hour and minute times are within
  // the day start and end times
  return thisHour >=  dtm.Hour &&
         thisMinute >= dtm.Minute &&
         thisHour < ntm.Hour &&
         thisMinute < ntm.Minute; 
}
11  Using Arduino / Programming Questions / Re: Servo Timer2 Library Problems? on: January 28, 2014, 06:11:10 am
http://forum.arduino.cc/index.php/topic,21975.0.html
The original post you posted the library is where I got it. I had some errors and found a forum post the OP had the same errors and he posted the code containing the fixed errors and I haven't received an error(when compiling) since I used that code.


If the code you are using is from another post,  let me have a link to that code. I would like to have a look at the exact same code you are running.

12  Using Arduino / Programming Questions / Re: Servo Library error causing robot to imitate a dog chasing it's tail. on: January 22, 2014, 03:34:03 am
the degreesToUS function should be:
Code:
int degreesToUS(int degrees)
{
  return (map(degrees, 0,180, MIN_PULSE, MAX_PULSE));
}

although ServoTimer2 will not be as accurate as the Srvo library, I did a quick test using a logic analyzer and measured the output timing of ServoTimer2 to be within 1 % of the servo library. This will degrade if other interrupts are occurring frequently (as may be the case with VirtualWire), but I am surprised the test sketch posted does not work for you.

Can you post a link to the location where you downloaded the version of ServoTimer2 that you are using.


p.s. - the title of this tread may cause unnecessary concern for people using the Servo library, you may want to rephrase the problem statement as we don't yet know what is the cause of the behavior you are seeing, but its nothing to do with the Servo library and my not be due to an error in ServoTimer2.
Michael
13  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: October 29, 2013, 10:57:20 am
Hi ladinek,

I would be happy to add this feature to the library after it is well tested with the various chips compatible  with DS1307 that the library currently works with.
I suggest you create a new thread for your DS1307 enhancements when you are ready to post some code, and add a link to that thread here.

Michael Margolis
14  Using Arduino / Project Guidance / DS1302 RTC problems on: October 10, 2013, 04:59:38 am
so it seems that the ds1302 and ds1307 are both fault ridden , is there any other rtc that is reliable ?

I tested a bunch of DS1307 chips for many weeks back when the time library was created and never saw a fault.  If you haven’t already,  try one on well-made breakout board before ruling out this chip.

---
Mod – It looks like this RTC discussion is hardware related rather than anything directly to do with the time library. I think the posters issues would be apparent using any test harness for the RTC chips. If there is further discussion on RTC chips, it may be better to put this back in its own thread and add a link here to that, to keep this thread  focused on the Time library .
   
Michael Margolis
15  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: February 05, 2013, 02:42:06 am
Keith, don't beat yourself up. I can see why it seemed logical to include the TimeAlarm library within the Time folder. Unfortunately, Arduino does not currently handle library installation or inter-library dependencies very well, which  is why I chose to have TimeAlarms as a separate library. Perhaps when Arduino support a simple mechanism for installing libraries, problems such as yours will go away.

Michael
Pages: [1] 2 3 ... 415