Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Hardware wiring for IR LED & Detector


  • Please log in to reply
14 replies to this topic

#1 James

James

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 05 November 2010 - 08:19 PM

I have an IR LED & detector pair that was meant for use with another microprocessor (basic stamp, probably 8 bit) that I'd like to use with the Netduino. I do have the previous wiring schematic which was very simple, but I'm not sure how to convert the resistor values & such over to Netduino. What should I look up or compare to figure out how the schematic would translate? TIA!!

#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 05 November 2010 - 08:28 PM

What should I look up or compare to figure out how the schematic would translate?

Could you post the schematic and part numbers? You probably cannot drive IR LED directly from Netduino pin, depending on its current requirement, which can be rather high (100 mA is not uncommon).

#3 James

James

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 05 November 2010 - 08:50 PM

Could you post the schematic and part numbers? You probably cannot drive IR LED directly from Netduino pin, depending on its current requirement, which can be rather high (100 mA is not uncommon).


Here's a link for the schematics:
http://www.bing.com/...files/gif_1.gif

The IR Emitters use a 30kOhm resistor between the output pin and VSS. The IR Detectors use a 220 Ohm resistor.

#4 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 05 November 2010 - 09:34 PM

The IR Emitters use a 30kOhm resistor between the output pin and VSS. The IR Detectors use a 220 Ohm resistor.

Hm, those 30 kΩ resistors are a little bit confusing, as they result in 0.16 mA current (assuming 5V power supply) which is IMHO way too low and they are not even listed in the component list. So I would rather show the adjustment calculation for 220 Ω resistor (bottom left "IR Emitter Left" on the picture): Current I = U/R = (5 - 1.4) [V] / 220 [Ω] = ~16 mA, for Netduino resistor value is R = U/I = (3.3 - 1.4) [V] / 0.015 [A] = ~126 Ω.

The receiver (PNA4601M) can be used as depicted (powered from 5V rail), Netduino inputs are 5V tolerant.

Edit: Fixed the formulas to include IR LED voltage drop (~1.4 V, depending on the LED type).

#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 05 November 2010 - 09:47 PM

I forgot one important thing: The IR receiver requires the signal to be modulated on 38 kHz carrier frequency - this means you have to switch the IR LED on and off very fast (at 38 kHz) for certain amount of time to produce a pulse on the receiver side (see the modulation picture). AFAIK this is not easily achievable in the current firmware implementation.

#6 James

James

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 05 November 2010 - 10:47 PM

I forgot one important thing: The IR receiver requires the signal to be modulated on 38 kHz carrier frequency - this means you have to switch the IR LED on and off very fast (at 38 kHz) for certain amount of time to produce a pulse on the receiver side (see the modulation picture). AFAIK this is not easily achievable in the current firmware implementation.


Thanks CW2 - this is hugely helpful. I'm not super picky about when the IR LEDs are turned on, in fact it may be fine to run them constantly for this project so long as it doesn't kill battery life or burn out the LED (not sure about either of those). Would a separate option be to build a circuit that could modulate the LED at 38kHz constantly? Any thoughts or direction are greatly appreciated and thank you for the previous explanations!

#7 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 06 November 2010 - 09:43 AM

I'm not super picky about when the IR LEDs are turned on, in fact it may be fine to run them constantly for this project so long as it doesn't kill battery life or burn out the LED

In this case, you can use PWM.SetPulse(period, duration) method. The parameters are in microseconds, for 38 kHz and 50% duty cycle period = (1/38000) [s] = 26 [µs] and duration = 26/2 = 13 [µs]. So, if you call SetPulse(26, 13) the IR LED starts blinking at ~38 kHz, SetPulse(0, 0) turns it off. To produce pulses on the receiver side, put a delay between those two calls, i.e. Thread.Sleep(...). If you are interested in details, there is a nice tutorial on PWM.

Note: The article I referenced in the previous post discussed the problem with PWM that required very precise µs-resolution pulses - this is problematic, because there is no µs-delay function - both Thread.Sleep() and timers have millisecond resolution.

#8 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 25 January 2011 - 07:49 PM

CW2,

What do you think of this idea to achieve IR modulation with the current version of the .Net Micro Framework on the netduino?

#1: use SetPulse() to drive an IR LED at the desired frequency, say 38.4kHz.
#2: configure SPI to clock data out at 38.4 kHz as well.
#3: use the SPI MOSI pin to drive a (fast) transistor to ground the IR LED circuit according to the bit stream sent through SPI.Write() (0=ground, 1=don't ground).

I have not tried it yet, but...because the IR LED and SPI run that the same frequency, this hack should work to achieve the desired bit stream modulation.

Thoughts?


Cheers,
-Fabien.

#9 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 25 January 2011 - 08:42 PM

What do you think of this idea to achieve IR modulation with the current version of the .Net Micro Framework on the netduino?

#1: use SetPulse() to drive an IR LED at the desired frequency, say 38.4kHz.
#2: configure SPI to clock data out at 38.4 kHz as well.
#3: use the SPI MOSI pin to drive a (fast) transistor to ground the IR LED circuit according to the bit stream sent trough SPI.Write() (0=ground, 1=don't ground).

IMHO this is a good idea. One question, though: why SPI at 38.4 kHz? The carrier modulation is done by PWM, so you'd need to configure SPI clock according to the desired waveform (i.e. pulse durations). However, the SPI clock rate is based on the microcontroller's Main Clock frequency (48 MHz) divided by a value from 1 to 255, which gives min. speed ~188 kHz (~5 µs), so it may require rather long bit stream to produce millisecond pulses, depending on what exactly you need (?)

ad #3) Yep, with the first transistor needed to provide enough current for the IR LED, there will be in fact a TTL AND gate. Similar result can be achieved for example with a [constant-current] LED driver IC with Enable input wired to MOSI.

#10 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 25 January 2011 - 09:03 PM

One question, though: why SPI at 38.4 kHz?




SPI.Configuration() takes a Clock_RateKHz parameter in kHz, so it seemed perfect for matching the frequency of the IR LED carrier set with SetPulse().


I didn't realize that the max CPU clock divisor for SPI was 255 though. Hmmm...


The idea was to build a TV / Camera remote controller using this method.



#11 Dezorian

Dezorian

    Member

  • Members
  • PipPip
  • 24 posts

Posted 31 January 2011 - 10:05 AM

I'm also very interested in doing signal modulation on 38khz to transmit RS232 data from the UART. So far i've tried it with a 555 timer circuit but without an oscilloscope it's not doable. I'm receiving bytes, but its all rubbish. With a trimmer resistor its not possible to get 38khz without an oscilloscope. I found this IC which would simplify the circuit a lot: Page: http://www.rentron.c...ntrol/TX-IR.htm Datasheet: http://www.rentron.com/Files/TX-IR.pdf but it seems that the website's "View Cart" button is gone so i'm not sure if the site even sells the IC's anymore. I;ve send the webmaster an email so we'll see. Anymore solutions for building a 38khz carrier IR Transmitter would be awesome!

#12 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 10 February 2011 - 06:03 AM

Hi Dezorian, I had to put this research on hold for a bit but I did work out the math to do it. Now, I need the chance to build the circuit to test it. I'm know there are other ICs out there do get this done, but I just love the idea of making it happen with the netduino alone :)

#13 Dezorian

Dezorian

    Member

  • Members
  • PipPip
  • 24 posts

Posted 15 February 2011 - 04:26 PM

I figured it out btw. Not with the SPI or PWN, but with the 555 timer. If anyone is still interested in the solution (schedule etc), i'd be happy to help (just pm me). Right now i have the IR communincation working on COM1 (sending and receiving), and will use it to create the Netduino Laser Game B)

#14 Anshul

Anshul

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts

Posted 11 November 2012 - 08:32 PM

I figured it out btw. Not with the SPI or PWN, but with the 555 timer. If anyone is still interested in the solution (schedule etc), i'd be happy to help (just pm me).

Right now i have the IR communincation working on COM1 (sending and receiving), and will use it to create the Netduino Laser Game B)


I know this post was over a year ago, but if you could tell me how to modulated using the 555 at 38Khz it would help me out. I'm trying to read an IR Sensor that detects at 38Khz and this could be the solution. Thanks

#15 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 12 November 2012 - 06:35 AM

Here are both IR-transmitter and -receiver: http://highfieldtale...m/tag/infrared/ The receiver has been developed a couple of weeks ago, but the transmitter has been used with success by two other users, at least. What do you need else? Cheers
Biggest fault of Netduino? It runs by electricity.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.