Show Posts
Pages: 1 ... 3 4 [5] 6
61  Using Arduino / Programming Questions / Which Arduino Processor is My Code Running On? on: February 23, 2012, 12:11:09 pm
Need to determine which Arduino processor your code is running on? Simply access the signature bytes.
62  Using Arduino / Programming Questions / Re: Assembly generated code on: February 21, 2012, 04:17:54 pm
Windows instructions can be found here.
63  Community / Exhibition / Gallery / arduino IR Lap Timer on: February 20, 2012, 01:21:54 pm
IR-based Lap Timer suitable for cars, karts, motorcycles and bikes.
Utilizes an AIM IR Beacon Transmitter, but project site has information on how to make your own beacon.
Project information, including video demonstration, schematic and source code is located here.
64  Using Arduino / Displays / Sample code for inverting 4-digit 7-segment display on: February 12, 2012, 04:39:22 pm
Go from this:


To this:


Demo and explanation on my blog here.
65  Using Arduino / Project Guidance / Re: Binary Clock - using RTC on: January 24, 2012, 11:59:15 am
I doubt this call will work inside an interrupt:

Code:
DateTime now = rtc.now();
66  Using Arduino / Project Guidance / Re: Lap Timer on: January 10, 2012, 05:57:39 pm
Rob - nope, I'd never even heard of XBEE until now - I could use two of them on one Arduino?

Chagrin - I have 2 AiM IR Beacon Transmitters, model TL0600 - http://www.magnaracing.com/index.php?main_page=product_info&products_id=2001

and 2 receiver breakouts - http://www.sparkfun.com/products/8554

Thanks for your help!

I have built lap timers that are internal to the vehicle using Arduino and the AIM beacons you reference. But it seems you want the timer to be outside of the vehicle, stationary. Is that correct? If that is the case, you don’t need the AIM beacons.  Please clarifiy.
67  Using Arduino / Programming Questions / Re: Computing the Time it takes for indivdula instructions to excute? on: September 03, 2011, 11:21:13 am
1. count cycles

2. run code in avr studio simulator and use the stopwatch

3. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1175115259



68  Using Arduino / Programming Questions / Re: Atmega Assembler on: June 16, 2011, 12:40:49 pm
May I suggest, "Programming Microcontrollers using Assembly Language"  by Chuck Baird.
69  Using Arduino / Microcontrollers / Re: PIC vs AVR? on: June 15, 2011, 11:53:58 am
Once you understand the arduino, it's not a big leap to start programming AVR chips with an ISP and AVR Studio.
70  Topics / Science and Measurement / Re: accessing adc at faster rate on: May 16, 2011, 09:50:33 am
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1208715493/11
71  Using Arduino / Microcontrollers / Re: Pin change interrupts on arbitrary pins? on: March 20, 2011, 02:16:26 pm
afaik, only 2 pins for interrupts on 8/168/328 arduinos, however, more pins are available on the mega based boards. you would need to hardcode the interrupts, and i'm not sure if doing that would break any other functions.

something like this worked for me:

Code:
ISR(PCINT0_vect) {
  …
}

Setup() {
  //disable interrupts
  cli();
  
  //setup digital pin #8 pin-change interrupt (see datasheet)
  PCICR |= (1<<PCIE0);
  PCMSK0 |= (1<<PCINT0);
 
  //enable interrupts
  sei();
}
72  Using Arduino / Programming Questions / Re: Arduino as a chronometer ? Know what you are doing ! on: March 06, 2011, 10:55:27 am
update?
73  Using Arduino / Programming Questions / Re: Reading width of pulses on: March 05, 2011, 10:29:03 am
use a pin interrupt like this:

Code:

#define INT_PIN 3  //input pulse pin

extern volatile unsigned long timer0_millis;
volatile unsigned long t, now, prev;

void setup() {
  Serial.begin(9600);
 
  //init interrupt
  pinMode(INT_PIN, INPUT);
  attachInterrupt(1, PulseInterrupt, FALLING);  //0 = digital pin 3
}

void PulseInterrupt(void) {
  now = timer0_millis;
  t = now - prev;
  prev = now;
}

void loop() {
  Serial.println(t);
  delay(1000);
}

74  Using Arduino / Programming Questions / Re: Arduino as a chronometer ? Know what you are doing ! on: March 01, 2011, 03:59:50 pm
If it makes you feel safer, you can replace MyMicros() with:

Code:

//returns current microsecond [us] count
unsigned long MyMicros(void) {
  unsigned long m;
  uint8_t oldSREG = SREG, t;

  cli();
  m = my_timer0_millis;
  t = TCNT0;
  if ((TIFR0 & _BV(TOV0)) && (t < 249))
    m++;
  SREG = oldSREG;
  return ((m*250) + t)*4);
};


for testing purposes, the previous code will work fine. Also, I think it will only run on a 168/328 based arduino running at 16MHz too.
75  Using Arduino / Programming Questions / Re: Arduino as a chronometer ? Know what you are doing ! on: March 01, 2011, 03:47:01 pm
Here's a test for you. Insert the following code, which replaces the TIMER0 ISR, and recheck your results. The arduino TIMER0 ticks off at a 1.024 ms (vs. an implied 1ms) which creates some nasty timer/math issues. Admittedly, this code will break millis(), micros() and some PWM stuff too, but disregard that for now ;-)

Just call MyMicros() instead of micros().

Code:

//millisecond counter
volatile unsigned long my_timer0_millis;

ISR(TIMER0_COMPA_vect) {
  //incremented every 1ms
  my_timer0_millis++;
}

//returns current microsecond [us] count
unsigned long MyMicros(void) {
  unsigned long m;
  uint8_t t;

  m = my_timer0_millis;
  t = TCNT0;
  if ((TIFR0 & _BV(TOV0)) && (t < 249))
    m++;
  return ((m*250) + t)*4);
}

void setup(void) {
  ...

  //turn off interrupts
  cli();
  
  //replace arduino timer0 code with our timer
  my_timer0_millis = 0;
  // 16Mhz/64 prescale/250 counts = 16000000/64/250 = 1000us (1ms)
  TCCR0A = 0;
  TCCR0A |= (1<<WGM01);            // CTC mode, top=OCR0A, TOV0 set @ max, update immediate
  TCCR0B = 0;
  TCCR0B |= (1<<CS01) | (1<<CS00); // F_CPU/64
  TIMSK0 |= (1<<OCIE0A);           // enable CTC A interrupt
  OCR0A = 249;                     // 249 results in a 250 count rollover

  sei();

  ...

}


Pages: 1 ... 3 4 [5] 6