Show Posts
Pages: 1 ... 31 32 [33] 34 35 ... 133
481  Development / Other Software Development / Re: Nil RTOS update - Fast and Tiny! on: August 22, 2013, 10:14:47 am
I did it with a periodic task. Yours is more resource friendly, of course smiley
Code:
while (TRUE) {

wakeTime += SYSTIME_SYNC_PERIOD_TICKS;

// Sleep until time for next data point
nilThdSleepUntil(wakeTime);

// Read RTC..
nilSemWait(&i2cfree);
new_time = rtc.get_tm();
nilSemSignal(&i2cfree);
// .. and sync system Time and Date
setTime(new_time);
now();  // this makes the sync
}
}

Q: can I work with semaphores before I start the NilRtos? Like:

Code:
..
// SYNC the RTC and systime at boot
setSyncProvider(safeGetTime);   // the function to get the time from RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");  
setSyncInterval(300); // set the number of seconds between re-sync of time
sys_t_start = now(); // keep the boot start time
..
nilSysBegin();

While running above I get a proper time into "sys_t_start" var - it means the setSyncProvider() has called the safeGetTime() already.. So it had worked with semaphores, before the NilRtos actually started..


482  Development / Other Software Development / Re: Nil RTOS update - Fast and Tiny! on: August 22, 2013, 04:32:04 am
It comes from Time.h
PS:  setSyncProvider() calls RTC in regular intervals in order to sync "local time" (based on millis(). So it seems it must be guarded by a mutex.
483  Development / Other Software Development / Re: Nil RTOS update - Fast and Tiny! on: August 21, 2013, 04:46:56 pm
Could be the setsyncProvider() with setSyncInterval() used in setup() with Nirtos? Or better, a task shall be used for syncing (instead of the setSyncInterval())?
Code:
   setSyncProvider(RTC.get);   // the function to get the time from the actual RTC
..
     setSyncInterval(300);         // set the number of seconds between re-sync of time
     nilSysBegin();
484  Using Arduino / General Electronics / Re: Ultra low power - Selective powering of 5V IR sensor on: August 21, 2013, 04:02:19 pm
High-side p-mosfet switch:
arduino output Low:   Module powered
arduino output High:  Module power off
arduino output HiZ:   Module power off
485  Using Arduino / General Electronics / Re: Ultra low power - Selective powering of 5V IR sensor on: August 21, 2013, 02:40:18 pm
Use a p-channel mosfet as a high-side switch. Discussed many times here.
486  Development / Other Software Development / Exploring millis() on: August 21, 2013, 01:58:28 pm
@rob: Great analysis!!
My primary idea has been to have uint64_t timer0_overflow_count, and any calcs done in millis(). The cli() only for reading the timer0_overflow_count variable (as that is the capture point). And, may be a faster T0 interrupt freq (ie 256us)..
Code:
volatile unsigned long long timer0_overflow_count = 0;

SIGNAL(TIMER0_OVF_vect)
{
timer0_overflow_count++;  
}

unsigned long millis()
{
        // update to prevent reading incorrect value
       uint8_t oldSREG = SREG;
        cli();
unsigned long long m = timer0_overflow_count;  
        SREG = OLDREG

        Any calculus here...
}
But that might be too much processing for an 8bitter smiley

487  Using Arduino / Microcontrollers / Re: millis() not in sync with 8MHz system clock? on: August 21, 2013, 01:44:08 am
Quote
Essentially, the problem is that millis does not always increment by 1.
The T0 overflow isr increments in 1.024ms intervals (tick). There is a calculus inside the isr which makes the adjusting ticks to millis(). That is not linear within an one second interval probably, but precise in long run.
If you want a precise timekeeping you may consider the zero drift clock which works for any crystal oscillator frequency - see my topic in other sw dev.
488  Development / Other Software Development / Exploring millis() on: August 20, 2013, 04:54:07 pm
@rob: yes wiring.c, there is a calc for millis()
Code:
..
m += MILLIS_INC;
f += FRACT_INC;
if (f >= FRACT_MAX) {
f -= FRACT_MAX;
m += 1;
}
..
This does the conversion from ticks to millis, millis = 1.024*ticks.
489  Development / Other Software Development / Re: Nil RTOS update - Fast and Tiny! on: August 20, 2013, 02:02:37 pm
ok, so something like handshaking:  
Code:
// Wait for access to I2C bus.
    nilSemWait(&i2cSem);                     <<  waits on signal I2C is free (resource semaphore 1 -> 0 )
    // Access I2C bus here.    
    // Release I2C bus.
    nilSemSignal(&i2cSem);                   >>  signals I2C is free (resource semaphore 0 -> 1 )
I'll try..
thx..it seems it works.. now I know why we need counting semaphores smiley
490  Development / Other Software Development / Exploring millis() on: August 20, 2013, 01:27:46 pm
Cool.. There is a calculus for converting the timer0_overflow_ticks into millis() within the timer0 OVF ISR. I've been thinking to move that calculation into millis() function, but still as I see it is a lot of calcs..
491  Using Arduino / Microcontrollers / Arduino Uno @65MHz on: August 20, 2013, 11:23:15 am
http://3.14.by/en/read/arduino-liquid-nitrogen-overclocking
492  Development / Other Software Development / Re: Nil RTOS update - Fast and Tiny! on: August 20, 2013, 09:38:45 am
I have several tasks, two of them handle I2C. First reads ads1110 ADC (per. every 100ms) and the second one reads an external RTC (for example each second). Running both tasks accessing single I2C bus does not work well - it comes to data corruption.
What is the proper handling of such situation under NilRtos?
493  Development / Other Software Development / Re: New fork of the IDE on: August 20, 2013, 04:04:25 am
The upload works better now with the latest uecide, even I see an error message there:
Code:
Error grabbing serial port: uecide.plugin.AutoFormat.releasePort(java.lang.String)
Avrdude finds it and uploads..
494  Development / Other Hardware Development / Re: *** SUGGESTIONS FOR BEST PROCESSOR TO USE FOR NEW ARDUINO BOARD *** on: August 20, 2013, 02:15:37 am
The CM0+ is the closest alternative to avr 8bitters, imho. The key factor here is the price and power consumption. CM3 is obsolete, CM4 is expensive..
495  Development / Other Software Development / Re: New fork of the IDE on: August 19, 2013, 04:51:08 pm
ok. it works now..
Pages: 1 ... 31 32 [33] 34 35 ... 133