Show Posts
Pages: 1 2 [3] 4 5 6
31  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Arduino 0011 doesn't start on Vista on: April 20, 2008, 07:21:53 am
try running it on console and see its ouput
32  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Can't request access to Playground on: April 18, 2008, 05:59:08 am
it works now smiley
33  Forum 2005-2010 (read only) / Bugs & Suggestions / Can't request access to Playground on: April 17, 2008, 06:26:27 pm
I'm trying to visit the request access page, but i get to see the source code of the html form!!! It's insane.

I'm using firefox 2.0.0.4 under gentoo linux.
34  Forum 2005-2010 (read only) / Syntax & Programs / Re: timer interrupts problem on: May 24, 2008, 04:15:58 am
overload? just download the zip and check the code, it's small enough IMO.
35  Forum 2005-2010 (read only) / Syntax & Programs / Re: timer interrupts problem on: May 23, 2008, 03:15:28 pm
you can try with this lib: http://www.arduino.cc/playground/Main/MsTimer2
36  Forum 2005-2010 (read only) / Syntax & Programs / Re: Printing analogRead value to LCD on: May 14, 2008, 05:25:51 am
what library is that? can i see it?
37  Forum 2005-2010 (read only) / Syntax & Programs / Re: variable issues on: May 09, 2008, 03:44:30 am
try setting it as: volatile int, since interrupts sometimes do bad things with your registers.
38  Forum 2005-2010 (read only) / Syntax & Programs / Re: Counting pulses at 20 kHz? on: May 09, 2008, 03:31:22 am
check the FrecuencyTimer2 library on the playground.

http://www.arduino.cc/playground/Code/FrequencyTimer2

allows you to set timer2 at high rates like 40khz
39  Forum 2005-2010 (read only) / Interfacing / Re: Serial data to Visual Basic, Visual C++, Java on: May 16, 2008, 02:12:12 pm
May be any of you can help me.

Sometimes, when speaking to arduino from linux, i just read crap from arduino, and after some refreshes, i read good values.
Both are configured at 9600, no parity, 8bits, 1 stop bit.

Do you know why is it happening?
40  Forum 2005-2010 (read only) / Development / Re: FrequencyTimer2 in miliseconds on: May 09, 2008, 04:44:04 pm
check the library here: http://www.arduino.cc/playground/Main/MsTimer2
i hope you like it
41  Forum 2005-2010 (read only) / Development / Re: FrequencyTimer2 in miliseconds on: May 09, 2008, 02:37:22 pm
BroHogan, i've already done a stand-alone version (and better) that i'll post in an hour or so.
42  Forum 2005-2010 (read only) / Development / Re: FrequencyTimer2 in miliseconds on: May 08, 2008, 04:24:00 pm
thanks, i only hope future versions of arduino compiler support something similar since it's more user-friendly IMO
43  Forum 2005-2010 (read only) / Development / Re: FrequencyTimer2 in miliseconds on: May 08, 2008, 09:28:32 am
woot, 2nd version, now with multiple triggers for the same timer!

Code:
// up to 5 "virtual" overflows with the same timer
#define _TIMERS 5

static unsigned int _msecs[_TIMERS];
static unsigned int _counters[_TIMERS];
static void (*_funcs[_TIMERS])();

void _overFlow();
void Timer2Init();
void Timer2Func(byte num, void (*f)());
void Timer2Ms(byte num, unsigned int msecs);  // msecs = 0 for disabling


void _overFlow() {
  byte tmp;
  
  for(tmp = 0; tmp < _TIMERS; tmp++) {
    if (_msecs[tmp] > 0) {
      _counters[tmp] += 1;
      if ((_counters[tmp] % (_msecs[tmp]*2)) == 0) {
        _counters[tmp] = 0;
        (*(_funcs[tmp]))();
      }
      }
  }
}

void Timer2Init() {
  byte tmp;
  
  for(tmp = 0; tmp < _TIMERS; tmp++) {
        _msecs[tmp] = 0;
      _funcs[tmp] = 0;
      _counters[tmp] = 0;
  }
  
  FrequencyTimer2::setPeriod(1000);
  FrequencyTimer2::setOnOverflow(_overFlow);
}

void Timer2Func(byte num, void (*f)()) {
  _funcs[num] = f;
}

void Timer2Ms(byte num, unsigned int msecs) {
  _msecs[num] = msecs;
}

And a simple example:

Code:
void flash() {
  static boolean output = HIGH;
  
  digitalWrite(13, output);
  output = !output;
}

void flash2() {
  static boolean output = HIGH;
  
  digitalWrite(12, output);
  output = !output;
}

void setup() {
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  Timer2Init();
  Timer2Ms(0, 1000);  // flash a led each second
  Timer2Func(0, flash);
  Timer2Ms(1, 3000);
  Timer2Func(1, flash2);  // flash a led each 3 seconds
}

void loop() {
}
44  Forum 2005-2010 (read only) / Development / FrequencyTimer2 in miliseconds on: May 06, 2008, 05:34:49 pm
Since this library sets timer2 interrupt using microseconds and not letting you counting in seconds, i've written a wrapper to allow this.

Code:
static unsigned int _msecs = 0;
static void (*_func)() = 0;

void _overFlow();
void Timer2Init();
void Timer2Func(void (*f)());
void Timer2Ms(unsigned int msecs);

void _overFlow() {
  static unsigned int _counter = 0;
  
  _counter += 1;
  
  if ((_counter % (_msecs*2)) == 0) {
    _counter = 0;
    (*_func)();
  }
}

void Timer2Init() {
  FrequencyTimer2::setPeriod(1000);
  FrequencyTimer2::setOnOverflow(_overFlow);
}

void Timer2Func(void (*f)()) {
  _func = f;
}

void Timer2Ms(unsigned int msecs) {
  _msecs = msecs;
}

How to use? it's very easy:

Code:
void flashLed() {
  static boolean value = HIGH;
  digitalWrite(13, value);
  value = !value;
}
  
void setup() {
  pinMode(13, OUTPUT);
  Timer2Init();
  Timer2Ms(1000); // overflow each second
  Timer2Func(flashLed);
}

void loop() {
}

Do you like it?
45  Forum 2005-2010 (read only) / EspaƱol / Re: Estrujando los AD on: May 15, 2008, 12:01:56 pm
no existe problema alguno, cada ADC tarda su tiempo y punto.
Pages: 1 2 [3] 4 5 6