Duty cycle doubt

Hi,
First of all, I apologize for my English. I'm not native but I'll try to do my best.

I'm building a project to pulse a light: I have a laser connected to an Arduino and I switch it on and off during a period in order to pulse it in a determined frequency.

This laser works with 3.3V and as the output tension of a digital pin is 5V, I thought I could put a resistor to get those 3.3V. I realized I got about 1.5V and it was because Arduino wasn't giving 5V. In fact, I get an output of 2.5V where the laser is connected.
I think this is because of the duty cycle: As I am turning the pin on and of during the same period, my duty cycle is 50%:

digitalWrite(11,HIGH);
delayMicroseconds(period);
digitalWrite(11,LOW);
delayMicroseconds(period);

Then, is the laser receiving 5V or 2.5V? I need 3.3V, so if the output is 5V I know I need a resistor... but what do I need if I'm getting a lower value?

My knowledge of electronics is quite limited so I guess you can help me.

Thanks in advance!

By laser do you mean a laser diode? If you are trying to power the laser
directly from an Arduino pin then it won't work, you are likely to damage
something.

Perhaps we can be more useful if you give us the details - which laser? Is
there a datasheet?

In general a laser diode needs a constant-current supply, not constant
voltage, so it all sounds a bit wrong...

What MarkT said, as well as:
How are you measuring your voltage? If you are using a DVM, it will take the DC average of your signal, which the DC average of a a square wave is the duty cycle * amplitude. You'll want to check using an oscilloscope if possible.

think this is because of the duty cycle:

No it is not.
The problem is :-

I thought I could put a resistor to get those 3.3V.

Using a single resistor to reduce a voltage is wrong. It will only give you a consistent voltage drop if the current from the device is constant, which it rarely is.

Driving a Laser is not easy, it is not simply of shoving a voltage at it, you normally need a special driver. You also need to know what current the Laser would normally take giving it 3V3. This page has a lot of good advice about driving a Laser.
http://www.repairfaq.org/sam/laserdps.htm

Perhaps we can be more useful if you give us the details - which laser? Is
there a datasheet?

I bought the laser here: http://www.aixiz.com/store/product_info.php/cPath/65/products_id/359
Is this a laser diode? Which is the difference?

What MarkT said, as well as:
How are you measuring your voltage? If you are using a DVM, it will take the DC average of your signal, which the DC average of a a square wave is the duty cycle * amplitude. You'll want to check using an oscilloscope if possible.

Yes, I am measuring the voltage with a digital voltimeter. Then, if I am measuring the average, that means the laser is receiving 5V (the digital output)? Or 2.5V?
I'm sure it sounds a stupid question but... :~

Grumpy_Mike , I think I understand what you say about the resistor. I noticed it was the wrong way and I removed it.
Thanks for the info. I'm going to have a look.

Nevertheless, still I have doubts about the duty cycle.

Thank you!

The data sheet says:-

automatic current control driver included,

So you just have to insure you have the right voltage.

about the resistor. I noticed it was the wrong way and I removed it

I hope you are not using it with 5V, The maximum voltage according to that sheet is 2.5V, you should not even be driving it with 3.3V. You should be driving it with 1.8V.

Nevertheless, still I have doubts about the duty cycle.

You have to explain why you have those doubts.
The duty cycle has nothing to do with anything here.

Grumpy_Mike:
I hope you are not using it with 5V, The maximum voltage according to that sheet is 2.5V, you should not even be driving it with 3.3V. You should be driving it with 1.8V.

You have to explain why you have those doubts.
The duty cycle has nothing to do with anything here.

Well, I am a little bit confused: that datasheet says 2.3Vmáx but the heading of the item says 3.2V (also in the invoice).

My doubts about the duty cycle is because I am turning it on and off during the same time. So this means a 50% duty cycle. Am I right? Then, if I have an output of 5V and a duty cycle of 50%, if I measure the voltage with a DVM, I get 2.5V. This means I am driving the laser (or whatever I have connected) with 5V or 2.5V? This is maybe stupid, but I am starting and everything is a huge doubt for me.

Thanks!

PS: Great web! I have to read all that carefully.

So this means a 50% duty cycle. Am I right?

Yes that is correct.

Then, if I have an output of 5V and a duty cycle of 50%, if I measure the voltage with a DVM, I get 2.5V

That is true but it is misleading, it makes you conclude:-

This means I am driving the laser (or whatever I have connected) with 5V or 2.5V?

Measuring a PWM voltage on a DVM is very misleading. You are always driving with 5V.
The fact that it is PWM means it is 5V and 0V rapidly, but the peak voltage is still 5V and it is that peak voltage that matters in things like voltage ratings. If you were driving an LED or heater than the average voltage of 2.5V is what would matter.
Read this page of mine, it might explain it better, especially the animated PWM diagram.
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Grumpy_Mike:
I hope you are not using it with 5V, The maximum voltage according to that sheet is 2.5V, you should not even be driving it with 3.3V. You should be driving it with 1.8V.

Note under the table of specifications where it says "Internal diode specifications only".

The module contains a constant current driver. It is intended to run from 3.3V. It almost certainly will tolerate 5V, but will heat up. The description makes no mention of duty cycle and a 25mW laser probably can run continuously with reasonable heatsinking or at least good air circulation around the casing.

In fact, at a 50% duty cycle, it almost certainly can run continuously, probably even on a 5V supply since the dissipation in the constant-current circuit will be reduced as well.

There are however, two other problems.

The most obvious is the specified current - 35 mA typical, 60 mA maximum. This is beyond the (safe) specification of the Arduino - whichever it is, so you need to use a transistor to drive it. Just about any general purpose NPN transistor will do. You could use a base resistor of about 1k from the Arduino port. Put two silicon diodes in series with the laser module and you have reduced 5V to 3.7V and allowing some loss in the transistor, that should be just about right.

The second is a bit more subtle. Not knowing what capacitors (or if any) are in the current driver, you do not know whether it is designed for pulsed operation at a given frequency. If its response it slowed by capacitors, it may either not turn on, or may overdrive the laser diode.

And you have not actually explained whether your test circuit has actually been working in the first place? What you have been doing may or may not be damaging, depending on the variation in the above factors. It would be useful to measure the current draw either continuously (from a 3.5V supply) or for comparison, when you are PWM-ing it, but a cheap multimeter will not indicate this on the 200mA range while the 10A range gives poor resolution (10 mA - at 3 digits).

Note that the actual current is set by the diode itself controlling the "ACC" circuit.

Oh yes! I just noted ...

This laser module is completely self contained and useful for sensor, biomedical and laser radar / laser radar jamming systems

This latter claim would imply that the module is OK to be (pulse) modulated. OTOH that may just be marketing! Also note that the casing is the positive terminal.