Recently switched from an Odroid-C2 to the Jetson Nano Dev Kit. On the c2, I have a python function using wiringpi that properly interfaces with a PCL11 rotary encoder. Using the jetson nano and Jetson.GPIO, ticks are recorded sporadically (if at all).
- Which version of Jetson.GPIO you are using: Current Release
- Which Jetson board you are using: Jetson Nano Developer Kit
Steps to reproduce the behavior:
PCL11 Rotary Encoder: https://www.bourns.com/docs/Product-Datasheets/PEC11L.pdf
- Connect encoder channel A to BCM Pin 6 (Board 31, gpio200)
- Connect encoder channel B to BCM Pin 5 (Board 29, gpio149)
- Connect encoder push-switch to BCM 12 (Board 32, gpio168) [optional]
Here’s how I performed my test on both the Odroid-C2 and the Jetson Nano Dev Kit
clone https://github.com/guyc/py-gaugette.git and modify gaugette/rotary_encoder.py to use Jetson.GPIO
- Remove gaugette.gpio and replace with Jetson.GPIO
- Modify setup calls to match syntax, add setmode() to set to BCM or BOARD, and convert all trigger() calls to ``` self.gpio.add_event_detect(self.[pin_a/pin_b], self.gpio.BOTH, callback=isr) ```
- Create simple driver code `test.py`
import time import Jetson.GPIO as GPIO import gaugette.rotary_encoder A_PIN = 6 B_PIN = 5 gpio = GPIO GPIO.setmode(GPIO.BCM) encoder = gaugette.rotary_encoder.RotaryEncoder(gpio, A_PIN, B_PIN) encoder.start() while True: delta = encoder.get_cycles() if delta!=0: print(str(delta)) else: time.sleep(0.01)
Run test.py and rotate encoder clockwise and counterclockwise
Depending on the direction you rotate, the result should be a simple output:
1 1 1 1 -1 -1 -1 -1 -1
Little to no output. There may be a single output of ‘-1’ or ‘1’ for every 100-200 turns.
I’ve confirmed that this works on my old hardware (Odroid-C2, running Ubuntu 18.04). For every 1 tick, you get one output from the code. Just wondering why this may be different on the Jetson Nano.