adafruit / Adafruit_CircuitPython_IRRemote

CircuitPython drivers for IR remote send and receive
MIT License
29 stars 34 forks source link

Code transmission not same as remote #19

Closed No1089 closed 5 years ago

No1089 commented 5 years ago

Hi,

I'm having some weird problems while trying to send out a remote code. I'm using the itsybitsy M4 express.

I have used two configurations to set up the header: 1) This produces an output similar to the Sony remote on the logic analyser. encoder = adafruit_irremote.GenericTransmit(header=[2400, 550], zero=[1150, 630], one=[630, 550], trail=0) 2) This is more alligned with the Sony remote's supposed header. encoder = adafruit_irremote.GenericTransmit(header=[2400, 550], zero=[630, 1150], one=[550, 630], trail=0)

When reading my sony remote's code I receive the following: Heard 25 Pulses: [2455, 544, 1225, 554, 637, 546, 1250, 542, 670, 525, 1241, 551, 650, 552, 648, 540, 1243, 549, 653, 542, 649, 546, 645, 549, 667] length: 25 new length: 24 evenbins: [[547, 12]] oddbins: [[1241, 4], [657, 8]] evenbins: [[547, 12]] oddbins: [[1241, 4], [657, 8]] outliers: [] Pulses: [1225, 637, 1250, 670, 1241, 650, 648, 1243, 653, 649, 645, 667] & Bins: [[1241, 4], [657, 8]] Space: 1241 Mark: 657 12 [False, True, False, True, False, True, True, False, True, True, True, True] Decoded: [86, 15] When I transmit the same code on the M4 I receive the following: Header 1: Heard 34 Pulses: [2463, 495, 1207, 606, 674, 470, 1189, 595, 686, 498, 1179, 586, 699, 487, 677, 509, 1233, 576, 1149, 600, 1202, 590, 1202, 563, 1176, 617, 679, 507, 674, 512, 679, 481, 700, 486] length: 34 new length: 32 evenbins: [[1186, 8], [689, 8]] oddbins: [[496, 16]] evenbins: [[1186, 8], [689, 8]] oddbins: [[496, 16]] outliers: [] Pulses: [1207, 674, 1189, 686, 1179, 699, 677, 1233, 1149, 1202, 1202, 1176, 679, 674, 679, 700] & Bins: [[1186, 8], [689, 8]] Space: 1186 Mark: 689 16 [False, True, False, True, False, True, True, False, False, False, False, False, True, True, True, True] Decoded: [86, 15] Header 2: Heard 34 Pulses: [2471, 507, 653, 1114, 572, 614, 683, 1111, 596, 563, 671, 1122, 596, 591, 600, 586, 647, 1119, 651, 1142, 682, 1110, 650, 1117, 675, 1117, 601, 585, 595, 565, 574, 613, 599, 587] length: 34 new length: 32 evenbins: [[596, 16]] oddbins: [[1117, 8], [590, 8]] evenbins: [[596, 16]] oddbins: [[1117, 8], [590, 8]] outliers: [] Pulses: [1114, 614, 1111, 563, 1122, 591, 586, 1119, 1142, 1110, 1117, 1117, 585, 565, 613, 587] & Bins: [[1117, 8], [590, 8]] Space: 1117 Mark: 590 16 [False, True, False, True, False, True, True, False, False, False, False, False, True, True, True, True] Decoded: [86, 15]

The code is appearing, but between the two bytes some extra data is added. Is there a way to bypass this/transmit the raw pulses?

I'm a bit stuck and having no luck with the IRLib2 on Arduino - it's not allowing me to send codes out - the pin definition is not entirely clear and SAMD51 is barely supported.

I prefer to use Circuitpython since it allows much easier remote debugging.

ladyada commented 5 years ago

the Sony encoder/decoder isnt that heavily tested - since the samd51 has tons of RAM can you just send out the full array, see if the issue is in the encoder or the IR transmitter section?

No1089 commented 5 years ago

I'd love to do exactly that, but not sure where/how to implement it.

ladyada commented 5 years ago

this guide has some example code that you may be able to use! https://learn.adafruit.com/circuitpython-tv-zapper-with-circuit-playground-express

No1089 commented 5 years ago

Thank you. I'll give it a go. Reverted to Arduino, since the deadline is tomorrow, but I have further use for this.

No1089 commented 5 years ago

I got it working! Thanks @ladyada!

No1089 commented 5 years ago

This is the code I used:

`import array import time import adafruit_irremote import pulseio import board import digitalio

button = digitalio.DigitalInOut(board.A3) button.direction = digitalio.Direction.INPUT button.pull = digitalio.Pull.UP

pwm = pulseio.PWMOut(board.D5, frequency=38000, duty_cycle=2 ** 15, variable_frequency=True) pulse = pulseio.PulseOut(pwm) pulses = [2452, 527, 1238, 553, 662, 527, 1264, 527, 662, 528, 1263, 527, 663, 527, 666, 528, 1259, 527, 667, 527, 636, 553, 667, 527, 662]

while True: if not button.value: print("IR signal sent!") pulse.send(array.array('H', pulses)) time.sleep(0.1) pulse.send(array.array('H', pulses)) time.sleep(0.1) pulse.send(array.array('H', pulses)) time.sleep(0.1)`

ladyada commented 5 years ago

congrats :)