tombsage
Posts: 15
Joined: Sun May 12, 2013 8:58 pm

Transistor for IR Transmitter

Fri Apr 11, 2014 1:31 pm

Hi all,

Not sure if this is the right place to post this but here goes.....

I'm working on a home automation project and I'm fairly new to electronics. I want to set up an IR circuit to be able to control a variety of IR devices. I am following this schematic http://alexba.in/blog/2013/03/09/raspbe ... -for-lirc/ but I do not have a P2N2222AG NPN Amplifier Transistor. Due to my ignorance of electronics, i'm not sure if I can use any of the transistors I do have.

The transistors I do have are:

BC337 Transistor: bipolar, NPN; 50V; 800mA; 625mW; TO92
BD139 Transistor: bipolar, NPN; 80V; 1.5A; 12W; TO126
BD140 Transistor: bipolar, PNP; 80V; 1.5A; 12W; TO126
BD127 Transistor: bipolar, NPN; 300V; 0.5A; 17.5W; TO126
BF421 HIGH VOLTAGE 300V/0.5A 830mW TO92
BC557 Transistor: bipolar, PNP; 50V; 100mA; 500mW; TO92
BC327 Transistor: bipolar, PNP; 50V; 800mA; 625mW; TO92
BF493 Transistor: bipolar, PNP; 350V; 500mA; 625mW; TO92
BC517 Transistor: bipolar, Darlington, NPN; 40V; 400mA; 625mW; TO92

Could someone point me in the right direction please.

Thanks in advance,
Tom

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Transistor for IR Transmitter

Fri Apr 11, 2014 1:43 pm

I wouldn't follow that schematic if I were you. Directly connecting the base-emitter junction of a bipolar transistor between a GPIO output pin and ground looks like a fairly foolish thing to be doing in my opinion. I'm happy to be corrected if wrong.
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

User avatar
Douglas6
Posts: 4809
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Transistor for IR Transmitter

Fri Apr 11, 2014 1:47 pm

I hope someone with better knowledge than myself will respond, but I'm suspicious of that schematic. There are no current limiting resistors at all; that may be a little dicey.

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Transistor for IR Transmitter

Fri Apr 11, 2014 1:54 pm

Hi Tom,
tombsage wrote:i'm not sure if I can use any of the transistors I do have.
Circuits like this are not critical in terms of the transistor model.
When you need to replace one, always pick the same type (NPN). Otherwise, you need to modify the circuit.
Another quick advice would be to take a transistor with the max current similar to the original transistor or this current to be a couple of times larger than the circuit requires.

So, my first selection from your list would be the first one (BC337). Then, a second selection would be the last one (BC517).

What I (like the others) miss in the circuit are two resistors - I'd add a base resistor for this transistor (1k or few hundred ohms) and a small resistor in series to two diodes (few tenths of ohms). The resistor values are also not critical - take a look in a drawer what you have there.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

tombsage
Posts: 15
Joined: Sun May 12, 2013 8:58 pm

Re: Transistor for IR Transmitter

Sat Apr 12, 2014 2:23 am

Thanks everyone for your support!

After some further research I did find this blog http://randomtutor.blogspot.co.uk/2013/ ... ry-pi.html which has a schematic with resistors as you all suggested.

Image

Would the resistors impact on the circuits performance and if so what would be the optimal resistors to use? (electronics noob over here! :lol: )

Thanks again for all your help, hopefully one day I can repay the favor.

tombsage
Posts: 15
Joined: Sun May 12, 2013 8:58 pm

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 4:44 pm

OK so I have wired the circuit up using the schematic with the resistors as recommended and am using a BC337. I am using LIRC to control the circuit but I am not having much luck with it.

I have recorded signals from my TV remote using LIRC's irrecord. I send the code using the command

Code: Select all

irsend SEND_ONCE tv KEY_POWER 
No errors are displayed and using my phone's camera, I can see that the IR LED lights up. Still, nothing happens regarding the TV.

I have also tried controlling my Xbox 360 using the config file found here: http://lircconfig.commandir.com/lircd.c ... remote=337 usingg the command

Code: Select all

irsend SEND_ONCE Microsoft_Xbox360 RightArrow
and other commands in the config file.

I have also tried replacing SEND_ONCE to SEND_START/SEND_STOP with no luck.

This is getting very frustrating.

If anyone can help I will be eternally in your debt. :)

/etc/lirc/hardware.conf

Code: Select all

# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD=false

#Don't start irexec, even if a good config file seems to exist.
#START_IREXEC=false

#Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc-rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""

/etc/modules

Code: Select all

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

snd-bcm2835
spi-bcm2708
i2c-bcm2708
i2c-dev
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=22


User avatar
Douglas6
Posts: 4809
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 5:39 pm

Everything there looks right, and this seems to be confirmed by the fact that the irsend command is lighting up the IR LED.

Double-check your /etc/lirc/lircd.conf file, and maybe post it here for a second set of eyes.

The only other thing I can think of is to start with the receiver (TV or XBox) as close as possible to the transmitter, pointing directly at it (that is the top of the IR LED should be pointed at the receiver), and with minimal ambient light. If that works you can start backing it off to see how much range you have.

What size resistor did you end up using in series with the IR LED?

[EDIT: Your last schematic shows you powering the IR with 3.3 volts. I would use the 5 volt rail, but again, I'm no electronics expert]

tombsage
Posts: 15
Joined: Sun May 12, 2013 8:58 pm

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 6:35 pm

Douglas6 wrote:Everything there looks right, and this seems to be confirmed by the fact that the irsend command is lighting up the IR LED.

Double-check your /etc/lirc/lircd.conf file, and maybe post it here for a second set of eyes.

The only other thing I can think of is to start with the receiver (TV or XBox) as close as possible to the transmitter, pointing directly at it (that is the top of the IR LED should be pointed at the receiver), and with minimal ambient light. If that works you can start backing it off to see how much range you have.

What size resistor did you end up using in series with the IR LED?

[EDIT: Your last schematic shows you powering the IR with 3.3 volts. I would use the 5 volt rail, but again, I'm no electronics expert]

I just tried with the 5v rail at a 2mm distance from the receiver. Still no luck. I used a 10k resistor from the GPIO pin and a 240R resistor in series with the IR diode.

Images of circuit
https://www.dropbox.com/s/zya69wx28h373 ... .31.45.jpg
https://www.dropbox.com/s/78pmetrauzhxh ... .31.57.jpg

/etc/lirc/lircd.conf

Code: Select all

# Please make this file available to others
# by sending it to <[email protected]>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Apr 13 16:14:52 2014
#
# contributed by
#
# brand:                       /home/pi/lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  tv
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9022  4473
  one           583  1665
  zero          583   541
  ptrail        583
  repeat       9022  2231
  pre_data_bits   16
  pre_data       0x8B7
  gap          107970
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0xF807
          KEY_VOLUMEUP             0x00FF
          KEY_VOLUMEDOWN           0x20DF
          KEY_CHANNELUP            0x28D7
          KEY_CHANNELDOWN          0xEA15
      end codes

end remote


begin remote
  name            Microsoft_Xbox360
  bits            16
  flags           RC6|CONST_LENGTH
  eps             30
  aeps            100
  header          2676   870
  one             454   429
  zero            454   429
  gap             106291
  pre_data_bits   21
  pre_data        0x37FF0

  begin codes
       OpenClose       0x8BD7
       XboxFancyButton 0x0B9B
       OnOff           0x8BF3
       Stop            0x0BE6
       Pause           0x8BE7
       Rewind          0x0BEA
       FastForward     0x8BEB
       Prev            0x0BE4
       Next            0x8BE5
       Play            0x8BE9
       Display         0x8BB0
       Title           0x0BAE
       DVD_Menu        0x8BDB
       Back            0x0BDC
       Info            0x8BF0
       UpArrow         0x0BE1
       LeftArrow       0x8BDF
       RightArrow      0x0BDE
       DownArrow       0x8BE0
       OK              0x0BDD
       Y               0x8BD9
       X               0x0B97
       A               0x8B99
       B               0x0BDA
       ChUp            0x8BED
       ChDown          0x0BEC

       Start           0x0BF2
       Enter           0x0BF4
       Record          0x8BE8
       Clear           0x0BF5
       1               0x8BFE
       2               0x0BFD
       3               0x8BFC
       4               0x0BFB
       5               0x8BFA
       6               0x0BF9
       7               0x8BF8
       8               0x0BF7
       9               0x8BF6
       100             0x0BE2
       0               0x8BFF
       Reload          0x8BE3

  end codes

end remote


User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 6:57 pm

Hi,
tombsage wrote:Video of IR diode:
It seems that the diode emits some violetish light...
Are you sure that the IR receivers are compatible with generated patterns (= your code) ? There are various IR protocols, few different carrier frequencies also exist...


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

tombsage
Posts: 15
Joined: Sun May 12, 2013 8:58 pm

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 7:08 pm

Hi Ivan,
FLYFISH TECHNOLOGIES wrote:Hi,
tombsage wrote:Video of IR diode:
It seems that the diode emits some violetish light...
Are you sure that the IR receivers are compatible with generated patterns (= your code) ? There are various IR protocols, few different carrier frequencies also exist...


Best wishes, Ivan Zilic.
This is a video of the remote I was initially trying to emulate:
https://www.dropbox.com/s/5456c0p09mjte ... .59.53.mp4

I'm not sure if the receivers are compatible but there is already a set of codes generated for the Xbox 360 by someone which I tested which also failed. I'm guessing the Xbox codes should have worked as they are published on this website:
http://lircconfig.commandir.com/lircd.conf/

ddahms
Posts: 67
Joined: Tue Mar 18, 2014 3:38 pm

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 7:32 pm

I think you have the transistor in backwards. The BC337 has an unusual pinout, C-B-E.

User avatar
Douglas6
Posts: 4809
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 7:46 pm

Two mm huh? Couldn't get it any closer? :)

Those resistor values seem a little high, tho I'm not convinced that's your ultimate problem.
FLYFISH TECHNOLOGIES wrote:I'd add a base resistor for this transistor (1k or few hundred ohms) and a small resistor in series to two diodes (few tenths of ohms).
I think he meant a few tens of ohms, like 10 or 20 ohms (maybe not). That was based on two LEDs, sounds like you have just one.

Ah, I see you're getting some qualified help now :)

[EDIT: Just watched the video, and when I did this some months back, I remember the LED being MUCH brighter on my phone-cam; like a regular bright LED to the eye. So perhaps it is the transistor or resistors]

tombsage
Posts: 15
Joined: Sun May 12, 2013 8:58 pm

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 8:54 pm

OK, I just tried a 1K1 resistor and a 20R resistor with the transistor both ways around. The IR LED is a lot brighter

https://www.dropbox.com/s/h01nyp3vkg3mc ... .42.51.mp4
https://www.dropbox.com/s/2qmgqh6ub3gak ... .43.45.jpg

Even after this it is still not working, I have no idea what else could be wrong. :(

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 9:27 pm

Hi,
Douglas6 wrote:
FLYFISH TECHNOLOGIES wrote:I'd add a base resistor for this transistor (1k or few hundred ohms) and a small resistor in series to two diodes (few tenths of ohms).
I think he meant a few tens of ohms, like 10 or 20 ohms (maybe not).
Ups, yes, lapse... few tens of ohms.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Transistor for IR Transmitter

Mon Apr 14, 2014 9:33 pm

Hi,
tombsage wrote:Even after this it is still not working, I have no idea what else could be wrong. :(
Ok... so we're approaching to a point where (almost) guessing doesn't give results... The solution is to start debugging...
Yes, I'm aware that articles are mostly oriented on how to make things, not how to debug them when something goes wrong.

So, lets start thinking how you can analytically find out where is the problem... Do you have multimeter ? Do you have any technical details about IR requirements of your receivers ? Do you have any other IR transmitter which could prove that your IR receiver(s) work ?


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Transistor for IR Transmitter

Tue Apr 15, 2014 12:30 pm

[/quote]
tombsage wrote: I have recorded signals from my TV remote using LIRC's irrecord.
Do you have the ability to simultaneously transmit and record? that would allow you to analyse (with your LIRC IRrecord) the signal you are generating to see if there is a variation from the desired output.
Doug.
Building Management Systems Engineer.

tombsage
Posts: 15
Joined: Sun May 12, 2013 8:58 pm

Re: Transistor for IR Transmitter

Tue Apr 15, 2014 4:34 pm

Hi all,

Thanks again for all the support, it's much appreciated.

Ivan -
I do have a multimeter. What tests do you suggest?
I am testing on an Xbox 360 elite and a TV which is a Logik (unknown model). The TV remote works and the xbox IR remote works so both IR receivers are working.

Doug -
I do have 2 Raspberry Pis so I will your suggested test shortly. (I believe you cant send and receive IR signals simultaneously using LIRC, correct me if I'm wrong).

kind regards,
Tom

tombsage
Posts: 15
Joined: Sun May 12, 2013 8:58 pm

Re: Transistor for IR Transmitter

Tue Apr 15, 2014 5:43 pm

OK so I set up a second raspberry pi with the receiver, the codes are being sent but for some reason the Xbox and the TV are not picking them up.

Image of IR codes working from Pi to Pi
https://www.dropbox.com/s/jpe84jagtrmhcgy/Capture.PNG

So that rules out the possibility of the circuit not working. I'm not sure why the Xbox and TV wouldn't pick up the signals. Surely using irrecord would capture the correct codes, no?

Any ideas?
I'm stumped.

ddahms
Posts: 67
Joined: Tue Mar 18, 2014 3:38 pm

Re: Transistor for IR Transmitter

Tue Apr 15, 2014 8:09 pm

This is indeed perplexing since it seems to be working. Does the receiving Pi show the same response to a signal sent from the remote as one transmitted from the other Pi? I imagine it does.

What IR led are you using?

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Transistor for IR Transmitter

Tue Apr 15, 2014 9:08 pm

Hi again,

Could you try transmitting the same signal 3 times consecutively with a 400 millisecond delay? That seems to be a default setting on my tablets IR app (touchsquid), I'm not sure why but it seems to work for them. There are other settings to tweak within the app but these should have been picked up by your 2nd RPi IR receiver.
Doug.
Building Management Systems Engineer.

User avatar
Ferdinand
Posts: 236
Joined: Sun Dec 01, 2013 2:24 pm
Location: Leiderdorp, NL

Re: Transistor for IR Transmitter

Thu Apr 17, 2014 1:25 pm

Hi Tom,
Keep the following items in mind:
- The bc337 is a small signal transistor and maybe causes your problems. Maybe the carrier frequency is a little to high (38 kHz) for this type of transistor and will not saturate properly.

-instead of a transistor you may use a logic circuit such as a nand/nor/or/xor gate which can sink/drive ~100 mA. See for more info --> https://iprototype.nl/docs/ir-led-950nm ... asheet.pdf
Try different current settings 25, 50, 75 and 100 mA.

-if you still want to use a transistor then reduce the base resistor
to ~3 kOhm and use a ~1nF speedup capacitor across the base resistor. A switching transistor will improve your setup.
The transistor must handle, in this case, 100 mA. See also counterpart TSO22xx ->
https://iprototype.nl/docs/ir-reciever- ... asheet.pdf

-perhaps the carrier frequency of the led circuit does not match with the carrier frequency of the remote control of your tv set ~38 kHz. See http://lirc.org/html/help.html#faq --> frequency setting

-check the signals on the gpio pin, with PISCOPE or better a real scope (signals on the gpio pin and transistor/ir diode).
-improved transmitter::
http://sourceforge.net/p/lirc/mailman/message/29877403/

-see for troubleshooting:: https://learn.adafruit.com/ir-sensor

Good Luck,
Ferdinand.
Success with your project!
Ferdinand

MystX
Posts: 32
Joined: Fri Sep 30, 2011 7:01 am
Contact: Website

Re: Transistor for IR Transmitter

Sat Apr 26, 2014 1:03 am

Ferdinand wrote: - The bc337 is a small signal transistor and maybe causes your problems.
I've been using the same setup with the same transistor and it works perfectly with my TV and AV receiver, but not my Xbox360. I think 38kHz is not too high for a BJT.
Ferdinand wrote: -perhaps the carrier frequency of the led circuit does not match with the carrier frequency of the remote control of your tv set ~38 kHz. See http://lirc.org/html/help.html#faq --> frequency setting
I've heard that the 360 at least uses a different carrier. Some say 36kHz, some say 56kHz. I've tried setting LIRC to use both, and tried different remote configs, but no dice.

Sorry to highjack the thread, but I think we might have the same problem since we are using the same setup. Perhaps my TV and AVR work due to luck, or they are very forgiving?

MystX

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Transistor for IR Transmitter

Sat Apr 26, 2014 1:53 am

Hi,
MystX wrote:Perhaps my TV and AVR work due to luck, or they are very forgiving?
IR receiver is optimized for the selected carrier frequency, where maximum range can be achieved due to best sensitivity.
Each receiver has also rejecting characteristics - how "rigorous" is to signals with a frequency deviations away from the carrier frequency. You might name this as a "forgiving property".

The bottom line is that many receivers exist, so one can only guess about expected/proper behavior without detailed information of the receiver type present in equipment under scope.


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

GeofP
Posts: 28
Joined: Fri Jan 31, 2014 9:59 am
Location: NE Hampshire UK

Re: Transistor for IR Transmitter

Thu May 01, 2014 6:45 am

Have you seen these 2 posts?

http://www.raspberrypi.org/forums/viewt ... 28&t=62063
https://github.com/raspberrypi/linux/issues/525

They explain a problem with the timing for lircd which was fixed as of Monday this week.

Perform a sudo rpi-update to load the corrected version of lircd.
A software version equal or later then the following will produce the correct timing for lircd commands.
3.12.18+ #677 PREEMPT Mon Apr 28 22:45:00 BST 2014.

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