Show Posts
Pages: 1 [2] 3 4 ... 7
16  Using Arduino / Programming Questions / Re: attachInterrupt() calls wrong function upon interrupt on Arduino Mega2650 on: September 23, 2013, 06:59:08 pm
What board are you compiling for? Because when I compile your code I get the following IVT:

Code:
00000000 <__vectors>:
   0: 71 c0        rjmp .+226    ; 0xe4 <__ctors_end>
   2: 00 00        nop
   4: 57 c1        rjmp .+686    ; 0x2b4 <__vector_1>
   6: 00 00        nop
   8: 86 c1        rjmp .+780    ; 0x316 <__vector_2>
   a: 00 00        nop
   c: b5 c1        rjmp .+874    ; 0x378 <__vector_3>
   e: 00 00        nop
  10: e4 c1        rjmp .+968    ; 0x3da <__vector_4>
  12: 00 00        nop
  14: 13 c2        rjmp .+1062    ; 0x43c <__vector_5>
  16: 00 00        nop
  18: 42 c2        rjmp .+1156    ; 0x49e <__vector_6>
  1a: 00 00        nop
  1c: 71 c2        rjmp .+1250    ; 0x500 <__vector_7>
  1e: 00 00        nop
  20: a0 c2        rjmp .+1344    ; 0x562 <__vector_8>
  22: 00 00        nop
  24: 7f c0        rjmp .+254    ; 0x124 <__bad_interrupt>
  ...
17  Using Arduino / Programming Questions / Re: Display floating point temperature on 7-segment display on: September 20, 2013, 04:32:24 pm
Multiply the float by 100 and convert it to an integer.

Code:
int intTemp = floatTemp * 100;

This will turn 12.3456 into 1234.
Now you can display the digits onto the 7 segment display and simply enable the dot before the last two digits.

How about if the temperature is 100.1?
18  Using Arduino / Programming Questions / Re: Arduino assembler programming on: August 15, 2013, 09:57:34 am
Inline Assembly is a good method to get your feet wet. However it has somewhat odd and confusing syntax.

Mixing C and assembly in AVR Studio is another method.

Check out the book, "Programming Microcontrollers using Assembly Language" for an excellent primer.

Goodluck...
19  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."
20  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.
21  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
22  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.
23  Using Arduino / Programming Questions / Re: 2 critical interrupts question on: May 22, 2013, 01:40:28 pm
Nesting interrupts is possible. Carefully.
24  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.
25  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);
      }
}
26  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
27  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.
28  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)

29  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)

30  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...
Pages: 1 [2] 3 4 ... 7