RMT, receiving is working fine however transmitting seems to fail



  • Hello,

    I have been playing around with an IR receiver and an IR transmitter, I have no issue recording the signal from my AC remote (Panasonic) however when I try to transmit I seems to be erratic and not transmitting everything.
    I am using two WiPy, one to receive and one to transmit.

    To receive/record:

    import machine
    import time
    # create a RMT object
    rmt = machine.RMT(channel=4)
    # Configure RTM for receiving
    rmt.init(gpio="P21", rx_idle_threshold=12000)     
    # wait for any number of pulses until one longer than rx_idle_threshold
    while True:        
        data = rmt.pulses_get()
        print('length:%s' % (len(data)))
        print(data)
    

    From the remote the output is as followed:

    length:128
    ((0, 3458), (1, 1769), (0, 397), (1, 500), (0, 366), (1, 1340), (0, 419), (1, 475), (0, 394), (1, 472), (0, 393), (1, 475), (0, 367), (1, 498), (0, 367), (1, 500), (0, 367), (1, 501), (0, 367), (1, 500), (0, 394), (1, 472), (0, 397), (1, 472), (0, 392), (1, 500), (0, 368), (1, 499), (0, 398), (1, 1307), (0, 397), (1, 498), (0, 367), (1, 476), (0, 391), (1, 500), (0, 368), (1, 499), (0, 396), (1, 448), (0, 415), (1, 475), (0, 367), (1, 499), (0, 366), (1, 1340), (0, 420), (1, 1316), (0, 420), (1, 1313), (0, 392), (1, 501), (0, 422), (1, 472), (0, 392), (1, 1315), (0, 394), (1, 500), (0, 366), (1, 500), (0, 368), (1, 499), (0, 368),
    (1, 499), (0, 395), (1, 449), (0, 391), (1, 499), (0, 367), (1, 500), (0, 367), (1, 476), (0, 391), (1, 500), (0, 392), (1, 475), (0, 391), (1, 475), (0, 367), (1, 499), (0, 368), (1, 499), (0, 424), (1, 470), (0, 368), (1, 499), (0, 368), (1, 499), (0, 368), (1, 499), (0, 366), (1, 501), (0, 367), (1, 500), (0, 395), (1, 472), (0, 368), (1, 498), (0, 368), (1, 499), (0, 368), (1, 499), (0, 390), (1, 478), (0, 392), (1, 474), (0, 395), (1, 472), (0, 393), (1, 473), (0, 396), (1, 472), (0, 419), (1, 475), (0, 396), (1, 470), (0, 394), (1, 1312), (0, 396), (1, 1338), (0, 422), (1, 472), (0, 390), (1, 478), (0, 392), (1, 474), (0, 394), (1, 472))
    

    If i try to send this code using an IR led from another WiPy with the following code:

    from machine import RMT
    import time
    
    record = ((0, 3458), (1, 1769), (0, 397), (1, 500), (0, 366), (1, 1340), (0, 419), (1, 475), (0, 394), (1, 472), (0, 393), (1, 475), (0, 367), (1, 498), (0, 367), (1, 500), (0, 367), (1, 501), (0, 367), (1, 500), (0, 394), (1, 472), (0, 397), (1, 472), (0, 392), (1, 500), (0, 368), (1, 499), (0, 398), (1, 1307), (0, 397), (1, 498), (0, 367), (1, 476), (0, 391), (1, 500), (0, 368), (1, 499), (0, 396), (1, 448), (0, 415), (1, 475), (0, 367), (1, 499), (0, 366), (1, 1340), (0, 420), (1, 1316), (0, 420), (1, 1313), (0, 392), (1, 501), (0, 422), (1, 472), (0, 392), (1, 1315), (0, 394), (1, 500), (0, 366), (1, 500), (0, 368), (1, 499), (0, 368),
    (1, 499), (0, 395), (1, 449), (0, 391), (1, 499), (0, 367), (1, 500), (0, 367), (1, 476), (0, 391), (1, 500), (0, 392), (1, 475), (0, 391), (1, 475), (0, 367), (1, 499), (0, 368), (1, 499), (0, 424), (1, 470), (0, 368), (1, 499), (0, 368), (1, 499), (0, 368), (1, 499), (0, 366), (1, 501), (0, 367), (1, 500), (0, 395), (1, 472), (0, 368), (1, 498), (0, 368), (1, 499), (0, 368), (1, 499), (0, 390), (1, 478), (0, 392), (1, 474), (0, 395), (1, 472), (0, 393), (1, 473), (0, 396), (1, 472), (0, 419), (1, 475), (0, 396), (1, 470), (0, 394), (1, 1312), (0, 396), (1, 1338), (0, 422), (1, 472), (0, 390), (1, 478), (0, 392), (1, 474), (0, 394), (1, 472))
    data = ()
    duration = ()
    for x in record:
        data = data + (x[0],)
        duration = duration + (x[1],)
    
    rmt = RMT(channel=4, gpio="P21", tx_idle_level=RMT.LOW)
    while 1:
        print('sending...')
        rmt.pulses_send(duration, data)
        print('done')
        time.sleep(2)
    

    I get random transmissions:

    length:25
    ((0, 564), (1, 330), (0, 208), (1, 818), (0, 559), (1, 370), (0, 654), (1, 263), (0, 850), (1, 187), (0, 436), (1, 288), (0, 558), (1, 571), (0, 695), (1, 11801), (0, 1012), (1, 312), (0, 374), (1, 274), (0, 207), (1, 573), (0, 1796), (1, 647), (0, 1194))
    length:7
    ((0, 265), (1, 156), (0, 284), (1, 183), (0, 202), (1, 174), (0, 205))
    

    Any idea what am I doing wrong ?

    Thank you in advance.


Log in to reply
 

Pycom on Twitter