Infrared

Chris,
That’s true, I thought about that after posted, but i didn’t want repost another one as it may make other people feel I am annoying, so it is ok. Thanks!

How did you read your tv’s signal? With oscilloscope?

Digging up an older thread. Anyone have any success sending an IR signal using a panda board? The basic setup I have been trying to use is driving a transistor with a PWM at 50% duty cycle to get the carrier frequency and using a digital pin with outputcompare on the collector to provide the wave form for the ir signal. Using a soundcard oscilliscope I was able to independently verify the pure pwm (using 5-20kHz for testing) and the outputcompare timings. The soundcard oscilliscope doesn’t provide a high enough sampling rate to get a good view of the exact signal seen by the ir emitter so not sure exactly what I’m getting, but I was able to count the number of pulses provided by the output compare and the proper number are there, but the timings are a little off. It may be the carrier frequency is fine, but the wave form for the ir signal is not accurate enough. I hooked up the ir emitter to a Global Cache GC-IRL, but it wasn’t able to detect a valid ir signal. Anyone have any insight into sending IR using a fez board?

Bob, what you are doing is perfectly valid and should just work. Remotes are usually 38Khz so why are you using 5-20Khz?

Bu the way, you may want to keep en eye out to next firmware release, we have something you will love seeing that is directly related to what you want to do :slight_smile: Should be out in days now…

The soundcard oscilloscope I was using has a working range up to 20kHz so I was just verifying that the PWM was accurate in that range and assuming if it were then the higher frequency should be accurate as well. For generating the signal I was trying to learn with the GC-IRL I was using 38 kHz for the carrier frequency. I will wait with bated breath for the new firmware release.

In the GHI NETMF API docs for output compare the remarks section has the following line “Also, there is a limit in how much time the pin can toggle. Values are platform dependent.”

Is this saying there is a limit on the size of the array of timings or is it a limit on the magnitude of any individual timing? What is the limit for the Panda board?

A limit on the timings magnitude. You cannot toggle extremely fast… I think limit is around 10 us.

Thanks for the clarification. I believe I found the issue with not being able to generate a reliabe ir signal. The initial testing I did with the outputcompare I was using a constant length for the pulses/spaces. The image below shows a sample of the signal where the series is pulsed high/low using 500,500,500,1500. The timings on the short duration pulses are too far off (620us for 500us high and 330us for 500us low). The majority of code sets would not be able to be used with this amount of error. If the shortest duration in the signal were on the order of 1500us it may work.

FWIW, I was able to create 500us high/low pulses followed by a 1500us low, using OutputCompare on a Panda. Not sure where your variation is coming from.

Well son of a gun. What does your signal path look like? Or are you just hooking into ground and the pin you are generating the output compare on? And testing that real quick I do get the proper wave form. So it has something to do with the ciruit. The outputcompare path that generated that plot is running through an ir emitter, 10 ohm resistor, and a transistor that is running wide open. Guess I need to do a little investigating.

I hooked a 'scope probe directly to the output with the pin not loaded.

In your case, if I understand correctly, you’re sourcing more than 25mA – not sure if that’s more than the uProc can handle. I’d try maybe 30 ohm R to debug.

25mA on FEZ pins? You can’t do that, 5mA is what is recommended. You can use a buffer or transistor for higher loads.

Assuming (again) I understand the circuit correctly, and using Gus’s 5mA number, I’d try a 500 ohm’r.

My bad. Guess I need to look at at the specs a little closer. Doesn’t solve the characteristic of the circuit causing the altered wave form though. Still working on that.

sorry, did you try the 500ohm R?

did I read earlier that you are using a sound card-based 'scope? Any chance this is this issue – you’re really getting good signals but the scope has reporting issues? ANy chance the scope is loading the board?

I used a 680ohm resistor to reduce the current to just below 5ma (can’t seem to find electrical specs for fez board anywhere…just a mention of pin outputs being “weak”). It isn’t the soundcard scope. Bringing the emitter into the circuit is when the waveform gets mucked up.

Just an update. Determined the outputcompare isn’t able to drive the led so I added another transistor to sum the OC signal onto the carrier frequency and used the 5V off the board as the power for the LED and I am able to get a useable ir signal. Tested on a TV for volume up/down and works great. This is part of a larger project, but at some point I will likely put together a succint demo for transmitting ir over a single channel.

Bob, glad you were able to get it running. Now you’ll post your code and schematic, right? :slight_smile:

Gus, how much current can an output pin sink? Would something like the picture below work, assuming an appropriately sized resistor was used?

Pins can handle 15ma but 5ma is what we recommend.

Hi,

I suppose that this thread is proper for my needs - but tell me if I should create new one.

I am trying to use infrared sender & receiver library from http://code.tinyclr.com/project/267/infrared-sender-and-receiver/
In order to do some device @ FEZ Mini, but first I wanted to copy&paste the code and the example just to see how it works. The problem is, that something is not ok, because after saving a button code from air-condidioner remote controller, every attempt to control the conditioner with my device was unsuccessful. I made several changes in code to better know what are the differences. So here is the changed OnDataReceived():

private static void OnDataReceived(object sender, uint[] pulseWidths, int pulseCount)
{
    // return if one pulse has been already saved
    //if (_savedPulseCount != 0)
    //    return;
    if (_savedPulseCount == pulseCount)
        Debug.Print("Pulse counts are equal");
    if (_savedPulseCount > 0)
    {
        for (int i = 0; i < 16; i++) //just to show some widths
            Debug.Print("Saved pulse width: "+_savedPulse[i]+"\tReceived pulse width: "+pulseWidths[i]);
        MeasureMeanDifference(_savedPulse, pulseWidths, pulseCount);
    }
    else
    {
        _savedPulse = pulseWidths;
        _savedPulseCount = pulseCount;
    }

    Blink(3);
}

private static void MeasureMeanDifference(uint[] savedPulse, uint[] pulseWidths, int pulseCount)
{
    int diffSum = 0;
    for (int i = 0; i < pulseCount; i++)
    {
        var diff = (int)savedPulse[i] - (int)pulseWidths[i];
        if (diff < 0)
            diff = -diff;
        diffSum += diff;
    }
    Debug.Print("Total difference is " + diffSum + "us");
    Debug.Print("Mean difference is " + (double)diffSum/pulseCount + "us");
}

And here are the results for TV remote controller Grundig TP720. I used it instead of air-conditioner one because sometimes the beam reaches the device and changing it’s state for several times might be annoying for someone else in the room ;).

Attempts with still pressing a button on the remote control:

[quote]Saved pulse width: 546 Received pulse width: 544
Saved pulse width: 2624 Received pulse width: 2626
Saved pulse width: 537 Received pulse width: 538
Saved pulse width: 510 Received pulse width: 510
Saved pulse width: 491 Received pulse width: 492
Saved pulse width: 574 Received pulse width: 572
Saved pulse width: 499 Received pulse width: 492
Saved pulse width: 557 Received pulse width: 557
Saved pulse width: 496 Received pulse width: 496
Saved pulse width: 560 Received pulse width: 560
Saved pulse width: 493 Received pulse width: 493
Saved pulse width: 563 Received pulse width: 563
Saved pulse width: 500 Received pulse width: 500
Saved pulse width: 556 Received pulse width: 556
Saved pulse width: 497 Received pulse width: 497
Saved pulse width: 559 Received pulse width: 559
Total difference is 17us
Mean difference is 0.80952380952380953us

Total difference is 60us
Mean difference is 2.8571428571428572us

Total difference is 112us
Mean difference is 5.333333333333333us

Total difference is 26us
Mean difference is 1.2380952380952381us

Total difference is 91us
Mean difference is 4.333333333333333us[/quote]

Now I was using the FEZ Mini to generate signal:

[quote]Pulse counts are equal
Saved pulse width: 551 Received pulse width: 570
Saved pulse width: 2618 Received pulse width: 2616
Saved pulse width: 551 Received pulse width: 576
Saved pulse width: 505 Received pulse width: 477
Saved pulse width: 496 Received pulse width: 524
Saved pulse width: 560 Received pulse width: 528
Saved pulse width: 493 Received pulse width: 515
Saved pulse width: 563 Received pulse width: 564
Saved pulse width: 501 Received pulse width: 520
Saved pulse width: 555 Received pulse width: 532
Saved pulse width: 498 Received pulse width: 521
Saved pulse width: 558 Received pulse width: 531
Saved pulse width: 496 Received pulse width: 522
Saved pulse width: 561 Received pulse width: 557
Saved pulse width: 493 Received pulse width: 517
Saved pulse width: 589 Received pulse width: 562
Total difference is 1555us
Mean difference is 23.923076923076923us

Total difference is 1532us
Mean difference is 23.569230769230771us

Total difference is 1370us
Mean difference is 21.076923076923077us

Total difference is 1524us
Mean difference is 23.446153846153845us

Total difference is 1453us
Mean difference is 22.353846153846153us[/quote]

I am using the same IR diode and receiver module (TSOP312) as the author of the library.

Does anyone know (maybe someone had the same issue with this library) what is the possible reason?

Regards,
Tomasz