I've tried to find the solution from other threads but they all seem to miss the point to a certain degree, usually going into kHz and MHz, or into the SW GPIO territory that I don't need.
I have a led controlled opto relay -setup that's not working properly and need to troubleshoot it. I'm trying to use the hardware GPIO on Raspberry Pi 1 B+. Ideally The hardware GPIO would give a PWM of about 143Hz @ 0-3.3V.
This however has proven hard, using the "gpio" utility included with WiringPi. My script:
- gpio pwm-ms
- pwmr 70
- pwmc 2
- gpio mode 1 pwm
- gpio pwm 1 500
What I get from that, is continuous (no oscilloscope) voltage output ~1.2V. My Fluke can measure frequencies at least up to several hundred Hz and it reports a flat 0Hz (frequency is probably in kHz, etc.) The 2 leds start functioning at around pwm 700 but there is still no frequency reported by the fluke. So I assume the frequency is way beyond my ~140Hz.
Apparently Rpi.GPIO only works in python? It seems to have a simpler way to set frequency and duty cycle.
- pwmNN = GPIO.PWM(ioNN, 50)
I would prefer shell script and gpio utility, but why is it so hard to use?? So how would I get a frequency of 140Hz and a duty cycle of 20-80%? Reading WiringPi documentation and wiki gave me a hint that setting pwm to pwm-ms and range to 70 and divider to 2, would give me something close to 140Hz, but it doesn't seem to do so.
I haven't tried python or C, since it seems that a simple shell script (foo.sh) should do the same thing.