View previous topic :: View next topic |
Author |
Message |
velja
Joined: 17 Aug 2015 Posts: 4
|
Posted: Sat Feb 25, 2017 11:31 pm Post subject: 1 day delay |
|
|
Hi,
I make weather station with atmega328 on 16MHz. I need for rain gauge period of 1 day. I can count impulse from rain gauge, accumulate it, but after 1 day I have to reset that value (mm/day rain fall). I use timer1 on interrupt for measuring period for wind speed sensor so I can't use it for making time base. How to solve this problem? |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Sun Feb 26, 2017 2:08 am Post subject: |
|
|
In my web severs in the blog section I have created a real time clock
using the CPU clock I increment a variable during this interrupt
the variable is there to get NTP time each 24hours you could use
this for your purpose.
Regards Paul |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1173 Location: France
|
Posted: Sun Feb 26, 2017 11:02 am Post subject: |
|
|
With Arduino Uno you can't use the internal clock system because the M328 use PB6 and PB7 with the external 16MHz crystal so impossible to use a 32Khz crystal
but you can use an external I2C RTC as DS3231 or other softclock then you can use varWord= Sysday()
JP |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Sun Feb 26, 2017 12:02 pm Post subject: |
|
|
Hello Jp
I use the 16Mhz CPU clock and if you measure the frequency of the clock
I have found it to be ok for 24hour periods I then updated via NTP
Regards Paul |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1173 Location: France
|
|
Back to top |
|
|
velja
Joined: 17 Aug 2015 Posts: 4
|
Posted: Sun Feb 26, 2017 12:50 pm Post subject: |
|
|
Well, it's not essential to be 24 hours strictly. About external RTC, I have module with DS1307 but it fit on 5V system which is not mine. I use 3,3V, but it is important to use less components as it is possible with low power consumption as it is solar powering device. The one day period is on second place. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
|
Back to top |
|
|
O-Family
Joined: 23 May 2010 Posts: 328 Location: Japan
|
Posted: Sun Feb 26, 2017 3:06 pm Post subject: |
|
|
If Timer0 or Timer2 is not used, 1 second can be created even with 8bit timer.
And it is possible to count it 24 hours.
Code: | Dim T8msec As Byte
Config Portb.5 = Output
Config Timer2 = Timer , Prescale = 1024 , Clear Timer = 1 '16,000,000Hz / 1024 = 15,625Hz
Ocr2a = 125 - 1 '15,625Hz / 125 = 125Hz (8mS)
Do
If Tifr2.ocf2a = 1 Then 'Did 8ms elapsed?
Set Tifr2.ocf2a
T8msec = T8msec + 1
If T8msec = 125 Then 'Did 1sec elapse? (8ms * 125 = 1sec)
T8msec = 0
Set Portb.5 'The Arduino LED lights up at 1 second intervals.
Waitms 5
Reset Portb.5
End If
End If
Loop
End |
|
|
Back to top |
|
|
|