Show Posts
Pages: [1] 2 3
1  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: November 07, 2008, 08:18:20 am
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.
2  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: November 06, 2008, 06:56:09 pm
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
3  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 12, 2008, 06:40:18 am
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.
4  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 10, 2008, 12:03:34 am
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.
5  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 02, 2008, 07:53:08 am
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!
6  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 02, 2008, 04:48:45 am
Sorry, just picked up on your comment about MOVING #include <wiring.h> from one file to the other... much better, but still have this last little error:

In function 'void setup()':
error: 'class dtAlarmsClass' has no member named 'createAlarm'


Which is a lot nicer than what I had before...

Again, sorry for not reading your post correctly!! ¬
7  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 02, 2008, 04:44:23 am
OK, so now we get to the bit that's confused me every time I've read this thread: hotcarrier wrote -
Quote
mem,
Did you mean TimerAlarms.h ?
... to which you replied -
Quote
Yes, DateTimeAlarms.h
 
:-? Sorry if I've missed something here, but the thread you directed me to has 'TimerAlarms' files in it, not 'DateTimeAlarms'. I tried renaming them, and replacing any 'TimerAlarm' references with 'DateTimeAlarms' references but that didn't work. Also tried it in 0011 with similar results. I AM getting a different error now though:
Code:
In file included from C:\arduino-0012\hardware\cores\arduino/WProgram.h:4,


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected unqualified-id before 'int'


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:80: error: expected `)' before 'int'


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected identifier before '(' token


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected `)' before '(' token


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected ',' or '...' before '(' token


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:144: error: expected initializer before ')' token


c:/arduino-0012/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:176: error: '__compar_fn_t' has not been declared


In file included from C:\arduino-0012\hardware\cores\arduino/WProgram.h:6,


 In function 'void setup()':

What am I missing?!? I feel like such a newb... :smiley
8  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 02, 2008, 04:13:20 am
I was pretty sure that I'd replaced the DateTimeAlarms.h file, but I decided to do a clean install of v0012 in a seperate location anyway. I have a DateTimeAlarms library, but it's only got the DateTimeAlarms.h file; I don't seem to have the DateTimeAlarms.cpp or DateTimeAlarms.o file anywhere, and can't locate it on the forums or main site.

I'm guessing that if someone can point me to that file, my problems may just disappear...

Thanks again!
9  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 02, 2008, 02:32:17 am
Hi mem,

The errors posted are from 0011. I've tried with 0012, but I think I've done something wrong when I instaleld that. On compiling, I get this:
Code:
o: In function `loop':
C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:39: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:39: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:39: undefined reference to `dtAlarmsClass::waitForDigits(unsigned char, dtUnits_t)'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:41: undefined reference to `dtAlarmsClass::delay(unsigned long)'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:43: undefined reference to `dtAlarmsClass::delay(unsigned long)'


o: In function `OnTimer(unsigned char)':
C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:34: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:34: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:34: undefined reference to `dtAlarmsClass::setValue(unsigned char, unsigned long)'


o: In function `OnAlarm(unsigned char)':
C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:22: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:22: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:22: undefined reference to `dtAlarmsClass::setValue(unsigned char, unsigned long)'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:27: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:27: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:27: undefined reference to `dtAlarmsClass::setValue(unsigned char, unsigned long)'


o: In function `setup':
C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:13: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:13: undefined reference to `dtAlarms'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:13: undefined reference to `dtAlarmsClass::createAlarm(unsigned long, void (*)(unsigned char), unsigned char)'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:14: undefined reference to `dtAlarmsClass::createAlarm(unsigned long, void (*)(unsigned char), unsigned char)'


C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp/Temporary_6757_4834.cpp:15: undefined reference to `dtAlarmsClass::createTimer(unsigned long, void (*)(unsigned char), unsigned char)'


Couldn't determine program size: C:\Documents and Settings\john\My Documents\arduino-0012\hardware/tools/avr/bin/avr-size: 'C:\DOCUME~1\john\LOCALS~1\Temp\build61366.tmp\DateTimeAlarmsSketch.hex': No such file
I've got a feeling that this is going to be an embarassingly easy thing to fix but I can't put my finger on it.
10  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 01, 2008, 11:09:15 pm
Hi again...
Fixing my first problem has left me with another; here's the code:
Code:
#include <DateTime.h>
#include <DateTimeAlarms.h>

AlarmID_t Alarm9,Alarm12,Timer11;  // id to identify what triggered alarm if callbacks are shared

void setup(){
 ¬†Serial.begin(19200);
 ¬†Alarm9 = dtAlarms.createAlarm( DateTime.now() + 9, OnAlarm); // trigger 9 seconds from now
 ¬†Alarm12 = dtAlarms.createAlarm(AlarmHMS(12,0,0), OnAlarm); // trigger at mid day
 ¬†Timer11 = dtAlarms.createTimer( 11, OnTimer); // trigger in 11 seconds
}

void OnAlarm(AlarmID_t Sender){
 ¬†// callback for time of day alarms
 ¬†if( Sender == ¬†Alarm9) {
 ¬† ¬†Serial.print("Alarm9: ");       ¬†
 ¬† ¬†dtAlarms.setValue(Alarm9, DateTime.now() + 9 ); // reset alarm to trigger at the time that is 9 seconds from now
 ¬†}
 ¬†else ¬†if( Sender == ¬†Alarm12)
 ¬†{
 ¬† ¬†Serial.print("Alarm12: ");
 ¬† ¬†dtAlarms.setValue(Alarm12, AlarmHMS(12,0,0)); // reset alarm to trigger at noon
 ¬†} ¬† ¬†
}

void OnTimer(AlarmID_t Sender){
 ¬†// callback for time delay alarm
 ¬†Serial.print("Timer11: 11 sec timer: "); ¬† ¬†
 ¬†dtAlarms.setValue(Timer11, 11 ); // delay another 11 seconds
}

void  loop(){  
 ¬†
 ¬†dtAlarms.waitUntilThisSecond(0); // ¬†this code blocks waiting for start of the next minute, background alarms are still serviced
 ¬†digitalWrite(13, HIGH);
 ¬†dtAlarms.delay(2000); ¬†// note we call the alarm delay to service the background alarms
 ¬†digitalWrite(13,LOW); ¬†
 ¬†dtAlarms.delay(2000); // delay is in milliseconds , all other alarm values are seconds
}

...which gives me the following error:

o: In function `loop':
undefined reference to `dtAlarms'o: In function `OnTimer(unsigned char)':
o: In function `OnAlarm(unsigned char)':
o: In function `setup':


Again, thanks for any thoughts!
11  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: mini RTOS [sic] on: October 01, 2008, 10:20:29 pm
Hi everyone,

First time poster, long time forum-scourer... smiley

I've been madly searching these forums since receiving my Diecimila a few weeks ago, trying to cobble together some alarm code that I can use to trigger a camera at a given time each day. I was very pleased to find this thread, but I can't seem to work out why I get compile errors when using mem's example code from reply #2 or reply #16. For reply #2, I get:

[EDIT] Never mind, I fixed this first problem..

For reply #16, I get:

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


 ¬†relating to:

Code:
Wire.begin();
 ¬† ¬†// 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( &TimeForPhoto ) ) {       ¬†
 ¬† ¬† TimeForPhoto.value = AlarmHMS(12,30,0) ¬† ¬†// this is 30 minutes after 12 noon
 ¬† ¬† TimeForPhoto.onTickHandler = &OnTimeForPhotoTick;
 ¬† ¬† TimeForPhoto.Mode.isTimeOfDay = true;
 ¬† ¬† TimeForPhoto.enable(); // the above registers an alarm, labelled 'TimeForPhoto', as one that triggers at the given time
 of day.
 ¬†}
I'm able to follow the coding to a certain extent, but this is well above anything I've tried before... I've ordered a Mini-DS1307 board to supply the time, so until that comes I thought I'd work on the alarm code.

Any help would be greatly appreciated - and by the way, congrats on such a friendly, supportive forum!

JB
12  Forum 2005-2010 (read only) / Interfacing / Re: LM35 thermometer on: May 11, 2010, 06:25:38 pm
Hi Bob,

I haven't touched on this subject for quite a long time! At the moment, I don't have the information/part numbers at hand; they are in the field at a location some 200km from my office. I will have to make a special trip out there to check this out for you, so I just wanted to warn you that it could be quite some time (maybe 2 months) before I'm able to give you any more info... sorry!

I loved working with the Arduino, but for this project it was over-kill. No, scratch that: it provided a great environment for development and testing, which then proved that having the microcontroller was like re-inventing the wheel, only exceedingly more complicated than the original design! smiley

I'll do my best to get the details for you ASAP - I may be out that way before 2 months is up, but I make no promises... smiley-wink

Regards,

JB
13  Forum 2005-2010 (read only) / Interfacing / Re: LM35 thermometer on: November 05, 2008, 04:49:20 am
Hi again...  :-[

Just a quick note to say that I've managed to get a 1k thermistor working - hooray! So, don't spend too much time thinking about the LM335 I've been on about... even though it would be nice to know what I was doing wrong with them, I'm not all that fussed about it with another solution working just fine.

Cheers,

JB.
14  Forum 2005-2010 (read only) / Interfacing / Re: LM35 thermometer on: November 04, 2008, 10:04:17 pm
OK, after going round and round in circles for the last few days, I'm not getting any closer to getting acceptable results out of this LM335 chip - see http://www.jaycar.com.au/products_uploaded/LM135.pdf for the datasheet. I'm getting SOME change in voltage at the sensor, but it's nowhere near the measured change in temperature.

For example, just sitting on the desk at 21.6 deg C, the sensor is passing 2.970 volts. Cranking up a small heater, the measured temp is 50.6 degrees and the voltage has increased to 3.210 volts, an increase of 240 millivolts. Since each 10mV represents 1 degree, the LM335 is measuring a 24 degree increase, as opposed to the actual 29 degrees. 5 degrees is a fairly big discrepancy but it's probably one that I can live with.

What's confusing me is trying to work out why, over the above temperature range, the analog pin readings only move from 590 to 626? My board's 5V output is actually 5.22V, hence there should be 5.22/1024=5.098 millivolts per ADC value, correct? So, 626-590 = 36, times by the step value of 5.098, gives 183.5 or so millivolts, nowhere near the 240mV I measured with the multimeter.

This is how I've got my sensor wired up:

<GND>------<LM335>------+------<2K2 resistor>------<+5.22V>
                                         |
                                         |
                               <Analog pin 0>

I've searched everywhere I can think of for this LM335 interface, so if anyone has any ideas or can see where I've gone wrong, please let me know!

I'm not past trying something else either - initially I tried using some thermistors instead of the LM335, but I think that they may not be quite up to the task. If anyone can recommend exactly which type of thermistor I should be using that would also be appreciated...

Thanks for reading, again!! smiley
15  Forum 2005-2010 (read only) / Interfacing / Re: LM35 thermometer on: October 29, 2008, 10:58:59 pm
Hi kg4wsv,

Glad to hear about the pulldown resistor, I'm not worried at all about low temperatures.

I was in the middle of writing a big reply to your post, when I went back to the spec sheets & discovered that I'm not using an LM35 sensor, I'm using an LM335 sensor!  :-[ This has raised lots of different issues which I'll plug away at, but certainly explains why my readings weren't making much sense!!

I'll post back here when I have (a) solved my problems or (b) need more help!!

Thanks, JB.

PS - 5.22 is the measured voltage from my 5V output.
Pages: [1] 2 3