Page 4 of 7
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Mon Jul 13, 2026 11:20 pm
by mnfisher
Okay,
The pic12 acts as a transmitter with one or multiple recipients. The rc5 protocol would work okay - the Manchester encoder should work okay - with some tweaks to the timing.
I'll find a transmitter and play tomorrow. See
https://flowcode.co.uk/forums/viewtopic.php?t=2944
The rc5 uses a very similar encoding to this with a 14 bit message
Martin
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Tue Jul 14, 2026 12:55 am
by ELECTRONICA67
Ok, Thanks
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Tue Jul 14, 2026 12:41 pm
by mnfisher
I found a 'transmitter' board - but it doesn't seem to work (the LED doesn't seem to be connected to anything (no resistor etc)). The IR remote I found generates NEC format signals
However - I modified the Manchester encoding transmitter to generate RC-5 signal. I checked output on a logic analyser.
The 14 bit 'payload' has the format:
2 x 1 bits
Toggle bit (alternates 0 / 1 on each key press)
Address 5 bits
Data 6 bits (0..63)
The only MCU specific part here is the interrupt enable which needs to fire every 889us - this will need altering for PIC.

- LabNation_Screenshot57.png (162.85 KiB) Viewed 2194 times
Martin
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Tue Jul 14, 2026 3:35 pm
by mnfisher
... and a decoder.
I connected the transmitter directly to the receiver using a jumper. This means the logic is inverted - and needs a change to ProcessPin - enable the first block if using IR.
Fixed a bug in transmission - sent bits 15..1 instead of 14..0...
For the PIC - the interrupt handler needs to toggle the direction bit on each transition - so that it then looks for a change in opposite direction. The timer I use - ticks every 0.5us and I read the time delta in PinChange - this might need some work?
The receiver outputs the data received to UART - first the total 14 bit payload then the command - it's easy to shift out the address (or indeed combine the address and command as data). There is also the 'toggle' bit at bit 11.
Martin
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Tue Jul 14, 2026 3:49 pm
by mnfisher
Another fly in the ointment - the transmitter needs to modulate the output pin (using PWM) at 38kHz. I'd imagined the transmitter board would do this - but looking at mine (and photos) - I don't think this is the case. Indeed I might have fried mine by connecting it directly to an output pin..
Martin
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Tue Jul 14, 2026 4:16 pm
by mnfisher
My first attempt at generating with a 38kHz carrier.
I used the PWM component - and toggle the PWM pin (in this case d6) and my current output pin on and off at the same time. The duty on the PWM pin looks a bit 'low' - but setdutycycle doesn't seem to alter this?

- LabNation_Screenshot59.png (191.47 KiB) Viewed 2153 times
I also accidentally converted a block to C - attempts to convert it back didn't work (can't read xml file)
Martin
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Tue Jul 14, 2026 4:26 pm
by ELECTRONICA67
Thanks Martin, I appreciate the time and knowledge you're sharing with me;
I'll start assembling the hardware immediately to test the component.
Enrique
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Tue Jul 14, 2026 4:54 pm
by mnfisher
It will be interesting to hear how it goes.
There are a few changes needed if you use a PIC, as I didn't have the part to test, I used an Arduino (it was the set-up at present) - if you have issues I'll try and help.
It's not a component as such - I'd probably need some matrix magic to make the interrupts portable - but hopefully a step in the right direction.
Martin
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Wed Jul 15, 2026 10:22 am
by mnfisher
... and of course the PWM duty is 0..255 (not %) - so adjusting the duty cycle does work as expected...
Re: Modulo Ky-022 Sensor Receptor Infrarrojo Ir Pic
Posted: Wed Jul 15, 2026 11:32 am
by mnfisher
... I couldn't get the IR transmission to work using the PWM component

Looking at the trace on the scope - the pulses had 'gaps' - each high pulse was made up of several short 38kHz lumps with a space between them.
I added a small lump of C to enable the PWM from TMR0 and some C - to enable / disable in transmit. The LED on the receiver flashes brightly when the signal is good... Output on d6
Now - it seems to work AOK :=) (and I hadn't killed the IR transmitter board!)
Sorry - still AVR specific. I'll have a think about PIC conversion.
Martin