Hi all,
I am trying to blink/control an LED strip (WS281x series) with Jetson.GPIO library. What I have been done so far is:
1. I have enabled pwm0 (pin-32) and pwm2 (pin-33) using a command:
sudo /opt/nvidia/jetson-io/jetson-io.py
2. After executing a python script, I could see that PWM is working.
python nano-whitish.py
import RPi.GPIO as GPIO
import time
output_pins = {
'JETSON_XAVIER': 18,
'JETSON_NANO': 33,
'JETSON_NX': 33,
}
output_pin = output_pins.get(GPIO.model, None)
if output_pin is None:
raise Exception('PWM not supported on this board')
def main():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.HIGH)
p = GPIO.PWM(output_pin, FREQUENCY) # set (Hz) frequency
p.start(90) #set (%) duty-cycle
print("PWM running. Press CTRL+C to exit.")
try:
while True:
pass
finally:
p.stop()
GPIO.cleanup()
if __name__ == '__main__':
main()
If I would set FREQUENCY = 100000
(=100kHz), the period should be 10000 nano-seconds (=1/100000 seconds) (and it works-!).
sudo cat /sys/kernel/debug/pwm
platform/70110000.pwm, 1 PWM device
pwm-0 (pwm-regulator ): requested enabled period: 2500 ns duty: 0 ns polarity: normal
platform/7000a000.pwm, 4 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 (pwm-regulator ): requested period: 8000 ns duty: 1440 ns polarity: normal
pwm-2 (sysfs ): requested enabled period: 10000 ns duty: 9000 ns polarity: normal
pwm-3 (pwm-fan ): requested enabled period: 45334 ns duty: 0 ns polarity: normal
3. Our goal is to change a PWM Frequency (on pin-33 of J41) to 800kHz by using a method GPIO.PWM(output_pin, FREQUENCY)
.
If I would set FREQUENCY = 200000
(=200kHz) (and more than this value), I am facing some errors like this:
Traceback (most recent call last):
File "nano_whitish.py", line 37, in <module>
main()
File "nano_whitish.py", line 25, in main
p = GPIO.PWM(output_pin, 200000) # frequency
File "/usr/lib/python2.7/dist-packages/Jetson/GPIO/gpio.py", line 616, in __init__
self._reconfigure(frequency_hz, 0.0)
File "/usr/lib/python2.7/dist-packages/Jetson/GPIO/gpio.py", line 654, in _reconfigure
_set_pwm_period(self._ch_info, self._period_ns)
File "/usr/lib/python2.7/dist-packages/Jetson/GPIO/gpio.py", line 247, in _set_pwm_period
f.write(str(period_ns))
IOError: [Errno 22] Invalid argument
After some tests, I would think that there are some upper frequency limitation around 188000 Hz (=188kHz). More technically, if we put a bigger value than this, something prohibit my Jetson Nano to write a duty_cycle
and period
- as of like this process:
<open file ‘/sys/devices/7000a000.pwm/pwm/pwmchip0/pwm2/duty_cycle’, mode ‘w’ at 0x7f7a711030>
<open file ‘/sys/devices/7000a000.pwm/pwm/pwmchip0/pwm2/period’, mode ‘w’ at 0x7f7a711030>
Question1. Are there any technical report (for a Jetson Nano) regarding the PWM Frequency Range of Operation?
For a Jetson TX2, thanks to @enrique.ramirez, I could find an interesting table from:
Tegra X2 (Parker Series SoC) Technical Reference Manual” (Chapter 40)
For a Jetson Nano, I could not find any information from:
Tegra X1 SoC Technical Reference Manual
at the link → https://developer.nvidia.com/embedded/downloads