I tested the PWM with a green laser using a 2N2222 transistor between it and the microcontroller. At 1 kHz, the laser did not turn on, but it did at higher frequencies. When I tested it at 10 kHz, it worked, so I guess my theory that frequency wouldn't make a difference was wrong. I wonder if a MOSFET would behave differently—I'll give it a try.
Green Laser:
- The power supply to the laser is set at 6V with a maximum of 400mA.
- The laser draws 350mA at 100% duty cycle.
- The laser barely turns on at an ARR value of 13, but it steadily turns on with a dim beam at an ARR of 15 (or 15% duty cycle). I still need to determine the minimum value required to turn it on and then offset all future PWM signals accordingly.
For further testing, I need an easier way to control the PWM signal. Right now, I'm re-uploading the program repeatedly with different values. I think using a potentiometer to map to the ARR value might work.
P.S.: Although this laser is common and weak, I still feel my eyes straining when working near it. It seems that 6V at 350mA equals 2W, which is not exactly common. Never mind—I found some glasses and will wear them from now on. Haha!
A Question: Can I set the CCR to a value between 0 and 100 to correspond to the duty cycle?
No, the CCR can be set from 0 to the value of ARR. In the case of an ARR value of 1000, CCR can range from 0 to 1000. The CCR is used to control the duty cycle, and this value is compared with the ARR value to generate a certain duty cycle DD.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
I don't know what the operating voltage of the laser is, but while 350 mA is within the limits of the 2N2222 collector current, you will also have a large C-E drop of up to 2V according to the datasheet. In addition the gain of the transistor may be lower at higher currents so you need more base current. I'd check with a scope that the transistor is actually driven into saturation, and to account for the voltage loss across the transistor. Maybe a MOSFET is a better switch for your use case.
Are you sure? yes | no
Thanks for pointing it out. i've been meaning to use a MOSFET. will definitely switch to it.
Are you sure? yes | no