TTL signal

Hello, I am new to Arduino so I have started with a simple project. I am using an Arduino Uno for this project.

I have a laser that I can use a TTL signal to fire it. I wrote a simple 5 line program but I am not getting the results I expected.

void setup() {

pinMode(11,HIGH);
}

void loop() {
digitalWrite(11,HIGH);
delay(1);

digitalWrite(11,LOW);
delay(1);

}

I uploaded this and I am getting 5v with 1 millisecond between the rise and fall. (what I expected and measured from my oscilloscope). If I enter any number less than 1 as my delay (.9 or .1 or .01) I get the same result of about 12µs for the same three delays. Is 1 ms the fastest I can set for the delay in this problem? For my laser I need a TTL signal of <50µs.

Is there a better method to what I want to accomplish? Need more information please let me know. Know how to accomplish switching a laser with a TTL <50µs, please give me some advice.

Thank you
Kevin

huaorani:
Hello, I am new to Arduino so I have started with a simple project. I am using an Arduino Uno for this project.

I have a laser that I can use a TTL signal to fire it. I wrote a simple 5 line program but I am not getting the results I expected.

void setup() {

pinMode(11,HIGH);
}

void loop() {
digitalWrite(11,HIGH);
delay(1);

digitalWrite(11,LOW);
delay(1);

}

I uploaded this and I am getting 5v with 1 millisecond between the rise and fall. (what I expected and measured from my oscilloscope). If I enter any number less than 1 as my delay (.9 or .1 or .01) I get the same result of about 12µs for the same three delays. Is 1 ms the fastest I can set for the delay in this problem? For my laser I need a TTL signal of <50µs.

Is there a better method to what I want to accomplish? Need more information please let me know. Know how to accomplish switching a laser with a TTL <50µs, please give me some advice.

Thank you
Kevin

delay() takes an unsigned long so the smallest non-zero value you can use is 1.

You could try delayMicroseconds(). How much less than 50uS do you need (as there are lower limits to its accuracy)?

You might also consider using a hardware timer to generate the signal for you, especially helpful if accuracy of the pulsewidth is important or if you want to modulate the signal etc.

pinMode(11,HIGH);

Although above does work because HIGH and OUTPUT are the same, it's cleaner to use

pinMode(11,OUTPUT);

What do you measure if you don't use any delay?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.