Good Oscilloscope Projects for Beginners? / Skills Test / TDR

TDR


Simple TDR circuit:

How to wire the setup:

Contraption photo:

Oscilloscope trigger setup:

Horizontal Zoom = ~20ns
Vertical Zoom = ~2V or 5V

Trigger: Normal or Single
Type = Edge
Source = Channel 1
Slope = Rising
Coupling = DC
Level = ~3.40V


Testing

Tap the button once, and you should get something similar to the below picture:

The unknown wire in this example is a medium length extension cord.

You then use the Cursors to measure the time difference between the bottom of the first spike, and the bottom of the second spike.
Once you have your measurement (71.20ns in this example), use this calculation to get the distance in feet:
(71.20ns * 0.983 * 0.67) / 2 = 23.44 feet

This extension cord is 23.5 feet long.

3 Likes

That's a nice setup. Have you measured the rise time of the pulse? It looks pretty fast.

1 Like

Hello @EmilyJane!

Yeah, the rise time is ~6ns.

1 Like

What is the value of clockMillis the first time it is used?

1 Like

A trick question, eh? It's "uninitialized".

Does that affect the way the sketch runs? :wink:

1 Like

It can affect it in a bad way. The value โ€˜0โ€™ should be assigned to it during definition. :wink:

1 Like

When starting a millis( ) based TIMER you must reset it !

One way to Corrected sketch:



const byte clockLED             = 12;

bool greetingFlag               = false;

unsigned long clockMillis;

const unsigned long interval    = 50;  //50ms

//*********************************************************************************
void setup()
{
  Serial.begin(9600);

  pinMode(clockLED, OUTPUT);

} //END of   setup()


//*********************************************************************************
void loop()
{
  //******************************************
  //at the begining of the sketch print a greeting
  if (greetingFlag == false)
  {
    //print a greeting to the user
    Serial.println("Welcome to Oscilloscope Training.");

    //give 2 seconds to read the serial monitor
    delay(2000);

    //we have finished with the greeting, disable it form here on in
    greetingFlag = true;

    //start the TIMER
    clockMillis = millis();        //  <------<<<<<<   reset the TIMER
  }

  //******************************************
  //toggle the clock LED every 50ms
  if (millis() - clockMillis >= interval)
  {
    //restart the TIMER
    clockMillis = clockMillis + interval;

    //toggle LED
    digitalWrite(clockLED, !digitalRead(clockLED));
  }

} //END of loop()
1 Like

OR



const byte clockLED             = 12;

bool greetingFlag               = false;

unsigned long clockMillis;

const unsigned long interval    = 50;  //50ms

//*********************************************************************************
void setup()
{
  Serial.begin(9600);

  pinMode(clockLED, OUTPUT);

} //END of   setup()


//*********************************************************************************
void loop()
{
  //******************************************
  //at the begining of the sketch print a greeting
  if (greetingFlag == false)
  {
    //print a greeting to the user
    Serial.println("Welcome to Oscilloscope Training.");

    //give 2 seconds to read the serial monitor
    delay(2000);

    //we have finished with the greeting, disable it form here on in
    greetingFlag = true;

  }

  //******************************************
  //toggle the clock LED every 50ms
  if (millis() - clockMillis >= interval)
  {
    //synchronize the TIMER if there are delays in the code   <------<<<<<<   
    while (millis() - clockMillis >= interval) 
    {
      clockMillis = clockMillis + interval;
    }

    //toggle LED
    digitalWrite(clockLED, !digitalRead(clockLED));
  }

} //END of loop()
1 Like

Ah, that makes sense.

Do you have any more :wink:?

After breakfast.
:fried_egg:

1 Like

This is the method I use 99% of the time, see the <--------<<<<< line of code:



const byte clockLED             = 12;

bool greetingFlag               = false;

unsigned long clockMillis;

const unsigned long interval    = 50;  //50ms

//*********************************************************************************
void setup()
{
  Serial.begin(9600);

  pinMode(clockLED, OUTPUT);

} //END of   setup()


//*********************************************************************************
void loop()
{
  //******************************************
  //at the begining of the sketch print a greeting
  if (greetingFlag == false)
  {
    //print a greeting to the user
    Serial.println("Welcome to Oscilloscope Training.");

    //give 2 seconds to read the serial monitor
    delay(2000);

    //we have finished with the greeting, disable it form here on in
    greetingFlag = true;

  }

  //******************************************
  //toggle the clock LED every 50ms
  if (millis() - clockMillis >= interval)
  {
    //if some inaccuracy can be accepted use this      <------<<<<<<
    clockMillis = millis();

    //toggle LED
    digitalWrite(clockLED, !digitalRead(clockLED));
  }

} //END of loop()
1 Like

Do you have any logic level MOSFETs ?

Yep! How about the STP90NF03L? I use it for most projects.

Connect your MOSFET as seen in this schematic.

Write a sketch that toggles pin 2 at 10Hz on Arduino D2.

Show us your screen capture of the turn ON chacteistics. (here is mine)

Corrected image:

I think I got it :thinking:.

Here is the sketch:

#define PULSE63_13     cli(); PINB = bit(PINB5); PINB = bit(PINB5); sei()

const byte pulsePin = 2;

unsigned long clockMillis = 0;

const unsigned long interval    = 50;  //50ms

//*********************************************************************************
void setup()
{
  Serial.begin(9600);

  pinMode(pulsePin, OUTPUT);
} //END of   setup()


//*********************************************************************************
void loop()
{
  //PULSE63_13;//for testing

  //******************************************
  //toggle the clock pin every 50ms = 10 hertz
  if (millis() - clockMillis >= interval)
  {
    //restart the TIMER
    clockMillis = millis();

    //toggle pulse pin
    digitalWrite(pulsePin, !digitalRead(pulsePin));
  }

} //END of    loop()

Here is what the scope shows with the STP90NF03L:

Is that right?

Are you using a 0.1uF capacitor ?

Oh, no. In your schematic, it says to use a 1ยตF capacitor. Is that not right?

It says .1uF

i.e. 100nF

Ah, that explains it. I missed the "." :person_shrugging:.

1 Like