Sulring
Posts: 4
Joined: Fri Nov 21, 2014 3:30 pm

5v laser module controlled by a GPIO

Fri Nov 21, 2014 4:30 pm

Hello,

I want to switch the laser module (4.5 - 5 - 5.5v, 25 - 35 -55mA) on and off with a GPIO. Since I'm very bad at electronics, I decided to ask a question before wiring anything and pobably frying something. I plan to use a 2N2222A transistor, the base connected to GPIO via a resistor.
The questions are:
  • Is it okay to use 2N2222A or I should better use something else?
  • If it's okay, which resistor would be adequate?

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6905
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.

Re: 5v laser module controlled by a GPIO

Fri Nov 21, 2014 5:44 pm

Sulring wrote:Hello,
I want to switch the laser module (4.5 - 5 - 5.5v, 25 - 35 -55mA) on and off with a GPIO. Since I'm very bad at electronics, I decided to ask a question before wiring anything and pobably frying something. I plan to use a 2N2222A transistor, the base connected to GPIO via a resistor.
The questions are:
  • Is it okay to use 2N2222A or I should better use something else?
  • If it's okay, which resistor would be adequate?
That transistor appears to have a "good enough" spec. I would use a configuration similar to my "backlight drive" circuit shown (bottom right) here:
http://www.cpmspectrepi.webspace.virgin ... rGLCD.html
but the resistor values depend upon the actual current you wish to pass through the module and the drive voltage (ie. GPIO direct or via a level-shifter). I have an "ancient" basic** program that I've used (and used above) to calculate the resistor values which, FWIW, is elsewhere on my website. Unfortunately, for some reason, the BBC Basic (RiscOS) version "no longer" works so you'll need access to QBasic (on XP?) to make use of it. Of course there is also the question of "how fast" (rise time/frequency) do you need to switch the device...
Trev.
** AECDPP
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) but Buster on the P3B+, P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Sulring
Posts: 4
Joined: Fri Nov 21, 2014 3:30 pm

Re: 5v laser module controlled by a GPIO

Sat Nov 22, 2014 1:41 pm

Thanks for the answer.
Right now I power the laser module directly with 5v pin of my RPI, and I don't plan to change it since I have both space and weight issues. I try to avoid any aditional components.
The circuit.
schemeit-project.png
schemeit-project.png (5.25 KiB) Viewed 6431 times
Did you mean it like this? That was my plan except the R2 resistor. Why do I need it?
As for the speed...as fast as possible :) I'm unsure if it is possible, but I'd like to pulse the laser at 5-10Hz.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6905
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.

Re: 5v laser module controlled by a GPIO

Sat Nov 22, 2014 11:46 pm

Sulring wrote:Thanks for the answer.
Right now I power the laser module directly with 5v pin of my RPI, and I don't plan to change it since I have both space and weight issues. I try to avoid any aditional components.
The circuit.
schemeit-project.png
Did you mean it like this? That was my plan except the R2 resistor. Why do I need it?
As for the speed...as fast as possible :) I'm unsure if it is possible, but I'd like to pulse the laser at 5-10Hz.
Whilst a single resistor is usable, it's more difficult to determine the actual current that will flow through the module because of variations in the gain (hFE) and associated Vbe for a given current for individual transistors. IIRC, there's also a greater risk of "thermal runaway". Again IIRC, turn-off times are usually faster, since R2 is usually smaller than R1. In other words - a more stable design approach. A rep-rate of 5-10Hz is quite "slow" - what's the pulse length, rise and fall times? Is it really a LASER module or do you mean an "ordinary" Light Emitting Diode module (a LASER Diode Module is a very different thing, often requiring much higher pulse currents than you quote)?
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) but Buster on the P3B+, P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Sulring
Posts: 4
Joined: Fri Nov 21, 2014 3:30 pm

Re: 5v laser module controlled by a GPIO

Sun Nov 23, 2014 12:25 am

Pulse length has to be ~40ms and pause between pulses ~40ms.
LASER. It's picotronic.de: LD650-5-5(12x32)-PL
http://www.picotronic.de/picopage/en/pr ... /id/109303

User avatar
joan
Posts: 15997
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 5v laser module controlled by a GPIO

Sun Nov 23, 2014 9:22 am

I have one of these http://www.hobbytronics.co.uk/electroni ... /red-laser

I just power it by connecting it directly to a gpio as it's happy with 3V3. It's said to take 20mA which is slightly out of spec for a gpio. No extra components needed.

Here I am controlling it with software PWM. https://www.youtube.com/watch?v=ZokTYoFpxhE

Nowadays I use hardware timed PWM.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6905
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.

Re: 5v laser module controlled by a GPIO

Sun Nov 23, 2014 9:27 am

Sulring wrote:Pulse length has to be ~40ms and pause between pulses ~40ms.
LASER. It's picotronic.de: LD650-5-5(12x32)-PL
http://www.picotronic.de/picopage/en/pr ... /id/109303
Thanks for the link. However there appears to be no mention of your "pulse length" etc. in the data sheet - it seems to be CW**** device to me**. Is it the case that you need to modulate it with what, in effect, is a 12.5 Hz square-wave for your application?
Trev.
**Having worked with, and designed trigger and control circuits for, various lasers during the first half of my career, for me a "pulsed laser" is one that generates up to several Mega Watts of optical power with pulse lengths in the nano-second or micro-second time-scale (rise-times <1nS --> a few nS) at rep-rates of 10's to a few 100 Hz.
****@joan's post seems to confirm this
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) but Buster on the P3B+, P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: 5v laser module controlled by a GPIO

Mon Nov 24, 2014 7:14 pm

Hi

I'd be interested to hear more of the action of R2.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6905
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.

Re: 5v laser module controlled by a GPIO

Mon Nov 24, 2014 10:16 pm

grahamed wrote:Hi
I'd be interested to hear more of the action of R2.
The basic design philosophy goes back more than 30 years, when most logic design was TTL-based (5V) or CMOS-based (often 12 to 15V). It's also related/derived from base bias techniques for amplifier design. The use of a potential divider circuit gives more stable control of switching thresholds and saturation currents when the transistor is turned on. The programs I wrote then were used to design trigger circuits involving what might be called "extreme level-shifting" - for example a TTL logic output would be used to drive a transistor (normally held "on") controlling the gate of a thyristor which, in turn, discharged a capacitor (at 300V or more) through the primary winding of a transformer which generated a pulse of a few kV to switch a spark-gap which finally discharged another capacitor (or capacitors) at 50 - 100 kV to energise a pulsed CO2 laser.
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) but Buster on the P3B+, P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Sulring
Posts: 4
Joined: Fri Nov 21, 2014 3:30 pm

Re: 5v laser module controlled by a GPIO

Tue Nov 25, 2014 5:05 pm

Thanks for the answers.
I solved it, using 100 for R1, 10k for R2. Works great so far.
FTrevorGowen wrote: Thanks for the link. However there appears to be no mention of your "pulse length" etc. in the data sheet - it seems to be CW**** device to me**.
I've never said it was a pulsed one. It is a CW laser. I'm just switching it on and off by setting GPIO output to 1/0. Pulsing it for image processing.

Return to “Interfacing (DSI, CSI, I2C, etc.)”