Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Programming Questions / Re: All about timers - how to handle sw interrupts? on: July 20, 2013, 11:06:58 am
Timers generate hardware interrupts - a software interrupt is something different.

Per Datasheet:

"The External Interrupts are triggered by the INT0 and INT1 pins or any of the PCINT23..0 pins. Observe that, if enabled, the interrupts will trigger even if the INT0 and INT1 or PCINT23..0 pins are configured as outputs. This feature provides a way of generating a software interrupt."
17  Using Arduino / Programming Questions / Re: Incorrectly calculating elapsed time between interrupts. on: July 12, 2013, 03:34:07 pm
Just curious, have you tried to install the interrupt without using Arduino's attachInterrupt() function?

Also, there is a known issue with calling micros() with IRQs disabled and the potential for timer0 rollover, however, I don't believe this to be your issue.
18  Topics / Science and Measurement / Re: Oscilliscope for beginners on: July 11, 2013, 07:56:23 am
Understanding Signals Tutorial at: http://www.parallax.com/go/propscope
19  Using Arduino / Programming Questions / Re: full adder/subtracter with carry on: June 28, 2013, 04:03:05 pm
add:
Code:
unsigned char low, high;

void setup() {                
}

void loop() {

  //add 1 with carry
  asm(
    "lds r24, (low)  \n\t"  //low byte
    "lds r25, (high) \n\t"  //high byte
    "ldi r23, 1      \n\t"  
    "add r24, r23    \n\t"  //increment low byte by 1
    "adc r25, 0x00   \n\t"  //add carry to high byte
    "sts (low), r24  \n\t"  //save results
    "sts (high), r25 \n\t"
    ::: "r23","r24", "r25"
  );

  //subtract 1 with carry
  asm(
    "lds r24, (low)  \n\t"
    "lds r25, (high) \n\t"
    "ldi r23, 1      \n\t"
    "sub r24, r23    \n\t"
    "sbc r25, 0x00   \n\t"
    "sts (low), r24  \n\t"
    "sts (high), r25 \n\t"
    ::: "r24", "r25"
  );
}

Edit note: for completeness I included the subtraction code. My original thought was that the OP was requesting an assembly language routine.
20  Using Arduino / Programming Questions / Re: 2 critical interrupts question on: May 22, 2013, 01:40:28 pm
Nesting interrupts is possible. Carefully.
21  Using Arduino / Programming Questions / Re: Cornering fog lights / turning assistant. on: May 14, 2013, 10:43:44 pm
After changing RISING to INPUT - both lamps are on permanently..

INPUT is not a proper mode parameter for attachInterrupt. However, it results in generating an interrupt request on the low level of the pin.
22  Using Arduino / Programming Questions / Re: Cornering fog lights / turning assistant. on: May 14, 2013, 11:36:15 am
like this?
Code:
/* Light turning assistant for cars (cornering lights)
   Credits to user Dr_P at http://mjlorton.com forum
   
*/
int fogL = 8;                               // 55W Relay for L fog lamp
int fogR = 7;                               // 55W Relay for R fog lamp
int indL = 4;                               // Circuit between multiswitch and indicator relay
int indR = 2;                               // Circuit between multiswitch and indicator relay

void SignalHigh() {
  digitalWrite(fogR, HIGH);
  digitalWrite(fogL, HIGH);
}

void setup() {
  pinMode(fogL, OUTPUT);
  pinMode(fogR, OUTPUT);
  pinMode(indL, INPUT);
  pinMode(indR, INPUT);
  attachInterrupt(1, SignalHigh, RISING);
}

void loop() {
  int i = 100;                                    // counter initialized with "done" value

  if (digitalRead(indR)) {
    i=0;                                          //if indicators were reversed, the cycle needs to be reset to full 5s
    while(digitalRead(indR) && i<100) {
      i++;
      digitalWrite(fogR, HIGH);
      digitalWrite(fogL, LOW);
      delay(50);
    }
  }
  if (digitalRead(indL)) {                        //same as right side
    i = 0;
    while(digitalRead(indL) && i<100) {
      i++;
      digitalWrite(fogR, LOW);
      digitalWrite(fogL, HIGH);
      delay(50);
    }
  }
  if (!digitalRead(indR) && !digitalRead(indL))   // no indicators currently on
    if (i == 100) {                               //neither indicators were on OR the 5s cycle is over
      digitalWrite(fogR, LOW);
      digitalWrite(fogL, LOW);
    } else                                        //one or both indicators were on for less than 5s
      while(!digitalRead(indR) && !digitalRead(indL) && i<100) { //but not any more
        i++;                                      //finish the 5s cycle in the last foglight configuration
        delay(50);
      }
}
23  Using Arduino / Programming Questions / Re: How to interface LISY300 Gyroscope Module with arduino on: May 11, 2013, 10:44:58 pm
http://wiring.org.co/learning/basics/gyrolisy300al.html
24  Using Arduino / Programming Questions / Re: Is AVR studio more code-space efficient than Arduino IDE? on: May 06, 2013, 01:42:52 pm
Are you talking about the code on the PC or the arduino?

The arduino IDE compiled code includes some routines for timing, pwm, pin manipulation and the like. So there is some room for small reductions if you're not using those functions.  With AVR Studio, you could also ditch the bootloader and gain space there as well. But as said above, same compiler, so same results for identical source.
25  Using Arduino / Programming Questions / Re: Motor Acceleration Timer Deceleration Problem on: April 23, 2013, 06:09:05 pm
bigger hint:

Code:
  if (millis() - 0 >= 1000)

26  Using Arduino / Programming Questions / Re: Motor Acceleration Timer Deceleration Problem on: April 23, 2013, 02:46:46 pm
What happens if this statement is false?

Code:
  if (millis() - lastTick >= 1000)

27  Using Arduino / Programming Questions / Re: 7-segment LED Displays on: April 21, 2013, 03:51:50 pm
http://playground.arduino.cc//Main/InterfacingWithHardware#Output

scroll down to 7 segment displays...
28  Using Arduino / Programming Questions / Re: Millis Accuracy Again on: April 18, 2013, 02:20:23 pm

Exactly. He's getting way too much variation to conclude that millis() are the cause.


Exactly X2

I did a quick look at your code and offer these suggestions:
 
1. Delay() is bad, and it appears your code is planted there. Try using a non-blocking delay.
2. You are running lots of ISRs (Serial, SPI, ADC, to identify a few) which could be blocking. Try eliminating/minimizing some and see if your timer accuracy improves.

29  Using Arduino / Programming Questions / Re: adressing data from assembler on: April 08, 2013, 12:13:47 pm
Generating your own pro/epilogue code: http://ucexperiment.wordpress.com/2013/03/13/improving-the-interrupt-service-routine/
30  Using Arduino / Programming Questions / Re: "RMSVal" was not declared in this slope on: April 02, 2013, 12:48:35 pm
Also check use of RMSPin v. RMSPIN
Pages: 1 [2] 3 4 ... 6