Closed jldigi40 closed 9 months ago
Not sure whether using the same GPIO for PWM signal and input monitoring works.... test it maybe? What would work for sure is wiring the PWM pin to some other pin (with a resistor to be safe) and monitor that.
Generally, this will not work, at least not reliability. If the pin is set to pwm, it is internally routed to a different piece of hardware. You might see something on the gpio line, but this will mostly be random noise. I recommend connecting to a different pin with a resistor, as mentioned above.
From the Broadcom manual (chapter 6, page 89), it appears that:
alternate function
such as PWM (which is an output) completely bypass the dections+interrupt blocksFor this reason I believe it can't work and agree with @pgrawehr.
The resistor trick also mentioned by @huesla is a great workaround but be careful because the amount of the events could substantially hit the overall performance because of the overwhelming amount of interrupts in kernel mode.
Hello Raf
Thanks just wanted some thoughts here , idea was more for a self check is PWM is working for diagnostic page on a POC project , based on Blazor based Web app interface I developing , all good just need get out a my good old oscilloscope to check PWM is active and working !!!
Thanks. Joshua
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Raf (Raffaele Rialdi) @.> Sent: Wednesday, January 31, 2024 6:42:58 AM To: dotnet/iot @.> Cc: jldigi40 @.>; Author @.> Subject: Re: [dotnet/iot] If define a PWM Output on , eg GPIO18 (pin12), Does it create a ValueChanged Event if I enable this ? (Issue #2274)
From the Broadcom manualhttps://datasheets.raspberrypi.com/bcm2835/bcm2835-peripherals.pdf (chapter 6, page 89), it appears that:
For this reason I believe it can't work and agree with @pgrawehrhttps://github.com/pgrawehr.
The resistor trick also mentioned by @hueslahttps://github.com/huesla is a great workaround but be careful because the amount of the events could substantially hit the overall performance because of the overwhelming amount of interrupts in kernel mode.
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/iot/issues/2274#issuecomment-1917765510, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5DG5L2PPWU5DEH66NN75VDYRFEMFAVCNFSM6AAAAABCQEXA7KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJXG43DKNJRGA. You are receiving this because you authored the thread.Message ID: @.***>
Hi @jldigi40 it's great to hear that.
I'll give you some alternative ideas:
ATTINY85
microcontroller (below 1$) or equivalent to detect the presence of the PWM and, for example, turn on a led.Even if I have more powerful instruments, I own all of those in my own lab and happily use all of them :-)
Hey @jldigi40 thanks for your questions, since this is not actionable for us I'm going to go ahead and close. If you have any further questions please feel free to open new issue or start Discord discussion
Hi All,
Just general question does the ValueChanged if attaced to a OpenPin , fire on PWM change of such Pin ?
Example - Setup
PWM Setup... /boot/config.text .
Enable PWM
dtoverlay=pwm,pin=18,func=2 . .... ./99-com.rules
Edited for permission... .
PWM export results in a "change" action on the pwmchip device (not "add" of a new device), so match actions other than "remove".
SUBSYSTEM=="pwm", PROGRAM="/bin/sh -c '\ chown -R root:gpio /sys/class/pwm && chmod -R 770 /sys/class/pwm;\ chown -R root:gpio /sys/devices/platform/soc/.pwm/pwm/pwmchip && chmod -R 770 /sys/devices/platform/soc/.pwm/pwm/pwmchip\ '" .
Reboot.... ...
Code Example....
//Start PWM Channel - GPIO18 as in config.text overlay ? var pwm = PwmChannel.Create(0,0,100,0.5); // 100hz, 50/50 duty pwm.Start();
... Can I add a event to GPIO18 and see each time PWM swiitches ?
controller.OpenPin(18,Pinmode.Output).ValueChanged += GPIO18ValueChangeEvent;
Just want make sure not looking at something not possible ?
Joshua