Pages: 1 2 [3]   Go Down
Author Topic: mini RTOS [sic]  (Read 3813 times)
0 Members and 1 Guest are viewing this topic.
London
Offline Offline
Faraday Member
**
Karma: 10
Posts: 6249
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

JB, the sketch you posted compiles on my PC without any errors in 0012 with the <wiring.h> moved from the .h file to the .cpp file.

Have you tried to use the .h and .cpp file I posted today in the other thread?

If you are still stuck, send me a Personal Message with your email address and I will email you the files you need to put in the DateTimeAlrams directory.
Logged

Millicent, South Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi mem,

As we'd say in Australia - you beauty, all sorted! smiley-grin

I've read so many threads where you've helped others, on matters MUCH more complicated than mine. It's a rare thing for someone to be able to provide assistance so happily and helpfully to beginners and 'experts' alike; your parents would be proud! smiley

Thanks for your help, and I'm sure I'll have more questions as my project matures. FYI, the project goes something like this:
  • A remote automated camera system to take photos of key wetlands once or twice a day
  • Using a Canon Powershot A720 consumer camera, with modified firmware (see http://chdk.wikia.com/wiki/CHDK for more info - I'm sure there are people here who would be interested in what the CHDK community has achieved)
  • Thermistor to monitor enclosure temperature, and operate fans when required
  • DS1307 mini-board (http://www.futurlec.com/Mini_DS1307.shtml) for RTC
  • Arduino to control fans, camera power & solenoid to turn camera on at specific times
Believe it or not, this is all part of a WORK project, so I get to spend my time playing with Arduino & all sorts of other fun bits & pieces; I'm LIVING the tinkering philosophy! 8-)

Thanks again for your help, that sketch has compiled happily under 0012. Tomorrow I'll start working on how to integrate this with the rest of the code I've pulled together - hopefully my DS1307 board isn't far away!
Logged

JB

London
Offline Offline
Faraday Member
**
Karma: 10
Posts: 6249
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi JB, happy to help, and its a particular pleasure when I hear about interesting projects like yours. I am intrigued about the ways people use stuff that I have posted, I would be interested in hearing how you have implemented the alarms in your application,

When you get a chance, why not post some more information in the exhibition area.

Have fun!
Logged

Millicent, South Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi again...

I'm having some trouble compiling the following code (from reply #16) and hoped that someone could help me out...
Code:
#include <DateTime.h>
#include <DateTimeAlarms.h>

AlarmClass Timer1;
AlarmClass Timer2;
AlarmClass Timer3;

void setup(){
  // you can register time of day Alarms at any time but really shouldn't enable them until the internal clock is set

   if( dtAlarms.registerTimer( &Timer1 ) ) {        
     Timer1.value = DateTime.now() + 11;   // fire at the time of day 11 seconds from now
     Timer1.Mode.isTimeOfDay = true; // the value given above is a time of day
     Timer1.onTickHandler = &OnTimer1Tick;
     Timer1.enable();  
  }

   if( dtAlarms.registerTimer( &Timer2 ) ) {        
     Timer2.value = AlarmHMS(12,30,0)    // this is 30 minutes after 12 noon
     Timer2.onTickHandler = &OnTimer2Tick;
     Timer2.Mode.isTimeOfDay = true;
     Timer2.enable();  
  }
   if( dtAlarms.registerTimer( &Timer3 ) ) {        
     Timer3.Mode.isTimeOfDay = false; // the timer value is treated as a delay in seconds, not absolute time
     Timer3.value =  13;   // delay in seconds from the time this alarm is enabled
     Timer3.onTickHandler = &OnTimer1Tick;
     Timer3.enable();  
  }

}

 void OnTimer1Tick(void *Sender){

  if( Sender ==  &Timer1)
      Serial.print("Timer1 event: ");
   else  if( Sender ==  &Timer3)
      Serial.print("Timer3 event: ");
  timeDisplay();    
 }


void OnTimer2Tick(void *Sender){
    Serial.print("Timer2 event: ");  
}
On trying to compile this code I get the following error:

In function 'void setup()':
error: 'class dtAlarmsClass' has no member named 'registerTimer' In function 'void OnTimer1Tick(void*)':


I'm using 0012, and have the latest DateTimeAlarm cpp and h files. I've got my DS1307 mini-board attached & sending me the time (in a seperate sketch), but now I need to create alarms to fire at specific times every day.
Logged

JB

London
Offline Offline
Faraday Member
**
Karma: 10
Posts: 6249
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi JB, The library was changed a while ago to simplify the creation of alarms. The code from post#16 used the old method. The code you posted earlier did use the latest version, sorry that this long thread got you confused. I must find some time to post this in the playground so the latest information is easier to find.

Anyway, here is the sketch posted above updated to compile with the latest version of the library code:

Code:
#include <DateTime.h>
#include <DateTimeAlarms.h>

AlarmID_t Timer1, Timer2, Timer3;

void setup(){

   Timer1 = dtAlarms.createTimer(DateTime.now()+ 11, OnTimer1Tick);
/* the expression above replaces the code commented out below  
   if( dtAlarms.registerTimer( &Timer1 ) ) {
     Timer1.value = DateTime.now() + 11;   // fire at the time of day 11 seconds from now
     Timer1.Mode.isTimeOfDay = true; // the value given above is a time of day
     Timer1.onTickHandler = &OnTimer1Tick;
     Timer1.enable();
  }
*/

   Timer2 = dtAlarms.createTimer(AlarmHMS(12,30,0), OnTimer2Tick);
/*
   if( dtAlarms.registerTimer( &Timer2 ) ) {
     Timer2.value = AlarmHMS(12,30,0)    // this is 30 minutes after 12 noon
     Timer2.onTickHandler = &OnTimer2Tick;
     Timer2.Mode.isTimeOfDay = true;
     Timer2.enable();
  }
*/

  Timer3 = dtAlarms.createAlarm(13, OnTimer1Tick);
/*
   if( dtAlarms.registerTimer( &Timer3 ) ) {
     Timer3.Mode.isTimeOfDay = false; // the timer value is treated as a delay in seconds, not absolute time
     Timer3.value =  13;   // delay in seconds from the time this alarm is enabled
     Timer3.onTickHandler = &OnTimer1Tick;
     Timer3.enable();
  }
*/

}

 void OnTimer1Tick(AlarmID_t Sender){

  if( Sender ==  Timer1 )
      Serial.print("Timer1 event: ");
   else  if( Sender == Timer3 )
      Serial.print("Timer3 event: ");
 }


void OnTimer2Tick(AlarmID_t Sender){
    Serial.print("Timer2 event: ");
}

void loop(){
  
}
« Last Edit: October 10, 2008, 01:58:21 am by mem » Logged

Millicent, South Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry for not replying sooner, I've been away from home for the weekend... Thanks for this code, it's compiled happily as promised. I'm now basically at the point where I can assemble the separate code fragments I've 'collected' together & have my system up & running! smiley

I'll be having a test-build of a complete system soon (I've got other priorities over the next few weeks), so when I've finished that I'll definitely post it in the exhibition area.

Thanks again for your help mem (and all other forum members who have unknowingly helped my understanding of the Arduino environment!), and I'll pop a note in this thread when I put something in the exhibition area.

Cheers,

JB.
Logged

JB

Millicent, South Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Back for more help...

Is there an alarm which I can set to go off at a specific time of day? I thought that the dtAlarms.createTimer(AlarmHMS(12,30,0), OnTimer2Tick); command was referring to an hour, minute & second of the day (obtained from the RTC), not time since the sketch started running, then repeating after the same H/M/S. I need to be able to have my program trigger a camera at 2 or 3 different times during the day, setting up the times in the sketch.

Thanks again,

JB
Logged

JB

London
Offline Offline
Faraday Member
**
Karma: 10
Posts: 6249
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi JB,

dtAlarms.createTimer(AlarmHMS(12,30,0), OnTimer2Tick);

is a timer, it will call OnTimer2Tick 12 and a half hours after it is set using the above code.

If you want an alarm that triggers at 12:30 and say 3:30 every day you want this code:

dtAlarms.createAlarm(AlarmHMS(12,30,0), OnTimer2Tick);
dtAlarms.createAlarm(AlarmHMS(15,30,0), OnTimer2Tick);


« Last Edit: November 07, 2008, 03:15:58 am by mem » Logged

Millicent, South Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi mem,

Thanks for that, I'll give that a try next week. While working on it today I came up with this little line:
Code:
if (hour == 14) { if (minute == 07) { if (second == 00) { TakePhoto();}}}
 if (hour == 14) { if (minute == 07) { if (second == 30) { TakePhoto();}}}
 if (hour == 14) { if (minute == 10) { if (second == 00) { TakePhoto();}}}
referencing to the DS1307 real-time clock. Seemed to work just fine, and means I don't need to worry about the OnTimerTick functions. I do need to consider the fact that, in the future, other people (who may not be particularly computer literate) need to be able to easily modify these alarms. I'll put both solutions to my not-so-PC-literate workmate & see which one he likes best! smiley

Cheers, JB.
Logged

JB

Argentina
Offline Offline
Full Member
***
Karma: 0
Posts: 188
Sé feliz
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, we have ported FreeRTOS past year (2009), you can look at these links:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1256745982/0

The versión 0.1 Alpha (for the 0017 IDE) is available here:

http://www.multiplo.org/duinos/wiki/index.php?title=Main_Page

And there is a v0.2 Alpha which runs in 0018 at:

http://novell.chel.ru/get.php?file=DuinOS_v0.2_Alpha

We did not make the v0.2, but are working in the v0.3.

It runs acceptable on the 328s, and better on the megas (and in our own 644 based boards). The 168 may be too small.

Regards,
Julián
http://robotgroup.com.ar
Back to top      
Logged

Pages: 1 2 [3]   Go Up
Jump to: