Trouble with Infrared Communications (Custom Transmission)

Discussion in 'Microcontrollers, Programming and IoT' started by _Nate_, Apr 15, 2018 at 11:36 PM.

  1. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    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).
     
    _Nate_, Apr 15, 2018 at 11:36 PM
    #1
    1. Advertisements

  2. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    What are the models of the transmitter and receiver?
     
    Hopup, Apr 15, 2018 at 11:51 PM
    #2
    1. Advertisements

  3. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    The receiver I believe is a tsop1838 or looks identical to one and the transmitter is a standard Arduino transmitter
     
    _Nate_, Apr 16, 2018 at 12:00 AM
    #3
  4. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    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.
     
    Hopup, Apr 16, 2018 at 12:21 AM
    #4
  5. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    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?
     
    _Nate_, Apr 16, 2018 at 4:17 AM
    #5
  6. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    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() {
     
    Hopup, Apr 16, 2018 at 2:06 PM
    #6
  7. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    I'm confused again since this is in setup? and there is nothing in the loop?
     
    _Nate_, Apr 16, 2018 at 10:07 PM
    #7
  8. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    Hopup, Apr 16, 2018 at 11:44 PM
    #8
  9. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    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 at 1:04 AM
    _Nate_, Apr 17, 2018 at 12:48 AM
    #9
  10. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    It is the timing in uS.
     
    Hopup, Apr 17, 2018 at 1:22 AM
    #10
  11. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    So how do I change the message being sent?
     
    _Nate_, Apr 17, 2018 at 1:27 AM
    #11
  12. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    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.
     
    Hopup, Apr 17, 2018 at 2:47 PM
    #12
  13. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    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 at 10:21 PM
    _Nate_, Apr 17, 2018 at 10:15 PM
    #13
  14. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    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.
     
    Hopup, Apr 18, 2018 at 1:50 PM
    #14
  15. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    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?
     
    _Nate_, Apr 18, 2018 at 10:05 PM
    #15
  16. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    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
     
    Hopup, Apr 18, 2018 at 11:53 PM
    #16
  17. _Nate_

    _Nate_

    Joined:
    Jun 12, 2017
    Messages:
    47
    Likes Received:
    0
    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?
     
    _Nate_, Apr 18, 2018 at 11:56 PM
    #17
  18. _Nate_

    Hopup

    Joined:
    Jul 5, 2015
    Messages:
    107
    Likes Received:
    7
    Use your own code what you got from reading the tx not my example, did you try to send it using 32bits?
     
    Hopup, Apr 18, 2018 at 11:58 PM
    #18
    1. Advertisements

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.