Pages: 1 [2]   Go Down
Author Topic: Getting a 1us delay  (Read 1278 times)
0 Members and 1 Guest are viewing this topic.
Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4773
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12778
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Which?  Charged capacitor or input capture?
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4773
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Some code from an older thread to measure short pulses, - see the discussion - http://arduino.cc/forum/index.php/topic,96971.0.html -
Code:
//
//    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++;
}
Logged

Rob Tillaart

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

Pages: 1 [2]   Go Up
Jump to: