Author Topic: Requirements for LED on IR shield  (Read 11342 times)

entropicrune

  • Newbie
  • *
  • Posts: 2
Requirements for LED on IR shield
« on: February 10, 2013, 03:29:39 pm »
No info on this at http://digistump.com/wiki/digispark/tutorials/ir.  I don't want to blow up either the Digispark or the the LED.  Also does the flat section on the silkscreen indicate the anode, or the cathode?

bjh

  • Newbie
  • *
  • Posts: 31
Re: Requirements for LED on IR shield
« Reply #1 on: February 10, 2013, 04:30:03 pm »
The flat side marks the cathode, it's connected to ground through the current-limiting resistor.  Putting the right value of resistor there will prevent too much current flowing through either the LED or the digispark. 


Note that the attiny85 can't provide as much current as most IR LEDs can handle, so I'm planning to squeeze in a driver transistor; I'll write it up when I do.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Requirements for LED on IR shield
« Reply #2 on: February 11, 2013, 09:37:01 am »
Flat side cathode


Good all around resistor value 180ohm

entropicrune

  • Newbie
  • *
  • Posts: 2
Re: Requirements for LED on IR shield
« Reply #3 on: March 10, 2013, 11:24:10 am »
Thank you!  I guess I will use 180 ohms unless BJH posts his writeup.

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Requirements for LED on IR shield
« Reply #4 on: March 10, 2013, 12:27:56 pm »
re the transistor.

If you used the relay shield, and inserted the IR led (and a series resistor) in place of the relay coil.
All of what you need is there, with a choice of pin2 or 5 to drive it.

The IR Led should give a spec for the Vf (forward voltage or voltage across the LED at xx current).
The resistor is there to drop the difference between your supply, and Vf.
You use ohms law to work it out :-
R = E/I  or (5v-Vf)/ I  .... (I is in Amps)

ie If the led Vf is 2v at 40mA the appropriate resistor is 5-2 = 3/.04 = 75 Ohms

Many of these IR LEDs are pulsed at higher current in order to gain the range.
The code is usually modulated at 38KHz, so they aren't on very much, and hence can be very high peak currents.

Mark

dougal

  • Sr. Member
  • ****
  • Posts: 289
Re: Requirements for LED on IR shield
« Reply #5 on: March 10, 2013, 01:26:39 pm »
Which pin is the IR LED output connected to by default? I was trying to eyeball it last night, but it was late, and I was too tired to be sure.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Requirements for LED on IR shield
« Reply #6 on: March 10, 2013, 02:00:24 pm »
dougal - P0 by default


The schematics will be up int he next few days - for real this time - I'm finishing up the new webstore right now and every product page has links to all the eagle files.

Mark

  • Full Member
  • ***
  • Posts: 196
Re: Requirements for LED on IR shield
« Reply #7 on: March 10, 2013, 02:30:07 pm »
Erik

Will you also have a pdf version of the schematics.?

mark

microtherion

  • Newbie
  • *
  • Posts: 15
Re: Requirements for LED on IR shield
« Reply #8 on: March 10, 2013, 04:38:44 pm »
I did some experiments with sending IR today, and came to the conclusion that P0 as an output pin is not an ideal match for the core shipping with the Digispark:


  • To send IR codes, you must be able to control both the frequency and the duty cycle of the PWM signal, so you need a top register and an independent compare register.
  • The five PWM signals that meet this condition are OC0B (P1), OC1A (P1), and OC1B (P4), and, with the drawback that this ties up another pin, ~OC1A (P0) and ~OC1B (P3).
  • However, the Arduino-tiny core used for Digispark uses timer 1 for millis() and micros() (There is another core for attiny85, atttiny, that uses timer 0 for this).
  • So to use P0 as an IR signal, you’re tying up P1 and giving up timing functionality.
So the alternatives are to modify the hardware, modify the core software, or lose some functionality. I ended up changing the pin assignment of the IR LED to P1.

dougal

  • Sr. Member
  • ****
  • Posts: 289
Re: Requirements for LED on IR shield
« Reply #9 on: March 10, 2013, 07:07:36 pm »
@microtherion: Can you give us a description of how you rerouted to P1? Perhaps you could add it to the IR Tutorial wiki page?

microtherion

  • Newbie
  • *
  • Posts: 15
Re: Requirements for LED on IR shield
« Reply #10 on: March 10, 2013, 08:17:54 pm »
Well, it was kind of violent  :-\


The trace from the IR LED to P0 is very plainly visible (passing through 2 solder jumpers), so I just cut that one, and then soldered a wire from one of the solder jumpers to P1. I would not necessarily recommend doing this before Erik has a chance to comment on


  • [size=78%]Whether there was a good reason for the P0 assignment that I missed and[/size]
  • [/size][size=78%]Whether there is a cleaner method to reroute to P1. [/size]

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Requirements for LED on IR shield
« Reply #11 on: March 11, 2013, 12:56:39 am »
@Mark - yes PDF and eagle


@microtherion and @dougal - adding an IR LED spot was an 11th addition because we had the room on the board - it was untested and unplanned - P1 certainly makes more sense in retrospect - I thinkt he easiest way to make the mod would be to cut the trace in the solder jumper near P2 and then solder a jumper form that pad to the side of P1's pad. You could also use the MIT high low tech core.

cyborg5

  • Newbie
  • *
  • Posts: 2
Re: Requirements for LED on IR shield
« Reply #12 on: March 28, 2013, 10:43:05 am »
I have to say I was disappointed to learn that the LED output portion of this shield was untested. I realize the board comes shipped without the LED but I think you really ought to put some sort of disclaimer on the product page explaining that you don't have supporting code in the whole mess about P0 versus P1. And I know that the shield had a design flaw I wouldn't have wasted my money on it. I would've purchased a prototype shield and built the thing myself.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Requirements for LED on IR shield
« Reply #13 on: March 28, 2013, 08:18:55 pm »
You guys know you can use the tone and noTone functions built in to Arduino to output ~38khz to any digital pin on the digispark just with tone(1, 38000), right? Why don't people read the docs? This is the second thread in a week I've seen on this forum with people talking about messing up all the timer registers when the solution is as simple as a single tone command! Seriously, just skim the core docs some time. There's a bunch of cool stuff in there!


Code: [Select]

void setup() {
  tone(0, 38000);
}


void loop() {
 
}


results in a 37.7khz square wave on D0 pin.


Code: [Select]

void setup() {
  tone(0, 40000);
}


void loop() {
 
}


results in about 40.1khz. IR receivers aren't too sensitive to exact frequency, so this doesn't matter too much. it will largely be a case of good enough if you enter in 37500, 38000, 40000, or whatever else your IR receiver is rated for.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Requirements for LED on IR shield
« Reply #14 on: March 28, 2013, 10:25:38 pm »
Bluebie - thanks for the reminder of how simple it is to generate that on any pin!


cyborg5 - we sell it as a Infrared Receiver Shield - so the ability to add an IR LED for transmitting is a bonus, I apologize if you felt that was deceptive, but the kit name says it all - when we feel the IR transmitting function works well enough for us to give it our full backing then we'll ship it as a Transceiver kit or will ship a separate transmitter kit.