Why is my PWM not working?

After viewing countless relevant topics relating to my problem I am left stuck. I am attempting to utilize the pwm0 located on pin 32 of the Jetson Nano 2GB Dev Kit, and after using;

sudo /opt/nvidia/jetson-io/jetson -io.py

to enable the pwm0 then after running a simple program to confirm that a PWM signal is being generated and wiring the pin 32 to an oscilloscope, I find that instead of seeing a PWM signal I am left with an output of 3.3 V.

Please help.

here is the simple PWM test program:

import Jetson.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
my_pwm=GPIO.PWM(32,500)
my_pwm.start(50)

time.sleep(5)

Hi granah18,

Are you using the devkit or custom board for Jetson Nano?
What’s your Jetpack version in use?

Please refer to the following steps on Jetson Nano to verify PWM output at PIN32

$ sudo /opt/nvidia/jetson-io/jetson-io.py
(Configure Jetson 40pin Header -> Configure header pins manually -> [*] pwm0  (32) -> Back -> Save pin changes -> Save and reboot to reconfigure pins)
$ sudo apt update
$ sudo apt install git python3-pip
$ git clone https://github.com/NVIDIA/jetson-gpio.git
$ cd jetson-gpio
$ sudo python3 setup.py install
$ cd samples

(modify the following line in simple_pwm.py)
output_pins = {
    'JETSON_XAVIER': 18,
-   'JETSON_NANO': 33,
+   'JETSON_NANO': 32,
    'JETSON_NX': 33,
    'CLARA_AGX_XAVIER': 18,
    'JETSON_TX2_NX': 32,
    'JETSON_ORIN': 18,
    'JETSON_ORIN_NX': 33,
    'JETSON_ORIN_NANO': 33
}

$ sudo python simple_pwm.py

***Update the project needs now require that both PWM pins (32 and 33) be enabled.

Hello KevinFFF,

Thank you for the response I am using the Jeston Nano 2 GB Devkit.

I have completed the above steps (this time now to include the use of pwm2 on pin 33 as well as pwm0 on pin 32)

There is but one hiccup when using;

$ vim simple_pwm.py

I find in the file the following output pins;

output_pins = {
‘JETSON_XAVIER’: 18,
‘JETSON_NANO’: 33,
‘JETSON_NX’: 33,
‘CLARA_AGX_XAVIER’: 18,
‘JETSON_TX2_NX’: 32,
‘JETSON_ORIN’: 18,
‘JETSON_ORIN_NX’: 33,
‘JETSON_ORIN_NANO’: 33
}

It seems that I am missing the project essential " ‘JETSON_NANO’: 32, " line why might this be?

apologies for the late response.

What’s your Jetpack version in use?

Do you mean that you want to enable both PIN 32 and PIN33 for PWM?

I am on

nvidia-l4t-core 32.7.4-20230608212426

and that is correct I would like to use both PIN 32 and PIN33 forPWM.

Please refer to Unable to get multiple PWM pins to work simultaneously - #5 by KevinFFF for this use case.

Thank you for the reference although helpful for the future, at this point that forum doesn’t quite help me understand why there is no PWM signal being generated from the Jetson.

If you refer to the steps I shared in 8./Mar., is there the PWM output from PIN32 of 40-pins expansion header?

Have you also tried the method in Unable to get multiple PWM pins to work simultaneously - Jetson & Embedded Systems / Jetson Orin Nano - NVIDIA Developer Forums to configure PWM to enable PWM for both PIN32 and PIN33? (i.e. you have to modify the simple_pwm.py to enable 2 PWM output)

Sorry that I’m not clear about what’s your current issue and the status.

in response to “Unable to get multiple PWM pins to work simultaneously - #5 by KevinFFF”, and after running the code below.

/////////////////Start of Code

import time
import math
import Jetson.GPIO as GPIO

def main():
pwm_pins = [32,33]
# Pin Setup:
# Board pin-numbering scheme
GPIO.setmode(GPIO.BOARD)
# set pin as an output pin with optional initial state of HIGH
GPIO.setup(pwm_pins, GPIO.OUT, initial=GPIO.HIGH)

_frequency_hz = 50
_duty_cycle_percent = 25
incr = 5

# p1 is a PWM object.
# ERROR the order of the p1 and p2 initialization determines which one works
# and which one fails. Whichever is initialized last will work, and whichever is
# first will fail. (verified with oscilloscope and stepping through with pdb). 
GPIO.setup(pwm_pins[0], GPIO.OUT, initial=GPIO.HIGH)
p1 = GPIO.PWM(pwm_pins[0], _frequency_hz)
p1.start(_duty_cycle_percent)

GPIO.setup(pwm_pins[1], GPIO.OUT, initial=GPIO.HIGH)
p2 = GPIO.PWM(pwm_pins[1], _frequency_hz)
p2.start(_duty_cycle_percent)

print("PWM running. Press CTRL+C to exit.")
try:
    while True:
        time.sleep(0.25)
        if _duty_cycle_percent >= 100:
            incr = -incr
        if _duty_cycle_percent <= 0:
            incr = -incr
        _duty_cycle_percent += incr
        p1.ChangeDutyCycle(_duty_cycle_percent)
        p2.ChangeDutyCycle(_duty_cycle_percent)
finally:
    p1.stop()
    p2.stop()
    GPIO.cleanup()

if name == ‘main’:
main()

//////////////////END of Code

I receive the following from an oscilloscope where the Yellow signal is from Pin 33 and the green signal is Pin 32

From the signals provided above we can gather that the Jetson is failing to generate a PWM signal.

**Please note that originally I had just copy and pasted the code from the other forum where pin 15 was a PWM pin (that is not the case for the jetson nano) and I was notified that pin 15 was not a PWM pin. Additionally I have also followed the steps from Mar 8th and the output on the oscilloscope is practically the same.

Do you mean that you can’t output PWM signal even when you use one PWM?

Yes this is correct

It seems not the expected result to me.
Are you using Jetson Nano with SD or eMMC module?

Have you also tried to configure pinmux through pinmux spreadsheet rather than Jetson-IO?

I am using a micro-SD, and I have attempted to use the pinmux spreadsheet however I am not quite sure how to operate it. Additionally, when I try to use the pinmux spreadsheet I receive the following message.

You may need to unblock it in properties of your pinmux spreadsheet file like the following.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.