I would also like to rapidly turn them on and off 1 microsecond on and 100 microsecond off.
Now what I noticed is that when I turn them on at 1us the leds dont turn on and there is no voltage between the positive and the drain of Q2 , if I turn them on for 25us and more the voltage is there.
So I changed R1 from a 100k resistor to a 1K resistor and then the leds turned on and the voltage was there when switching them on for 1us.
So what would be the best resistor to use for R1 ?
I know the resistor protects the Arduino but they also state
R1 has high resistance, so that when Q1 starts turning on, it easily overpowers R1.
The attached circuit, is that the circuit you use ? I want to be 100% sure of that.
What voltage is available for the leds ?
What is the value of R3 ?
Which Arduino board do you use ?
About 1us is fast for a slow mosfet. The input capacitance of your mosfet is 2.2nF. That is a lot !
You could add a "mosfet driver" with a combined transistor and fet output (a gate-charge-blaster-chip).
Or you could use a fast mosfet or a normal transistor for Q2.
The value of R1 can be as low as 150 ohm for an Arduino Uno.
I suggest to use two transistors. Use modern high gain and fast transistors. The 2N2222 was used by dinosaurs.
What is your project ? Why do you need it to turn on for 1us ? To make photos ?
There is another option : The peak current is 1A. Perhaps you could make a circuit without current limiter, and use that maximum peak current. Use a stable voltage and a resistor to keep the pulse below 1A. I would use about 700mA, that is double the continuous value and well below 1A.
The delayMicroseconds(1) is not accurate. I suggest to temporarily turn the interrupts off and use the special function to delay a number of clock cycles. But that depends on which Arduino board you have.
Yes I am using the attached circuit.
Voltage for the leds can be a 3.7 lipo or a 2cell lipo which is around 7.4v.
I am using an Uno now but want to move to a attiny later.
I got to switch it fast to get rid of sun interference, I can push the 1us to 5us but I would rather not
I was just thinking now switching at that speed makes the led look dim which is a problem, could i not switch it with higher current to get it brighter, how will that effect the life of the led?
I have also found a driver that has a High Switching Frequency up to 1MHz, will that not work?
You have to change something, that mosfet with that circuit is slow.
Do you have a link to the high switching driver ? Those drivers have often special high-speed mosfet outputs, that will work.
The life-time of a led is often a big mystery. Only well known manufacturers give details that are accurate. That's why I wrote using short pulses of 700mA which is double the normal current and still well below the peak of 1A. I think that is safe.
For diodes it is easier. That is often documented, and high peak currents will not reduce the life-time.
For leds, the brightness could be 50% after 2000 hours at the normal rated current (they were cheap ). I have UV leds that are even worse.
Its a pity I dont have a scope because I cant see the amp draw when switching so fast with my multimeter.
Mine are also cheap haha, if I could get 1000 hours out of the leds that would be good.
Ive attached a pic of the thing I am trying to copy because I cant afford to bye it due to import cost and currency conversion etc and my project needs are a little different.
The camera picks up infrared light and gives x y position to my arduino but the sun interferes so you have to modulate your source to differentiate between the 2.
So for the short pulses idea:
I would probably need a voltage regulator to keep my voltage stable any suggestions?
Then a resistor for the led.
And a fast mosfet or transistor any suggestions?
That is not a fast on/off switching thing for leds. It uses an inductance to create an efficient current source. For the inductance it has a switching frequency, and that can be up to 1MHz. The control line to turn the led on and off does not turn the led on and off at 1MHz. I took a look at the graphs of the datasheet, but I don't understand the PWM dimming.
Now I understand the 940nm: they are IR leds :o The forward voltage of 1.6V already gave it away.
I would use a transistor. Most normal mosfets have a gate capacitance that slows it down.
A BC338 is 800mA. I can't find a fast and common NPN transistor of 1A with high gain at the moment, sorry.
What about a single Li-ion or lipo cell of 3.6V (3.0 to 4.2V), and only one led per transistor. Add more circuits parallel for more leds.
The datasheet does not have a graph for the forward voltage with higher currents. I will use the 1.6V, but that is completely wrong.
4.2 - 1.6 = 2.6V, at 1A that requires a resistor of 2.6 ohm. Let's use 3.3 ohm.
With 3.3 ohm, the current could be maximum 780 mA for a full battery and 400 mA for an empty battery. Since that current is only a short pulse, the led should be okay.
Ok thanks man got it, going to give everything another try.
I am just going to have to figure out the correct forward voltage because it going to be more than 1.6 I think or I will just get leds with better datasheets