Go Down

Topic: Getting a 1us delay (Read 1 time) previous topic - next topic

GoForSmoke

It's the circuit that matters more. You have to be able to charge the cap much quicker than it bleeds.

There must be some other physical events that you could use. With radar and a CRT display you 'see' the return time as distance along a sweep trace. On our 1950's sets the minimum was about 250 meters because the outgoing pulse took that long but 500 m travel time (out and back) when light moves about 300,000,000 m/s is just over 1 usec, and we could tell 10 m differences in range easily.

Maybe you could invert the delay, have that interval cut from something bigger that's known or some way take a ratio with a known and get a measure from that?

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Coding Badly

Does anybody have a working code snippet I could use to achieve that?


Which?  Charged capacitor or input capture?

GoForSmoke

I think I could make such a circuit. If the pulse switches a transistor that charges a cap then the charge in the cap couldn't bleed back through the transistor when the pulse ended, could it?
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

robtillaart


Some code from an older thread to measure short pulses, - see the discussion - http://arduino.cc/forum/index.php/topic,96971.0.html -
Code: [Select]

//
//    FILE: PulseWidthMeter.pde
//  AUTHOR: Rob Tillaart
//    DATE: 2012-apr-01
//
//    LINK: http://arduino.cc/forum/index.php/topic,96971.45.html
//
// PURPOSE: measures short pulses that are send one per second
//

#include <avr/io.h>
#include <avr/interrupt.h>

volatile unsigned int count = 0;
unsigned int pulseCounter = 0;

void setup()
{
  Serial.begin(38400);
  Serial.println("PulseWidthMeter (timer1) 0.2");
  pinMode(3, INPUT);
}

void loop()
{
  // reset Timer1 registers and the counters (timer must be stopped before reset of counters!.
  TCCR1A = 0;
  TCCR1B = 0;
  count = 0;
  TCNT1 = 0;
  TIMSK1 = (1 << TOIE1);                      // enable Timer1 overflow interrupt:

  while ((PIND & B00001000) == B00000000);    // wait for HIGH
  TCCR1B |= (1 << CS10);                      // Set CS10 bit so timer runs at clock speed: 16 MHz
  while ((PIND & B00001000) == B00001000);    // wait for low
  TCCR1B = 0;                                 // stop counting
  pulseCounter ++;

  // Read the counters and convert to long
  unsigned long total = count * 65536L + TCNT1;  // Might need a +1 to correct start/stop calibration.
  float usec = (1.0 * total) / 16;

  // Display values
  Serial.print(total, DEC);
  Serial.print(" \t ");
  Serial.println(usec, 1);
  Serial.print("pulses: ");
  Serial.println(pulseCounter);
}

// count the overflows in IRQ
ISR(TIMER1_OVF_vect)
{
  count++;
}
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up