0

I would like to use hardware PWM on a GPIO port to generate RC-5 IR codes with an IR LED.

I read that .NET Core now has PWM support and that the Pi has at least one PWM-enabled GPIO pin, but I can find precious little documentation on how to access it. The PwmChannel.Create() method requires a chip number, and passing 0 doesn't work.

I'm hoping that the hardware can provide the 36 kHz carrier signal, and the Stopwatch.GetTimestamp() method should give me sufficient resolution to generate the RC-5 output over it... but I just can't get PwmChannel working.

I would be very glad of any pointers on how to do this... or am I on the wrong track altogether?

4
  • I read that: ".NET Core 3.1 is supported on the following operating systems: Debian: 9+, ...". Does it mean Raspbian 10 buster is also OK? – tlfong01 Feb 24 '20 at 3:51
  • 1
    I found Daren May's .NET 3.0 tutorial good. Do you have any other tutorials as good for newbies? - ".NET Core and GPIO on Rpi - Daren May 2019oct16" darenmay.com/blog/…. – tlfong01 Feb 24 '20 at 4:03
  • 1
    I would check that you can generate on off signals accurately at the sub-millisecond rate before you bother adding the carrier. If you check the resulting timings you may find that it can't be done with .NET on the Pi. – joan Feb 24 '20 at 8:30
  • 1
    @tlfong01 Apparently so! I installed the latest Raspbian distro and the latest .NET Core runtime successfully. (I have RS232 communication working nicely. It's just the PWM that's proving tricky.) – Olly Feb 25 '20 at 13:32
0

After having the same issue, I found the solution. You have to enable PWM in the boot config file.

Add this line to your /boot/config.txt file:

dtoverlay=pwm-2chan,pin=12,pin2=13,func=4,func2=4

Answer found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.