Author Topic: [Solved] Issues with IR range from Arduino circuit  (Read 5337 times)

0 Members and 2 Guests are viewing this topic.

Offline synopticaTopic starter

  • Contributor
  • Posts: 41
  • Country: au
[Solved] Issues with IR range from Arduino circuit
« on: February 14, 2017, 12:32:30 am »
Hi all,

I'm having a bit of trouble getting more than about a foot of range from an IR transmitter circuit I've built from an Arduino.

I've tried a few variations of the circuit and code as follows:

1) LED powered directly from ATmega pin, with various resistors from 47 - 220 ohm.
2) LED powered directly from 5V (as I suspect the current draw of the IR diode is greater than the ATmega can supply), switched by a BC548.  Tried both 470 and 1k resistors on the base of the transistor, and a 47 ohm before LED.  Have tried the resistor/LED both before the collector and after the emitter (I'm not sure if there's any particular preference either way?)

Nothing I've done has been able to increase the range beyond a foot or so.  I've got one of those standby powerboards that switches 240V when it detects any IR, which also flashes to indicate the presence of an IR signal. I've used this to eliminate the signal timing as a potential issue (I've been testing with both this device and a Panasonic TV.)

I've tried two different IR LEDs with no change in result (https://www.jaycar.com.au/arduino-compatible-infrared-transmitter-module/p/XC4426 and https://www.jaycar.com.au/5mm-infrared-transmitting-led/p/ZD1945).

Is there anything obvious I'm missing?  Any advice appreciated!

« Last Edit: February 18, 2017, 01:56:18 pm by synoptica »
 

Offline hexreader

  • Frequent Contributor
  • **
  • Posts: 269
  • Country: england
Re: Issues with IR range from Arduino circuit
« Reply #1 on: February 14, 2017, 01:01:31 am »
For 5V circuit I use TIP31C with 390 Ohms on the base and 12 Ohms 0.25 Watt resistor in series with IR LED.

I then parallel a second 12 Ohm resistor in series with second IR LED.

Gives reasonable range, though still not as good as commercial remote controls :(

I limit duty cycle to 1/3 or 1/4 to give better battery life (and to keep IR LEDs below spec for maximum average current)

Remember that LED has a voltage drop, so 47 Ohms gives less than the safe 100mA continuous that a typical IR LED might be specced for.

Choose an IR LED than can handle 1A burst current (but maybe limit current to 500mA to give long life) and be sure that average current specification is not exceeded.
« Last Edit: February 14, 2017, 01:08:09 am by hexreader »
 

Online sleemanj

  • Super Contributor
  • ***
  • Posts: 3048
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Issues with IR range from Arduino circuit
« Reply #2 on: February 14, 2017, 02:08:55 am »
By my rough estimates I think you are running the LED at about 60mA in the best case, maybe 70.

You could increase that quite  bit (for pulse currents)

The 548 though is only rated up to 100mA, so you might want to look at changing that. 
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline synopticaTopic starter

  • Contributor
  • Posts: 41
  • Country: au
Re: Issues with IR range from Arduino circuit
« Reply #3 on: February 14, 2017, 05:37:50 am »
For 5V circuit I use TIP31C with 390 Ohms on the base and 12 Ohms 0.25 Watt resistor in series with IR LED.

I then parallel a second 12 Ohm resistor in series with second IR LED.

Gives reasonable range, though still not as good as commercial remote controls :(

I limit duty cycle to 1/3 or 1/4 to give better battery life (and to keep IR LEDs below spec for maximum average current)

Remember that LED has a voltage drop, so 47 Ohms gives less than the safe 100mA continuous that a typical IR LED might be specced for.

Choose an IR LED than can handle 1A burst current (but maybe limit current to 500mA to give long life) and be sure that average current specification is not exceeded.

Thanks mate, I thought I was being a bit risky with the 47 Ohm, but I'll see how high I can take it.

I don't see why a commercial IR control should be any better; I've got cheap Chinese rubbish here that gives more range than I need for this project!

By my rough estimates I think you are running the LED at about 60mA in the best case, maybe 70.

You could increase that quite  bit (for pulse currents)

The 548 though is only rated up to 100mA, so you might want to look at changing that. 


Yeah - I don't think I calculated for drop across the diode itself, actually.

Sorry - I lied about the transistor; I tried both a BC548 and BC338 which is rated at 800mA - I'll do the remainder of my testing on the 338!
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13142
Re: Issues with IR range from Arduino circuit
« Reply #4 on: February 14, 2017, 06:58:30 am »
I *ASS*U*ME* you have done enough research and are modulating the IR with a carrier frequency compatible with the Panasonic TV's IR receiver module.

You are using crappy LEDs without proper datasheets.  The ZD1945 product page  claims it has a max pulse If rating of 1.2A, but that isn't a whole lot of help if you don't know the pulse duration or the duty cycle.  One could *ASS*U*ME* that the duty cycle is simply 50mA/1.2A, or fractionally over 4% but as Joule heating is proportional to I2R, we already know that the simple ratio isn't trustworthy with such a large difference between the peak and continuous currents.  Jaycar are very much the bottom-feeders of the retail component business, and the actual specs of their IR LEDs probably vary depending on which manufacturer's rejects they are buying cheap this month.

For comparison, take a look at the data available of a named brand IR LED from a reputable distributor, e.g. Vishay TSAL6200.  Not only is it rated for double the continuous current, but they provide the manufacturer's datasheet which includes graphs for radiant (optical) power vs current, and pulse current vs duration for various duty cycles.  That gives you the data you need to push it hard without burning it out.

To get good performance you need to drive the switching transistor HARD to make sure its fully saturated. Typically one would use a forced Beta of 10. i.e. Ic/Ib=10, to provide sufficient excess base drive to minimise the Vce_sat drop.   However an Arduino can only provide an abs. max of 40mA drive and you run into problems with voltage drop when you go much over 20mA, so you'll probably have problems pulsing the LED with more than a couple of hundred mA.   Frankly, it would make more sense to use a small MOSFET, - something good for a couple of Amps, with a gate threshold voltage under 2V, low Rds_on, and low enough gate charge and gate-drain capacitance that you can meet your desired switching time requirements with only 25mA gate drive.
 

Offline synopticaTopic starter

  • Contributor
  • Posts: 41
  • Country: au
Re: Issues with IR range from Arduino circuit
« Reply #5 on: February 14, 2017, 11:14:32 am »
I *ASS*U*ME* you have done enough research and are modulating the IR with a carrier frequency compatible with the Panasonic TV's IR receiver module.

You are using crappy LEDs without proper datasheets.  The ZD1945 product page  claims it has a max pulse If rating of 1.2A, but that isn't a whole lot of help if you don't know the pulse duration or the duty cycle.  One could *ASS*U*ME* that the duty cycle is simply 50mA/1.2A, or fractionally over 4% but as Joule heating is proportional to I2R, we already know that the simple ratio isn't trustworthy with such a large difference between the peak and continuous currents.  Jaycar are very much the bottom-feeders of the retail component business, and the actual specs of their IR LEDs probably vary depending on which manufacturer's rejects they are buying cheap this month.

For comparison, take a look at the data available of a named brand IR LED from a reputable distributor, e.g. Vishay TSAL6200.  Not only is it rated for double the continuous current, but they provide the manufacturer's datasheet which includes graphs for radiant (optical) power vs current, and pulse current vs duration for various duty cycles.  That gives you the data you need to push it hard without burning it out.

To get good performance you need to drive the switching transistor HARD to make sure its fully saturated. Typically one would use a forced Beta of 10. i.e. Ic/Ib=10, to provide sufficient excess base drive to minimise the Vce_sat drop.   However an Arduino can only provide an abs. max of 40mA drive and you run into problems with voltage drop when you go much over 20mA, so you'll probably have problems pulsing the LED with more than a couple of hundred mA.   Frankly, it would make more sense to use a small MOSFET, - something good for a couple of Amps, with a gate threshold voltage under 2V, low Rds_on, and low enough gate charge and gate-drain capacitance that you can meet your desired switching time requirements with only 25mA gate drive.

Modulation: I'm honestly not sure if I've done it right; but research indicates that most systems are 38kHz.  As such I did base my timings around a 26 microsecond interval with all on/off pulses being a multiple of this (not true modulation I know, but hopefully a close enough impersonation of?).  However, I've looked at other code and I can't see any evidence of this being done; most just have fixed length on/off with fixed-length microsecond delays in between. I've also tried with IRLib2, which while it makes no mention of modulation, is a popular library and I assume is implemented correctly  :-//

Crappy LEDs: Without doubt; but I've compared the performance of this circuit to ones coming with some of my cheapest Chinese crap which I assume uses LEDs of no better quality, which perform as well as any of the 'good' remotes I've got.

Switching transistor: I did choose my resistor according to Ic/Ib = 10 after finding another forum thread with the same formula.  The BC338 (according to the sheet) can switch 800mA (still less, but closer than the 548!).  I've got a crappy CR2032-powered camera IR remote here that's about 6mm thick - would something like this be employing a MOSFET?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13142
Re: Issues with IR range from Arduino circuit
« Reply #6 on: February 14, 2017, 11:58:58 am »
The crappy remote could use a MOSFET, or maybe a Darlington or maybe a superBeta transistor, but its more likely that the custom control chip (probably with a mask programmed MCU core) is optimised to have one or two pins with much higher drive capability - if it can dump 100mA into the transistor base, then the LED If could easily peak at over an Amp.  As all the other I/Os for scanning the matrix can be rather weak, the die area cost for one super output isn't significant.

If you look at the graphs in the TSAL6200 datasheet, its good for something like 500mA with a 10% duty cycle at the pulse rates required for a 38KHz carrier.  Your LED has half the continuous If rating and its crappy so some safety margin is indicated so I'd suggest shooting for 250mA of 38KHz PWM with 10% duty cycle.  Gate the PWM (preferably in software  from the PWM timer interrupt) on a cycle by cycle basis to implement the required modulation for each bit. 

I wouldn't bet on supplied libraries doing *ANYTHING* beyond basic functionality correctly, and often not even that.  The Arduino ecosystem does benefit from the large open source community it has attracted, but the culture of blindly using libraries without reviewing their source would never fly in a professional MCU development environment.   I've paid extra for a source licence for closed source libraries on other platforms just so I could review the code and debug my application in the confidence that I was responsible for the bugs I was suffering.  I've also contributed binary patches back to the authors of closed source library code, when I had found a critical bug, needed it working without delay, and couldn't get source access.    Take a good hard look at the IRLib2 source - print it out, annotate it and figure out what it is actually doing.   

Instead of testing to a TV or powerstrip, set up a range test with a 38KHz IR receiver module, using the test bit pattern specified for the graphs and figures in its datasheet, and displaying the bit error rate on another Arduino + display. When checking changes to the circuit make sure the transmitter LED is still in exactly the same orientation relative to the receiver, so you can get reproducible results.
 

Offline synopticaTopic starter

  • Contributor
  • Posts: 41
  • Country: au
Re: Issues with IR range from Arduino circuit
« Reply #7 on: February 14, 2017, 01:07:50 pm »
Looks like IRLib2 is actually significantly more complex than I first suspected; have a look at the docs: https://github.com/cyborg5/IRLib2/blob/master/IRLib2/manuals/IRLibReference.pdf

Since making a few modifications - swapping back to a 337 (not 338 as earlier thought), putting a smaller resistor on the base of the transistor (47R) and putting a 8.2R resistor behind the LED for ~500mA, I wasn't able to improve my range, but when switching back to IRLib2, range is significantly improved.

So looks like I need to do some work on modulation!

Cheers all for help :)
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13142
Re: Issues with IR range from Arduino circuit
« Reply #8 on: February 14, 2017, 07:38:22 pm »
You may well not be getting the current you expect for base drive due to the limitations of the Arduino I/O pin.  You need 50mA Ib, so stick in that BC548 as an emitter follower directly off the I/0 pin, add a 1K pulldown on its emitter to get a clean turnoff then use a 68R resistor between its emitter and the output transistor base.  That should give you a reliable 50mA base drive.  If you put the 8R2 resistor on the anode side of the LED, you can scope the voltage at its bottom end and calculate the peak LED current to see if its what you expect.  Also, add a 100uF low ESR decoupling cap directly from the top end of the 8R2 resistor (assuming its above the LED) to the emitter of the output transistor to supply the pulse current locally without bouncing the 5V rail around too much.
 

Offline synopticaTopic starter

  • Contributor
  • Posts: 41
  • Country: au
Re: Issues with IR range from Arduino circuit
« Reply #9 on: February 18, 2017, 01:55:59 pm »
Just thought I'd give an update on this as a mate brought over his Rigol tonight and helped me nut this out.

First problem (which I realised a few days ago) was that I wasn't actually modulating the signal; I was simply turning the IR LED on/off for the specified period; the fact that this was working from ~1ft away threw me off a bit!

Second problem was the resolution of the timer I was using to modulate the signal when I implemented it.  Specifying a period of 13.1579 us (half the period of 38kHz) was giving closer to 38.5kHz as Timer1 was rounding down to 13us.  Only once did we get this on the scope that we realised that Timer1 doesn't accept floats!

So instead I've implemented the timers directly using registers - on a 16MHz chip I've used a prescaler of 1 and a compare match register of 210 to give a carrier of just under 38kHz - a screenshot of the Rigol is attached if anyone's interested!

Using this carrier I've been able to successfully use the unit from as far as it needs to be so I'm happy - cheers for everyone's help!

(P.S. While it doesn't seem to be an issue I'd be interested if anyone had any input on the shape of the falling edge; is this just a characteristic of the transistor (BC337) or the ATmega itself?)
« Last Edit: February 18, 2017, 02:01:42 pm by synoptica »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13142
Re: [Solved] Issues with IR range from Arduino circuit
« Reply #10 on: February 18, 2017, 02:29:20 pm »
Post your current schematic.   Where was the waveform measured?  If it was across the LED, you could be seeing the RC time constant of the junction capacitance, with the scope's input resistance,
 

Offline synopticaTopic starter

  • Contributor
  • Posts: 41
  • Country: au
Re: [Solved] Issues with IR range from Arduino circuit
« Reply #11 on: February 19, 2017, 07:50:24 am »
Schematic attached!  I put the 10k resistor in to see if that affected the output at all, but no change.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13142
Re: [Solved] Issues with IR range from Arduino circuit
« Reply #12 on: February 19, 2017, 09:40:44 am »
R3 wont do much except at startup before the pin is configurede as an output.   

I'd expect the waveform at the bottom end of R1 to look a lot squarer than the one at the transistor collector.   Putting 10K across the LED should square up the collector waveform, by providing a discharge path for stored charge in the LED's junction but is *NOT* needed or recommended for the circuit's actual function.

You are overloading the Arduino pin.   A 47R resistor from a 5V logic signal into a transistor base is 90mA.  :scared: ATmega328P based Arduino output pins are only rated for an absolute maximum of 40mA: http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations

Its unwise to go over 2/3 of the abs.max. rating, so keep loads on output pins >180R. ;)
If you need a lower base resistor than that you *MUST* buffer the signal to provide more drive.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf