Generating a 38KHz carrier wave for IR

Go To Last Post
63 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is more of a generic question then AVR specific, hence the post here.

I want to generate a 38KHz carrier wave to transmit via IR, real basic, but I haven't done this before. After googling and reading up on this, I came up with this basic idea;

 

I have the pin at PB0 switch on/off at 38Khz using a timer and use the pin at PB1 to actually set 1 or 0 depending on what I want to transmit. I use two transistors and a simple IR led, the led will then either be off if the PB1 is at 0, or flash at 38Khz when PB1 is high. I can then switch PB1 to be high or low for a fixed duration.

 

Is this a logical approach to take, or should I do something else?

 

 

 

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use Txd to drive a Pfet , then another port pin ( using out PINx) to generate the 38K and drive an Nfet.

Not sure about your specific circuit, but my Nfet is grounded and the I/R diode and current limit resistor sit between the Pfet and the Nfet...

I use Txd because that's how my system works.....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, but I couldn't understand that. I suspect my limited electronic knowledge is at fault there, I don't know what Pfet and Nfet are. And Wikipedia is to generic on that topic. I am a hobbyist, not a professional, so I might need a bit more then that. In any case, thanks for the answer anyways.

Code, justify, code - Pitr Dubovich

Last Edited: Mon. Jul 20, 2015 - 12:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Eloque,

 

I don't think your specific configuration will work very well. Consider what voltages will be needed to forward bias your two transistors.

 

Cheers,

 

Ross

 

EDIT: Give me a couple of minutes and I will draw something for you.

 

Ross McKenzie ValuSoft Melbourne Australia

Last Edited: Mon. Jul 20, 2015 - 12:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, that's why I asked. I never built anything like this before, so I am happy for any help I can get.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, this should not set fire to your house.

 

 

I do not know how hard you want to drive the IR transmitting diode. But that will determine the values used for the base resistors and the one in the Q1 transistor's collector. I haven't checked the transistor's characteristics either but presume you chose these knowing that they could handle the current. Let me know more if you need some values.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I used an NFET instead of a BJT and just one port pin. It's easy enough to start and stop the timer or enable and disable the output pin for your 1 and 0.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Eloque,

 

Your 2N5089 transistors have an absolute maximum collector current rating of 100 milliamps, whereas the SFH482 can be operated in pulse mode at up to 1000 milliamps, so clearly your transistors are under rated if you hope to operate at greater than 100mA through the IR diode.

 

I agree with Torby... I would use an NFet, but if you want to persist with your BJT idea, let's talk more.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I do like not setting fire to my house. 

 

So what I see is that you added resistors between the MCU and the transistors. Those I understand. Although I would not know what specific value they should have. I just picked up the transistors I had laying around, ON SEMICONDUCTOR  BC547CZL1G  TRANSISTOR, NPN, TO-92, from Farnell. From their datasheet;

 

  • Collector Emitter Voltage V(br)ceo: 45V
  • DC Collector Current: 100mA
  • DC Current Gain hFE: 420
  • MSL: MSL 1 - Unlimited
  • No. of Pins: 3

 

So, it should be able to handle the 5.5 Volt I am using for the IR Led. I think, once again, it's a hobby, has been for years, keep figuring these things out. Also, I just took the IR led from an old remote and checked if I could see it lit up via a phone camera. Not really know what those characteristics are.

 

Also, you placed the Led and the resistor for that before the transistors, is that for a specific reason?

Code, justify, code - Pitr Dubovich

Last Edited: Mon. Jul 20, 2015 - 12:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am open to any and all suggestions, even if I do not know what an NFet is.

 

I do have to point out that I tried to find generic symbols in Eagle Cad, couldn't find them and as such and used the symbols that came close.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N channel Metal Oxide Semiconductor Field effect transistor is similar to an NPN transistor, but doesnt draw any base current, so you dont need series resistors to the gate. (pins are drain, gate, source instead of collector, base emitter)

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah, so that is wat a MOSFET is. Good to know, thanks. 

Also, the base of the design, the two transistors and two pins, that is ok? 

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK then. Considering that it is a hobby project and therefore you probably would like to use the components that you have on hand... let's stay with your BC547C transistors. And I am going to suggest that we only put 50milliamps through your IR diode. BUT... you haven't said what you want to do with the transmitted signal yet... so perhaps before going any further you should tell us.

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can write code to turn the timer on and off and avoid the second transistor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes I know that Russell, but as Eloque has come up with this "basic" idea perhaps he would like to explore it to its conclusion. His choice of course. I have already done the maths for the above design if he wants to "learn" his way. And then he could apply the same approach to the single transistor approach.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, in the end, I want to be able to transmit a simple command string from one AVR to another. A couple of bytes of data. That is my current goal, basically to understand how that works. So, I push a button on one circuit and a circuit a couple of inches away lights up a led. I push another button, another leds lights up or goes down. Once I've accomplished that, I'll start looking at doing more complex things. 

 

The very first basic step is to get an TSOP and an indicator LED working. I already built a circuit that flashes a led when I point a remote at it, now I want to build a circuit to replace that remote.

 

Also, I would very much like to use the components on hand, but since most of those are quite cheap to get anyways, I can always buy others if that makes more sense.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:

Yes I know that Russell, but as Eloque has come up with this "basic" idea perhaps he would like to explore it to its conclusion. His choice of course. I have already done the maths for the above design if he wants to "learn" his way. And then he could apply the same approach to the single transistor approach.

 

 

I understand that I can solve that part in code, but that's more of an improvement step I guess. Thanks for the suggestion however.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, if you have two BC547C transistors, one 62 ohm resistor and two 3.9K resistors, you can do it. Would you like to understand the maths (it is easy) and then you can branch out on your own?

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sure, I like maths. And I think I have those resistors.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK... using the component reference numbers in post # 5 and the datasheet for the BC547C ( http://www.onsemi.com/pub_link/C... ), we start by assuming that the port connected to R3 will provide the gate function. The port connected to R2 will provide the 38KHz. So we start with some parameters as thus...

 

Vcc = +5 volts

Maximum high voltage out of each MCU port is +4.8 volts when providing the current we will use.

Current through the IR diode is 50milliamps (mA)

 

These NPN transistors are controlled by the current flowing into the base terminal. If we push enough current into the base the transistor will switch on hard meaning that the voltage between the collector and emitter terminals will approach zero (but never actually get to it). In this case the datasheet says we can use a value of about 0.2volts for Vcesat (the saturation voltage between the collector and the emitter) when there is a collector to emitter current of about 50mA.

 

The datasheet tells us that the BC547C has a high hFE (dc current gain) of about 300. Because we want to drive the switch hard, we will use a convenient value of 50 (convenient for the maths involved with a IR diode current of 50mA).

 

So starting with Q2, we calculate the value of R3 as (4.8 - 0.7)/50mA/hFE = (4.8 - 0.7)/1mA = 4.1Kohms. The 0.7 volts is the base to emitter diode drop taken from the datasheet. So when R3 is 4.1Kohms, we should have 1mA flowing into the base of Q2 which will result in the Vcesat of about 0.2 volts, when 50mA is flowing through the collector emitter. The power dissipated will be V*I = 0.2 * 0.05 watts or nine tenths of nothing... cool. Because 4.1Kohms is close to 3.9K, you could use that instead with no effective change in performance.

 

Now to calculate the value of R2 we use a similar approach, except that we have to take into account that Q1's emitter is not at ground level. It is sitting 0.2 volts above ground because of Q2's Vcesat. So R2 will be (4.8 - 0.7 - 0.2)/50/hFE = (3.9)/1mA = 3.9Kohms. And because Q1 has the same Vcesat when 50mA is flowing through it, the power dissipated will be the same 02 * 0.05 watts. Cool again.

 

So now we have a total of 0.2 + 0.2 volts = 0.4 volts above ground at the junction of R1 and the collector of Q1. What value must we use for R1? Well we start by looking at  the datsheet for the SFH482 IR diode and estimate it (the voltage across the IR diode) to be about 1.5volts at 50mA. So now R1 = (5 - 1.5 - 0.4)/50mA = 3.1/0.05 ohms  = 62 ohms. How much power is dissipated in R1? Well it can be calculated either by V*I or I*I*R... so lets use the latter = 0.05 * 0.05 * 62 = 0.155 watts. So you could use a 250mW resistor but I would prefer a 500mW one so it does not get even warm.

 

And there it is... (I hope I didn't pitch it too simply, but if I did someone else may benefit from it later).

 

Enjoy.

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

Last Edited: Mon. Jul 20, 2015 - 02:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, that's great. And no, not to simple, simplicity is always good.

 

I will now try to build this thing and see if I can get it to work.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, I'm off to bed now.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I used this circuit for my IR playing , remember that not all receivers are suited for continuous reception of a bitstream

 

https://www.avrfreaks.net/comment...

https://www.avrfreaks.net/sites/d...

 

 

/Bingo

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, I've build a basic, working, board based on the help here. Thanx.

 

The two things that are bothering me now are, I have very, very dim leds in this setup. No real idea why that is. Both the red led I put in test, as the IR led I watch via my camera are lighting up very dim. If I point a remote at my camera that is a very bright led. But the same led, taken from that remote doesn't shine nearly as bright in my setup. I guess that is why the setups only works at about 10 cm distance.

 

Now, I know I shouldn't expect super bright leds here, but I expected a bit more. This is the datasheet, perhaps someone can point to what I am missing. Or, perhaps I am not missing anything and it's just not a bright led. I am going to try and do the math on just the LED, see if I can get it to be bright without the MCU.

 

The other thing is, creating the carrier wave. Right now, it's a dirty hack, 

 

		if (TCNT1 >= 27)
		{
			PORTB ^= 0x01;
		}

With the timer set at a 1 prescalar and 1 Mhz clock speed and 36 Khz, it's not exact, it's of by .7 clockticks. It works, sorta, the detector fires in synch with the transmitter, but only over about 10 cm range max. I've got the feeling that I should implement a PWM of some sort, but still kinda stumped there. I've done Dan's stuff on timers a few times, but feel there should be a way to create an exact 36Khz wave.

Code, justify, code - Pitr Dubovich

Last Edited: Tue. Jul 21, 2015 - 11:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Eloque.

 

In doing the calculations for you, I set the current at 50 mA because of the maximum current for the transistors that you had available. I did not want to destroy them or your house smiley Your remote control unit probably uses a higher current with a "stronger" transistor which will explain the brighter beam.

 

You should check the actual voltages in the circuit to confirm that it is working the way expected. So turn on both transistors continuously (no 38KHz pulse drive) and measure the Vce across both transistors. Remember they should have about 0.2 volts across each. If the Vce is much higher it means that you should lower the 3.9Kohm base resistor values so that the transistor is driven harder. Then measure the voltage across the R1.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you have pins to spare, you don't need a FET in middle.  You can just put several pins to work like a current adder.  This circuit below can pull 30mA on that LED (VF=1.2V):

 

The trick is, use all pins from the same port to keep the code simple, and switch the port pin direction rather than the port state -same as I2C, to prevent pins from shorting each other.

The code for the circuit above would be:

// Init the hardware

DDRD=0;      // All pins as inputs

PORTD=0;     // all pins will sink current when set as outputs

 

// LED control

DDRD=0xFF;      // pins pull current -> LED ON

DDRD=0;           // pins set as inputs (high impedance) -> no current -> LED OFF

 

// 38KHz carrier w/Interrupts

//Timer Interrupt set to 2 x 38KHz = 76KHz

ISR(TIMER1)

{

DDRD^=0xFF;        // Change LED state each half cycle (38KHz, duty 50%)

}

while(!solution) {patience--;}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did an IR transmit (and receive) project on an old AVR. I gengerated the 38KHz by configuring an AVR timer so that it toggled an output pin at 38KHz. A steady 38KHz (carrier) without modulation required 0 CPU time, 0 code.

Now, the CPU can turn the timer on/off at the (approximately) 1KHz bit rate as need be for the modulation of the carrier.

 

Using the CPU or an interrupt at 38KHz is hard, and not necessary.

Last Edited: Wed. Jul 22, 2015 - 04:50 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I am going to try and get further with this, thanks again. some questions,

 

In the various schematics, the Led is placed before the transistor, not after, is there a reason for that?

MOSFETs have been suggested, what should I look for when I order some? I found these http://www.farnell.com/datasheet... at Farnell.

Couldn't I find out the max brightness for the led, by putting it in series with a 6 Volt battery array and a resistor and just look? if it's bright in that setup, it should be able to bright in the MCU setup.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For a cheapy small mosfet -2N7002

Led before the transistor? Probably as an indicator. Especially if the transistor is switching a relay. Show us an example, so we don't have to guess.
Max brightness for led? Refer to the led datasheet.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The RDS on of that Farnell FET is too high at 13 Ohms. A 2N7000/2N7002 is good at <1 Ohm.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The farnell fet was a 800V device!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

For a cheapy small mosfet -2N7002

Led before the transistor? Probably as an indicator. Especially if the transistor is switching a relay. Show us an example, so we don't have to guess.
Max brightness for led? Refer to the led datasheet.

 

Okay, thanks.

The 2N7002 I can only find in packages that are not through hole type, bit unwieldy for experimenting on a breadboard, although soldering on some legs could work?

The datasheet examples I referred to are the ones suggested to me in this thread.

And the max brightness, well, except for the Kingbright leds, I don't have the datasheets and there is not much on the led that gives me information.

 

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Another question, if would want a more powerfull Led, should I look at the mA rating of the Led? Also, I can't find any range of wavelength the TSOP1936 would accept, I suspect it to be around 940nm based on the datasheet, but I could be wrong.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Eloque,

 

Just back from an evening with Chinese friends and their home cooked meal... delicious!

 

When you say putting the led before the transistor I guess you mean placing it in between the NPN transistor's collector and the positive supply rail. In that position we would say we have a low-side switch. An NPN transistor is most suitable as a low side switch because the signal driving the base is then also on the low side. For example if your positive rail was +24 volts and you had a 24 volt relay to actuate, a low side switch could be driven by a low side signal as small as 1 volt providing the required current into the NPN transistor's base. If you tried to do a high side switch using an NPN transistor, the base drive current signal would have to be provided from a signal of 24 + 0.7 volts at a minimum. Obviously we would not use an NPN transistor under that circumstance... a PNP could be used instead in what is called a high side switch configuration. However it would be a complication best avoided. So that is why I used a low side switch combination.

 

As others have suggested, an N type Mosfet could also be used (but you didn't have one so I went with what you already had). The NFet is switched by a voltage on its gate (similar to the transistor's base, but the transistor requires current for control). The NFet would also be best placed on the low side of the led. What characteristics are required? Well like the transistor, the current handling capacity is important. In the case of the transistor we look at the datasheet for the Vcesat versus collector current figures. In the case of the NFet we look at the Rds (equivalent resistance between the drain and the source terminals) and the drain/source current. The lower the Rds figure, generally, the better. But we also need to look at the Vgs figure which tells us what size drive signal we need to start turning on the NFet. For an Atmel MCU driving an NFet, I would look for a Vgs of less than 3 volts. When dealing with currents around 1 ampere, I would try to find an NFet with an Rds at 1 ampere of less than 0.5 ohms and preferably around 0.1 ohms or less. This would then mean that the voltage dropped across the drain/source would be 0.5 volts down to 0.1 volt and the power dissipated in the Nfet would be less than 0.5 watts.

 

Hope that helps.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chinese home cooked food, sounds awesome. 

 

In any case, tx for the pointers, I've been trying to find a MOSFET based on that, I've found this one; http://www.farnell.com/datasheet... in a through hole package. But that doesn't seem right based on what you told me, I also found these; http://www.farnell.com/datasheet... , I think that is more what I need.

 

 

 

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 2N7000 and 2N7002 are the same transistor, (NFet), just in through hole and surface mount packages.

 

 if would want a more powerfull Led

 

Several options:

Pick one with a higher intensity output, per the data sheet.

That won't help much with this project, as it sounds like you want to use what you have available, and don't have a real data sheet for the LED you have.

But, know that if you elect to order some parts, you can select a LED with a high intensity output, which typically will draw more current.

 

You can also "stack" several LEDs in series, with one resistor for the full stack, and one transistor to switch them on an off.

The supply voltage for the LED stack, however, had to be a little bit higher than the sum of the forward voltages of the stacked up LEDs all added up.

For example: If the forward voltage of the LED was 1.5 V, then 6 of them would need 6 x 1.5 = 9 V across them just to turn them on.

A little more voltage would be needed, to account for the voltage drop across the resistor and the transistor.

So, the circuit might have the micro running on 5V, and the LED's running off a 12 V supply, (typical automotive setup...).

 

You could also put several LEDs in parallel, (well, kind of in parallel).

In this case one puts a series resistor in series with EACH LED, and puts the LED & resistor combinations in parallel with each other.

One uses one transistor to turn them all on and off at the same time.

The transistor has to handle the sum of the currents for all of the LEDs.

 

The resistors balance the load, as the LEDs won't actually have the exact same Vforward, in spite of what the catalog says.

 

The image shows this setup with a 2N2222, (NPN) transistor.

These days I'd use the 2N7000 / 2N7002 NFet instead.

 

JC

 

 

Finally, note that the above shows a split power supply, +5V for the uC, +12V for the load, (your LEDs in this case), with a common ground connection.

 

Also know that with LEDs you do not need the reverse biased diode across the load, (your LEDs).

 

Lots of options...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lots of options indeed. Thank you for pointing and drawing them out. I took the advice and ordered in some more parts, the mosfets and the higher intensity leds among them. For those I now do have the datasheet.

 

I'll play around with those to figure it out. Better go back to reading Dan's stuff on timers and try figuring out a 38 or 36 KHz timer. 

 

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, I've gotten quite a bit further with the hardware, I am now turning to the software. The first issue I am running into is creating the carrier wave. I need, for this particular TSOP, a 36Khz wave.

 

Using the calculations from Dean's tutorial;

Target Timer Count = (1 / Target Frequency) / (1 / Timer Clock Frequency) - 1
Target Timer Count = (1 / 36.000 ) / (1 / 1.000.000 ) - 1
Target Timer Count = (1 / 36.000 ) / (1 / 1.000.000 ) - 1
Target Timer Count = 0,00002777... / 0,000001 )  - 1
Target Timer Count = 0,00002777... / 0,000001 )  - 1
Target Timer Count = 26,777...

Since I cannot do half ticks I can either use 26 and be actually at 37.037 Hz or use 27 and be at 35,714 Hz. Now there must be a way of solving this I think. I would not know what that would be however. Perhaps I can switch every pulse, so 26 on the first, then 27 on te second and so on. That would land me on 36.363 Hz on average, still not on the mark. I could perhaps use a 10Mhz crystal and be at 277 ticks per pulse, making it 36.101 Hz. But all that takes me close, but not exactly on the mark. While I feel that should be possible. Perhaps get a crystal that perfectly matches?

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good morning/afternoon Eloque.

 

In your thread title and your first post you say 38KHz... why is it now 36KHz?

 

How did you do the hardware?

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Morning Ross,

 

I did the hardware very carefully. Using the first schematic you send me, the one that wasn't supposed the set fire to my house. It didn't, set fire that is.

 

I used the 4.1K Ohm and 62Ohm resistors. It worked, I could light up the led in such a way my TSOP1736 detected it. That is also the reason it changed from 38 to 36, the TSOP I thought I had was 1738 and I actually had a 1736.

 

After that, I did start playing around with it. Tried to get the Led to burn brighter, ordered a few more powerfull leds and the MOSFETS suggested. Those should be in today. Now I am trying to figure out PWM.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, you could replace the 62 ohm resistor with a 39 ohm resistor... that should produce about 80mA through the IR led.

 

Did you measure the voltages across the transistors? I would be interested to know what values you got.

 

I understand, now, the need for the change from 38KHz to 36KHz... life happens.

 

Time for my bed.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps I can switch every pulse, so 26 on the first, then 27 on te second and so on. That would land me on 36.363 Hz on average

I suspect averaging won't make any difference.

 

The receiver detects the incoming pulses (signal), feeds it through a narrow band pass filter,  and squares up the output signal into nice pulses.

Depending upon the module, these pulses then may or may not be further processed.

 

The sensitivity of the receiver depends upon the photo-detector used, the optical filter placed in front of it, (an a lenses, etc.), and the bandpass filter.

 

Think of the "pass band" for the system as a bell curve, (as a function of the frequency of the incoming signal).

Either your signal hits right at the top of the curve, for best performance, or the signal will be a little off the peak of the curve, for diminished sensitivity.

 

Sending a signal that is a little bit on the left side of the bell curve, followed by sending a signal that is a little bit to the right of the bell curve, might give you a nice "average" that lands right on the dead center of the bell curve. 

But that doesn't matter.

Each one of the transmissions is separately processed, and they are both sub-optimal, as they are not on the center frequency.

 

Averaging them is, therefore, a software hassle and totally meaningless in terms of the overall system performance.

 

It is better to get a data sheet for the receiver module and look at the receiver sensitivity vs frequency curve.

Look at the frequencies you can generate, and decide if one of them is "close enough" to the desired optimal, center, frequency.

 

Another option, perhaps, (others can comment), is to tweak the internal RC Osc frequency off 8 MHz and see if you can come up with a "nice" frequency for data transmission.

I've not run the numbers to see if this is a viable option or not.

Sometimes one tweaks the Internal Osc frequency to tweak a USART baud rate, and this would be similar in concept.

 

JC

 

 

  

Last Edited: Thu. Jul 23, 2015 - 07:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks. I came home, read the datasheet and the MCU is indeed 8Mhz not 1Mhz, unless i clock divide by 8, that could be 36.036Hz, close enough to be within spec of the TSOP. 

I liked the bell curve explanation, makes a lot of sense.

 

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Still working on this. It's proceeding, difficult, but fun. Another few questions you might help me answer;

 

- Some people tell me that TSOP is obsolete, but I can't find why, is this the case?

- I've seen a thing called an IR receiver, that looks just like a led, anyone know those and what they are used for?

 

I've now decided I will try and build the original laser tag system that had me starting this hobby, 7 years ago. Got a bit more budget now and maybe this time it will work out. 

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tsop1736 doesn't seem to list on the Vishay website. It may be obsolete, but there is similar devices from Vishay that would replace it.
The ir receiver is probably a photodiode or phototransistor. The tsop device has a photodiode and electronics to process the signal to reject noise and recover the data. There may be situations where you don't want the electronics or your carrier might be a non- standard frequency.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That is insightful.

 

So, if I want to make a device for range finding, the simpler 2 pin device might do. When wanting to do data transmission, the TSOP device remains the goto device. Perhaps a newer generation of it, but still. Transmitting 12 bits of data is my next goal. Actually, transmitting 2, then 4 bits is.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As for the voltage over the transistor, I measured it. It was 150 mV, changed the resistor to base to 100 ohm and it became 75mV and the led did burn more bright. I removed the resistor completly and got a little more brightness even.

 

I am thinking I am not driving the transistor hard enough. I did get some MOSFETs, http://www.farnell.com/datasheet..., and they seem to have a gate, drain, source setup. That I assume is somewhat like base, emitter collector.

 

 

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 and they seem to have a gate, drain, source setup. That I assume is somewhat like base, emitter collector.

Did you see the schematics in Post #36, above?

 

JC 

 

Edit: Attitude removed...

Last Edited: Mon. Jul 27, 2015 - 08:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well yes, that is why I assumed that gate, drain and source are similar to base, emitter and collector. I built the transistor one and am now trying the MOSFET one.

Code, justify, code - Pitr Dubovich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Eloque,

 

Yesterday I wrote a reply which appears to have disappeared. Maybe I forgot to click "Post". Was a busy day.

 

Anyway what I was attempting to say was that the transistor's base is like the mosfet's gate, the transistor's emitter like the mosfet's source and the transistor's collector like the mosfet's drain. Be careful not to swap the drain and source connections.

 

Also... the transistor is controlled by current flowing through the base/emitter whereas the mosfet is controlled by a voltage on the gate. No current flows through to the source.

 

The 150mVolt value for Vcesat is an excellent value. By driving more current through the base to achieve the 75mV you are putting more load on your AVR's port. Putting a short circuit base "resistor" is the same as causing your AVR to drive one or two diodes (the base emitter acts as a diode junction). The AVR will not "thank you" for this abuse.

 

You can increase the brightness by increasing the current by decreasing the collector resistor R1. But be aware that your BC547 transistors have a 100mA limit... you don't want to kill your transistors.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The very first circuit shown has a problem (or more)...when PB1 is "high" it will light the led regardless of the other transistor on PB0.  It will supply led power via the port pin though the transistor's Vbe diode drop.  So PB0 is partially ignored/overridden.

 

Many of the other ideas presented are much more suitable.

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Pages