Strange behaviour with Jetson Nano DevKit PWM signal

Hello,

I’m in trouble with Jetson Nano and hope you can help me.

I need to use the board with a camera (Flir Duo Pro R), which accepts 3.3-5V PWM signal at 50Hz as commands.

Before Jetson (during pinmux configuration), I tested my scripts with a Raspberry 3B+, so I’m comparing the two boards.

Due to strange feedback by Jetson I decided to use a common arduino servomotor to test the signal and here the situation where I am:

SERVOMOTOR
Raspberry successfully generates right pwm signal
Jetson successfully generates right pwm signal

CAMERA
Raspberry successfully generates right pwm signal and camera receives commands
Camera does not receive commands, I don’t know anything about signal

This is very strange situation and I don’t know how to solve.
I’m powering the board via USB for this test, so I thought it could be voltage/current issue, but PWM is low voltage signal.

Hope someone could help me

Thank you

Jacopo

1 Like

Hi, did you probe the PWM signal to camera with oscilloscope? Or you can just probe the signal without any external device. It is important to observe if any difference between the output signals of Raspberry and Jetson.

Hello,
You were right, I didn’t use oscilloscope to observe the signal. I put too much trust in similarity with Raspberry.

I tried more with servomotor and I noticed strange behaviour also with it (it did not feedback for all duty cycles), so I acquired an oscilloscope.

My pwm test script is very simple:

import Jetson.GPIO as GPIO

pin = 32
freq = 50

GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin, GPIO.OUT)
pwm = GPIO.PWM(pin, freq)

pwm.start(0)
try:
        while True:
                pwm.ChangeDutyCycle(25)

except KeyboardInterrupt:
        pwm.stop()
        GPIO.cleanup()

Here-follow the result:

RASPBERRY
No problems: oscilloscope shows the right signal.

JETSON
Only troubles. In particular Voltage is around 225mV (very low), and freq in not 50Hz (as I set).
The signal is affected by strong noise I think.

I tried other DCs, other freqs, DCs change (as trigger, that I need).
Anytime the same: Raspberry works fine, Jetson doesn’t.

I don’t know how to solve this situation, and if I’m wrong.
Hope someone can help me

Thank you,
Jacopo

1 Like

Which pin are you using? I mean the physical pin number on board.

Hi Jacopo,

I am wondering if you could use the linux pwm sysfs to control the pwm signal and see the correctness.

https://www.kernel.org/doc/Documentation/pwm.txt
Some example to enable one pwm on pwmchip0.

# cd /sys/class/pwm/pwmchip0
 # echo 0 > export
 # cd pwm0
 # echo 20000 > period (20us is the total time period of the pulse)
 # echo 10000 > duty_cycle (50% duty cycle)
 # echo 1 > enable

Hello Wayne,

Thanks your your instructions.

I read something about sysfs to control pwm and I used exactly your example.
Unfortunately the result is the same: low voltage, random freq and unrecognizable signal.

cat /sys/kernel/debug/pwm provides this info:

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   (sysfs               ): requested enabled period: 20000 ns duty: 10000 ns polarity: normal
 pwm-1   (pwm-regulator       ): requested enabled period: 8000 ns duty: 1440 ns polarity: normal
 pwm-2   ((null)              ): period: 0 ns duty: 0 ns polarity: normal
 pwm-3   (pwm-fan             ): requested enabled period: 45334 ns duty: 0 ns polarity: normal

I’m not sure but I think it means pwm-0 (on pin 32) is correctly set.
(I don’t clearly know the difference between platform/70110000.pwm and platform/7000a000.pwm, maybe different elements? J41 and another, I think).

Could some configuration be wrong? I used Jetson-IO to configure pwm: https://devtalk.nvidia.com/default/topic/1063105/jetson-nano/can-t-get-jetson-nano-to-boot-with-custom-pinmux-configuration-per-nvidia-instructions/1

I want to try sysfs also with raspberry next days.

Thank you so much

Hi Jacopo,

In you first description

SERVOMOTOR ->Jetson successfully generates right pwm signal
CAMERA → Camera does not receive commands, I don’t know anything about signal

It sounds you had a working pwm case here with servomotor. Was it also pin32?

Are you able to use the PWM sysfs + servomotor to reproduce this successful case first?

Hi Wayne,

In this long period I made some tests.
I’m so sorry to tell you that my oscilloscope is untrustworthy (I used it for other purposes but results are not right), and I can’t have new one due to Covid-19 emercency.

I used sysfs in Jetson (always pin32) as you suggested and I note that:

  • SERVOMOTOR responds correctly (pwm signal successfully generated)
  • CAMERA does not respond

What I can point out is that Servomotor is 3-wired (Vcc, GND and signal) and Camera is 2-wired (GND, signal).
So, I think Jetson pin does not generate enough voltage for camera expectation (3.3-5V), in the other case Servomotor receives 5V voltage-level. Could be this?

If it is, Jetson does not work as it should, because logic-level of pinout should be 3.3V (like Raspberry). This also explains why I can manage pwm to camera with Raspberry.

Waiting for suggestions

Jacopo

Hi, the pin 32 is 3.3v output. There is a 1.8v to 3.3v level shift between pin 32 and Tegra chip pin. There is request of pin output on level shift: Do not recommend having the external pullup or pulldown resistors. If mandatory, it is recommended the value should be larger than 50 kΩ.

You can check the datasheet of camera to see if there is such pu/pd as requested.

Hello Trumany,

Thank you for your reply.

There is no mention of pullup or pulldown in camera datasheet/manual (Flir Duo Pro R). I’m contacting producer to make certain about this, but I’m quite sure there isn’t any resistor.

Any other solutions?
It is a strange behaviour. If you need more details for helping me, please let me know.

Thank you

Jacopo

Better to have the waveform of pin output so as to check the detail situation. Can you try to get one to test?

Hello

I found an oscilloscope and I could test again.

Here-after a comparison between Jetson and Raspberry PWM signal related to following simple code:

import RPi.GPIO as GPIO #or Jetson.GPIO as GPIO

pin = 32 #for both
freq = 50

GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin, GPIO.OUT)

pwm = GPIO.PWM(pin, freq)

pwm.start(0)
try:
   pwm.ChangeDutyCycle(10)
   while True:
      pass
except KeyboardInterrupt:
   pwm.stop()
   GPIO.cleanup()

RASPBERRY:

The wave is correct:

  • 50Hz of freq, so period of 20ms and duty-cycle of 2ms (right 10%)
  • high voltage around 3.3V

JETSON:

Random signal:

  • no freq (this wave does not appear in all periods)
  • no duty-cycle
  • random voltage

I made same test by directly sysfs with following settings:

cd /sys/class/pwm/pwmchip0
echo 0 > export
cd pwm0
echo 20000000 > period
echo 2000000 > duty_cycle
echo 1 > enable

and result is the same random wave.

It is clear something wrong.

Waiting for reply
Thank you
Jacopo

Hi Jacopo,

Back to the pinmux, you’ve configured this pin as PWM, right?

Yes, of course.

I used jetson-io.py to configure pinmux, and I have both 32 and 33 PWM pins.

The strange thing is that I’m able to change position of common 5V 3-wires servomotor using 32 PWM pin: I think the voltage it receives is not up to 5V (low speed rotations and not always successful), but I can see its positioning according to what I set (with both python and sysfs). I just thought something to do with 3rd wire (5V), but It is my supposition.

Really don’t know why and how to solve this strange behaviour.

Jacopo

Did you probe the PWM signal on pin 32/33 without device attached? What is the waveform like?

yes, of course.
The waveforms I reported in the previous reply are from no-device-attached test, and result is no sense signal for both pin 32/33.

Hi Jacopo,
Can you read the register 0x700031fc after selecting PWM in jetson-io?
Also, please try PWM signals by writing 0x05 to register 0x700031fc.
First share, what is the value in register 0x700031fc.
Then try with 0x05 value.

Thanks,
Shubhi

Hello Shubhi,

Thank you so much for your reply.

I disabled and enabled again PWM in jetson-io (with rebooting), then I used devmem2 to read/write register 0x700031fc.

sudo devmem2 0x700031fc b:

/dev/mem opened.
Memory mapped at address 0x7f7b8ce000.
Value at address 0x700031FC (0x7f7b8ce1fc): 0x1

sudo devmem2 0x700031fc b 0x05:

/dev/mem opened.
Memory mapped at address 0x7fa7675000.
Value at address 0x700031FC (0x7fa76751fc): 0x1
Written 0x5; readback 0x5

sudo devmem2 0x700031fc b:

/dev/mem opened.
Memory mapped at address 0x7fb067e000.
Value at address 0x700031FC (0x7fb067e1fc): 0x5

I tried via sysfs and python script (same of previous post) to generate PWM signal and I read with oscilloscope the following:

Voltage always up to around 1V, but sometimes a waveform appears (no freq). The second waveform you can see is a singular one of those I want to generate (10% of 20ms period), but wrong voltage. This is an half good news I think.

Waiting for your reply

Thanks,
Jacopo

Hi Jacopo,
Image you shared is not getting loaded.
So, are you saying with value 0x5 also, there is no improvement in PWM signals?
Also, to save your debugging time, you do not need to run jetson-io to enable PWM (just for debugging), you can directly write value 0x1 into register 0x700031fc.
Can you also check PWM signals by writing 0x9 value in above register, see if the signals improved?

Hi Shubhi,

Thank you again and sorry for image uploading (strange because I can see it). Anyway I edited previous post (image re-uploaded) and new result will be uploaded here.

I paid more attention to your instructions and I tried all steps here-reported:

~/Desktop/pwmtest$ sudo devmem2 0x700031fc b
/dev/mem opened.
Memory mapped at address 0x7fa64a1000.
Value at address 0x700031FC (0x7fa64a11fc): 0x1
~/Desktop/pwmtest$ python simple.py
running
^C
~/Desktop/pwmtest$ sudo devmem2 0x700031fc b 0x05
/dev/mem opened.
Memory mapped at address 0x7fac4fb000.
Value at address 0x700031FC (0x7fac4fb1fc): 0x1
Written 0x5; readback 0x5
~/Desktop/pwmtest$ sudo devmem2 0x700031fc b
/dev/mem opened.
Memory mapped at address 0x7fb7192000.
Value at address 0x700031FC (0x7fb71921fc): 0x5
~/Desktop/pwmtest$ python simple.py
running
^C
~/Desktop/pwmtest$ sudo devmem2 0x700031fc b 0x09
/dev/mem opened.
Memory mapped at address 0x7f929b7000.
Value at address 0x700031FC (0x7f929b71fc): 0x5
Written 0x9; readback 0x9
~/Desktop/pwmtest$ sudo devmem2 0x700031fc b
/dev/mem opened.
Memory mapped at address 0x7f93249000.
Value at address 0x700031FC (0x7f932491fc): 0x9
wesiijet@wesiijet-sbc:~/Desktop/pwmtest$ python simple.py
running
^C

I used python script reported in previous post, which gets same results of sysfs:

import Jetson.GPIO as GPIO

pin = 32
freq = 50

GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin, GPIO.OUT)

pwm = GPIO.PWM(pin, freq)

pwm.start(0)
try:
   pwm.ChangeDutyCycle(10)
   print('running')
   while True:
      pass
except KeyboardInterrupt:
   pwm.stop()
   GPIO.cleanup()

The result is always the same:

CONSIDERATIONS:

  • beginning voltage is rightly 0V, but when I try to generate PWM, voltage is stable at around 1V (no 3.3V) and “random” waveforms go to 0V (the opposite I want) as you can see in picture;
  • when script is interrupted, not always voltage returns to 0V, but I can read 1V;
  • there are no frequency and no duty-cycle, but sometimes I can recognize waveform I want. In picture I can recognize 4 intervals of 20ms: first it starts HIGH and after 2ms goes LOW, then HIGH for all 20ms, then third waveform same as first one, and the fourth is exactly what I want (2ms HIGH in 20ms period). I reported this case, but last waveform doesn’t always appear and most of time voltage remains stable at around 1V.

I’m pretty confident that if voltage was stable at 0V at default, this problem could be fixed (only UP to 3.3V left).
I’m not able to solve this problem, so I hope you can help me.
I have to say that I’m using Jetson with other (no-PWM) peripherals and all is good, I’m in trouble only with PWM since the beginning. Also softwares configurations work well.

Thank you so much

Jacopo