Closed mohamed-keshk closed 1 year ago
Having the same problem. Should be getting a constant stream of ones but get a mix of ones and zeros when the input signal is high. @mohamed-keshk, Can you please share any information on how to fix the issue?
It is possible that the sampling rate is not high enough. In that case, you should write a c program to read sysfs or the gpio registers directly.
@23100048 I'm sorry to disappoint you but I couldn't find a satisfying answer to why that happened, nor have found a solution. I abandoned the project, I mean to get back to it some time later, but till now, I simply can't read the encoder reliably. @anhmiuhv the sampling rate of the jetson nano gpio is a hell lot higher than the 500 hz signal I used to test it. If it can't handle such a slow signal, I guess we'd be better off using an uno.
Yeah, it is likely that you will need to use real time kernel to reliably sample. Uno is probably easier
If you still want to use Jetson Nano, it is worth exploring options to implement in C using libgpiod https://www.ics.com/blog/gpio-programming-exploring-libgpiod-library or sysfs https://www.ics.com/blog/how-control-gpio-hardware-c-or-c . Another option to explore is to read directly from Jetson register (for examples, https://github.com/mdhardenburgh/jetsonNanoRegisterAccess).
I think this is a good blog (albeit for Jetson TX2). https://www.lancesimms.com/JetsonTX2/JetsonTX2MappingGPIOs.html
The Python library contains some overhead.
Thankyou so much for your responses. Yes, I have shifted the process of reading the input signal to an arduino (mega 2560) and am communicating that via rosserial to the jetson nano. That has solved the problem.
I am using the Jetson nano GPIO to read the output of an AB bi-phase rotational encoder encode, I wrote a simple python script to trigger a rising edge interrupt, the callback function prints the current state of the pin that triggered.
After a lot of debugging and many many tries, I stopped using the actual encoder, I’m using a function generator set to output a 3.3v 500hz square wave on pin 13 on the Jetson nano. The output I expect should a stream of ones, but the actual output is random mix of ones and zeros.
The actual output from the terminal: 1 0 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1
What am I missing or doing wrong. This my system: L4T 32.6.1 JetPack 4.6 Ubuntu 18.04.6 LTS Kernel Version: 4.9.253-tegra