Connect with us

Trouble with Infrared Communications (Custom Transmission)

Discussion in 'Microcontrollers, Programming and IoT' started by _Nate_, Apr 15, 2018.

  1. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    I have been trying for a while to get a basic system working in which I can communicate infrared signals from one arduino to another to control it

    However, the only infrared help I've been able to find online regarding transmitters has been to make your own TV remotes. But what I want to do is to use one arduino to send IR messages with an IR transmitter to another arduino with an IR receiver (I would just use if statements for the values of whatever signal is being sent to activate whatever code I so desire).
     
  2. Hopup

    Hopup

    216
    27
    Jul 5, 2015
    What are the models of the transmitter and receiver?
     
  3. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    The receiver I believe is a tsop1838 or looks identical to one and the transmitter is a standard Arduino transmitter
     
  4. Hopup

    Hopup

    216
    27
    Jul 5, 2015
    According to the datasheet your Arduino must transmit signal like this:

    The data signal should fulfill the following condition:

    Carrier frequency should be close to center frequency of the band-pass (e.g. 38kHz).

    Burst length should be 6 cycles/burst or longer.

    After each burst a gap time of at least 9 cycles is necessary.

    The data format should not make a continuous signal transmission. There must be a Signal Gap Time (longer than 15ms) at least each 90ms (see Figure A).

    Site http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html, it has very good information which could possibly help you. In the code for IR led they use sony protocol for sending the signals.
     
  5. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    Ok, what I'm most confused about is this line:

    irsend.sendSony(0xa90, 12); // Sony TV power code

    Since I'm not using a sony receiver, what should this line of code be instead?
     
  6. Hopup

    Hopup

    216
    27
    Jul 5, 2015
    I think you could send the signal using those protocols and then in the other Arduino you just read the code. If you want to use your own protocol you must use send.raw.

    int khz = 38; // 38kHz carrier frequency for the NEC protocol

    unsigned int irSignal[] = {9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; //example raw nec protocol

    irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.

    delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
    }
    void loop() {
     
  7. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    I'm confused again since this is in setup? and there is nothing in the loop?
     
  8. Hopup

    Hopup

    216
    27
    Jul 5, 2015
  9. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    Ok things are looking good. I established a communication! (Whipee) But heres my question: You have the array being sent to the receiver, but what do the numbers mean and why do they show up as "180BD9FF"?
    Edit: Numerical value is 403429887
     
    Last edited: Apr 17, 2018
  10. Hopup

    Hopup

    216
    27
    Jul 5, 2015
    It is the timing in uS.
     
  11. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    So how do I change the message being sent?
     
  12. Hopup

    Hopup

    216
    27
    Jul 5, 2015
    I think the easy way would be to use one of the protocols for the transmission, or you could create one yourself, look at the files in the ir_NEC.cpp for how its done.

    https://www.sbprojects.net/knowledge/ir/nec.php

    Some examples for suitable data format are: NEC Code (repetitive pulse), NEC Code (repetitive
    data), Toshiba Micom Format, Sharp Code, RC5 Code, RECS–80 Code, R–2000 Code.
     
  13. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    Alright I now understand the 0's and 1's in the protocol but clarify something for me: The first two indexes in the array are defining a block of 9000ms and 4500ms, whereas ever two sets of 560 is a 0 and 560 followed by 1690 is a 1? And this binary but what is the default bit size?
     
    Last edited: Apr 17, 2018
  14. Hopup

    Hopup

    216
    27
    Jul 5, 2015
    Yeah, as far as I know that's right. I'm not expert on this subject, just interested about it also, since I have some projects where this can be useful.

    You can just use the (irsend.sendNEC(//hex value here, //bit count here) like in the demo, I cant test it since I don't have any receivers like this available. I think NEC protocol was 8 bit address and 8bit command.
     
  15. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    Alright, so I used a new code for receiving IR values, decoding them, and telling what type of transmitter (sony, nec, etc.)
    So I used my Roku remote and it told me it was NEC, so I used this code:

    irsend.sendNEC(0X57E3E817,128);

    Originally. the numeral after the code was a 32. I assumed that this is so because a 6 digit code can represent 32 different numbers. I also assumed, since the code given to me from the remote was 8 digits, that I needed to change the 32 to a 128. Is this correct?
     
  16. Hopup

    Hopup

    216
    27
    Jul 5, 2015
    No, maximum bit length is 32bits when NEC is used. 16bits for address and 16 for command.

    0x20DF10EF = 0000 0000 0010 0000 1101 1111 0001 0000 1110 1111
    address 0010 0000
    inverted address 1101 1111
    command 0001 0000
    inverted command 1110 1111
     
  17. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    OK, so I have fixed that but the signal that is outputted refuses to work with the TV still. I am using this:

    irsend.sendNEC(0X20DF10EF,32);
    delay(100);

    Edit: WE HAVE CONTACT. Turns out the range is just crap. I heard that using 2 180ohm resistors in parallel works well at increasing range?
     
  18. Hopup

    Hopup

    216
    27
    Jul 5, 2015
    Use your own code what you got from reading the tx not my example, did you try to send it using 32bits?
     
  19. _Nate_

    _Nate_

    99
    0
    Jun 12, 2017
    I want to thank you for all of your help with this. Thanks to you, I have a deeper understanding in IR and have been able to make great use of this knowledge. You rock!
     
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-