Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IR LIBRARY
21-01-2014, 10:08 PM,
#41
RE: IR LIBRARY
(21-01-2014, 04:09 AM)derf158 Wrote: i ran thru the code but no luck yet finding the issue.
fyi the code did compile.

Ok guys, reasoning about problem:
1) My hardware is simply a IR led connected to pin 11 (pinguino 18f2550) by a 100 Ohm resistor;
2) If i attached the led to +5 V and I noticed the IR LED lights up (thanks to my laptop web cam );
3) The IRsend_sendXXX functions are composed of ("trivial") little functions using delay;

I suppose there is a problem on PWM or timer...

I need to investigate!
Reply
21-01-2014, 10:10 PM,
#42
RE: IR LIBRARY
(21-01-2014, 10:08 PM)dkmorb Wrote:
(21-01-2014, 04:09 AM)derf158 Wrote: i ran thru the code but no luck yet finding the issue.
fyi the code did compile.

Ok guys, reasoning about problem:
1) My hardware is simply a IR led connected to pin 11 (pinguino 18f2550) by a 100 Ohm resistor;
2) If i attached the led to +5 V and I noticed the IR LED lights up (thanks to my laptop web cam );
3) The IRsend_sendXXX functions are composed of ("trivial") little functions using delay;

I suppose there is a problem on PWM or timer...

I need to investigate!
i have a ir module hooked to pin 0 on a 18f4550 i have no ir output i am only looking for the input to blink userled .
Reply
21-01-2014, 11:30 PM,
#43
RE: IR LIBRARY
Quote: i have a ir module hooked to pin 0 on a 18f4550 i have no ir output i am only looking for the input to blink userled .

I also have this configuration for receiver led:
Pin1 = Pin 7
Pin2 = Gnd
Pin3 = 5v

and redefined USERLED as
#define USERLED 5

but nothing happened. :-( -> I need a beer...
Reply
22-01-2014, 10:12 PM,
#44
RE: IR LIBRARY
I tried this program simulating the _IRsend_sendNEC_ function code: now the LED flashes but my LG TV doesn't work! I tried many codes (on, off,...). Nothing.

Code:
#define IR_LED 11
#define TOPBIT 0x80000000

#define NEC_HDR_MARK  9000
#define NEC_HDR_SPACE 4500
#define NEC_BIT_MARK  560
#define NEC_ONE_SPACE 1600
#define NEC_ZERO_SPACE  560
#define NEC_RPT_SPACE 2250

void IR_emitterOn(u8 pin, int time)
{
    // infrared LEDs have a typical forward voltage drop of 1.5V
    // We take 3.5V / 430Ω to find our peak current of 8.1mA.
    // If we set our PWM duty-cycle to 20%,
    // we then have an average current of 1.6mA supplied to each LED.
    PWM.setPercentDutyCycle(pin, 50);// duty cycle = 50%
delayMicroseconds(time);
}

void IR_emitterOff(u8 pin, int time)
{
    PWM.setPercentDutyCycle(pin, 0);// duty cycle = 0%
delayMicroseconds(time);
}

void IR_transmission()
{
  unsigned long data;
  int i;
  u8 nbits = 32;
  
  data = 0x20DFB54A;
  
  IR_emitterOn(IR_LED, NEC_HDR_MARK);
  IR_emitterOff(IR_LED, NEC_HDR_SPACE);
  
  for (i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      IR_emitterOn(IR_LED, NEC_BIT_MARK);
      IR_emitterOff(IR_LED, NEC_ONE_SPACE);
    }
    else {
      IR_emitterOn(IR_LED, NEC_BIT_MARK);
      IR_emitterOff(IR_LED, NEC_ZERO_SPACE);
    }
    data <<= 1;
  }
  IR_emitterOn(IR_LED, NEC_BIT_MARK);
  IR_emitterOff(IR_LED, 0);
}

void setup() {
    //run once:
    PWM.setFrequency(38000);                                // Use Timer2 to make a 38 KHz carrier frequency
       OnTimer0(IR_transmission, INT_MILLISEC, 1000);    // Use Timer0 to send burst every 500 us
       //OnChangePin0(IR_reception, INT_FALLING_EDGE);    // Goes to 0 if a carrier is received
    }

void loop() {
    //run repeatedly:

    }
Reply
23-01-2014, 12:09 AM, (This post was last modified: 23-01-2014, 12:14 AM by derf158.)
#45
RE: IR LIBRARY
(22-01-2014, 10:12 PM)dkmorb Wrote: I tried this program simulating the _IRsend_sendNEC_ function code: now the LED flashes but my LG TV doesn't work! I tried many codes (on, off,...). Nothing.

Code:
#define IR_LED 11
#define TOPBIT 0x80000000

#define NEC_HDR_MARK  9000
#define NEC_HDR_SPACE 4500
#define NEC_BIT_MARK  560
#define NEC_ONE_SPACE 1600
#define NEC_ZERO_SPACE  560
#define NEC_RPT_SPACE 2250

void IR_emitterOn(u8 pin, int time)
{
    // infrared LEDs have a typical forward voltage drop of 1.5V
    // We take 3.5V / 430Ω to find our peak current of 8.1mA.
    // If we set our PWM duty-cycle to 20%,
    // we then have an average current of 1.6mA supplied to each LED.
    PWM.setPercentDutyCycle(pin, 50);// duty cycle = 50%
delayMicroseconds(time);
}

void IR_emitterOff(u8 pin, int time)
{
    PWM.setPercentDutyCycle(pin, 0);// duty cycle = 0%
delayMicroseconds(time);
}

void IR_transmission()
{
  unsigned long data;
  int i;
  u8 nbits = 32;
  
  data = 0x20DFB54A;
  
  IR_emitterOn(IR_LED, NEC_HDR_MARK);
  IR_emitterOff(IR_LED, NEC_HDR_SPACE);
  
  for (i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      IR_emitterOn(IR_LED, NEC_BIT_MARK);
      IR_emitterOff(IR_LED, NEC_ONE_SPACE);
    }
    else {
      IR_emitterOn(IR_LED, NEC_BIT_MARK);
      IR_emitterOff(IR_LED, NEC_ZERO_SPACE);
    }
    data <<= 1;
  }
  IR_emitterOn(IR_LED, NEC_BIT_MARK);
  IR_emitterOff(IR_LED, 0);
}

void setup() {
    //run once:
    PWM.setFrequency(38000);                                // Use Timer2 to make a 38 KHz carrier frequency
       OnTimer0(IR_transmission, INT_MILLISEC, 1000);    // Use Timer0 to send burst every 500 us
       //OnChangePin0(IR_reception, INT_FALLING_EDGE);    // Goes to 0 if a carrier is received
    }

void loop() {
    //run repeatedly:

    }
does your original remote still work?

(23-01-2014, 12:09 AM)derf158 Wrote:
(22-01-2014, 10:12 PM)dkmorb Wrote: I tried this program simulating the _IRsend_sendNEC_ function code: now the LED flashes but my LG TV doesn't work! I tried many codes (on, off,...). Nothing.

Code:
#define IR_LED 11
#define TOPBIT 0x80000000

#define NEC_HDR_MARK  9000
#define NEC_HDR_SPACE 4500
#define NEC_BIT_MARK  560
#define NEC_ONE_SPACE 1600
#define NEC_ZERO_SPACE  560
#define NEC_RPT_SPACE 2250

void IR_emitterOn(u8 pin, int time)
{
    // infrared LEDs have a typical forward voltage drop of 1.5V
    // We take 3.5V / 430Ω to find our peak current of 8.1mA.
    // If we set our PWM duty-cycle to 20%,
    // we then have an average current of 1.6mA supplied to each LED.
    PWM.setPercentDutyCycle(pin, 50);// duty cycle = 50%
delayMicroseconds(time);
}

void IR_emitterOff(u8 pin, int time)
{
    PWM.setPercentDutyCycle(pin, 0);// duty cycle = 0%
delayMicroseconds(time);
}

void IR_transmission()
{
  unsigned long data;
  int i;
  u8 nbits = 32;
  
  data = 0x20DFB54A;
  
  IR_emitterOn(IR_LED, NEC_HDR_MARK);
  IR_emitterOff(IR_LED, NEC_HDR_SPACE);
  
  for (i = 0; i < nbits; i++) {
    if (data & TOPBIT) {
      IR_emitterOn(IR_LED, NEC_BIT_MARK);
      IR_emitterOff(IR_LED, NEC_ONE_SPACE);
    }
    else {
      IR_emitterOn(IR_LED, NEC_BIT_MARK);
      IR_emitterOff(IR_LED, NEC_ZERO_SPACE);
    }
    data <<= 1;
  }
  IR_emitterOn(IR_LED, NEC_BIT_MARK);
  IR_emitterOff(IR_LED, 0);
}

void setup() {
    //run once:
    PWM.setFrequency(38000);                                // Use Timer2 to make a 38 KHz carrier frequency
       OnTimer0(IR_transmission, INT_MILLISEC, 1000);    // Use Timer0 to send burst every 500 us
       //OnChangePin0(IR_reception, INT_FALLING_EDGE);    // Goes to 0 if a carrier is received
    }

void loop() {
    //run repeatedly:

    }
does your original remote still work?
at least you are making head way i am still stuck with IR receive not working.
Reply
23-01-2014, 09:53 AM,
#46
RE: IR LIBRARY
(23-01-2014, 12:09 AM)derf158 Wrote: does your original remote still work?
Yes, it works...and I hope will work forever! ;-)

Quote:at least you are making head way i am still stuck with IR receive not working.
I think the problems are related to hardware init!
Reply
23-01-2014, 10:54 AM, (This post was last modified: 23-01-2014, 11:22 AM by regis.)
#47
RE: IR LIBRARY
Are you sure your LG TV use the NEC protocol and data = 0x20DFB54A; means something for your TV ?
How much current do you have for your IR emitter LED ?
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
24-01-2014, 10:10 AM,
#48
RE: IR LIBRARY
(23-01-2014, 10:54 AM)regis Wrote: Are you sure your LG TV use the NEC protocol and data = 0x20DFB54A; means something for your TV ?
Well...I'm not sure at this point! My TV is a LG 22LH2000

Quote:How much current do you have for your IR emitter LED ?
I haven't measured current but with my sample program I see the LED light up at least.
Reply
24-01-2014, 10:27 AM,
#49
RE: IR LIBRARY
The more current, the more range. You can see the led's light but it's maybe not enough for your TV's receiver. Remember that a PIC pin can deliver 20-25mA max.
Take a look at http://www.circuitvalley.com/2013/09/nec...ntrol.html
Maybe a good start to test your TV and the IRremote library.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
24-01-2014, 11:52 AM,
#50
RE: IR LIBRARY
(24-01-2014, 10:27 AM)regis Wrote: The more current, the more range. You can see the led's light but it's maybe not enough for your TV's receiver. Remember that a PIC pin can deliver 20-25mA max.
Take a look at http://www.circuitvalley.com/2013/09/nec...ntrol.html
Maybe a good start to test your TV and the IRremote library.

Yes Regis, you're correct! I think the same thing.
But if I use IRemote library you posted, led it's not blinking! ;-) (over the LG error code...)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)