GPIO Pins don't read out right
I'm currently working on an autonomous robot. When we started we used a Raspberry Pi to collect data from our rotary encoders on the GPIO pins. We wrote a python file that perfectly read out 73.736 pulses when we rotated our wheel exactly 1 time. We calculated this amount of pulses using the wheel-to-encoder ratio and the amount of pulses of 1 encoder rotation. The number was correct.
Later on, we noticed that our camera lost frames due to an SDK that didn't work that well on Raspbian. That's when we made the decision to step up to an UP Squared board. We installed Ubuntu 18.04 because we work with ROS Melodic, and the SDK works better with this OS. The UP Squared board works perfectly with the camera now and takes over the other tasks of the Pi just fine.
We tried our script to read out our encoders on the UP Squared. At first we didn't get any results due to a kernel that didn't support the GPIO and the RPi.GPIO package that isn't made for Ubuntu 18.04. We downgraded our kernel to 5.0.0 generic, and made three versions of our script: the original one, one using the mraa package, and one using the periphery package. We also managed to install an RPi.GPIO package for Ubuntu 18.04.
We got all three of them reading out our encoder data! But not in the right way... When we drive our robot really slow, they all 3 tend to the 73.736 pulses per rotation , but when we drive full power, they only manage to read out 17-24K pulses. The slower we drive, the more pulses we get through. Also, when we drive fast, the script thinks we drive forward, when we drive slow, it thinks we drive backwards. When we drive backwards it is the other way around.
We've been troubleshooting for a while now... here's some things we noticed and tried to catch:
- The current could be to low to power all devices connected to the up squared (it gets it's power from a power module). So we hooked it up to it's original charger, but no difference.
- We tried different pins from the GPIO, all general GPIO pins, no difference.
- We read somewhere that the UP Squared doesn't come with pull up/down resistors, so we put in our own hardware resistors in the robot, no difference.
- We tried to use the Linux GPIO pinout, the RPi pinout and the normal Pin numbers, only the normal pin numbers get data through, the rest gets errors that the pins don't exist.
- We've been looking in the BIOS settings to maybe be able to change some things, nothing found.
I provided our scripts to read out the encoders with this question, which work on the raspberry.
We think it may be due to the pulses coming in too fast, but I think if the Raspberry can handle it, the UP Squared should be able to do that too. Maybe there is a problem with processor counters/clocks or interrupts which have influence on our script? Does anybody have an idea why not all of the pulses come through?
thanks a lot in advance!
- 267 All Categories
- 104 Announcements & News
- 35 Product News - New Product/Product Change Notice/ End-of-life
- 175 Welcome Developers!
- 48 Unboxing & Project Sharing
- 15 Tech Updates
- 235 UP Products
- 20 UP Squared Pro
- 107 UP Xtreme
- 763 UP Squared
- 1.3K UP Board
- 81 UP Core Plus
- 209 UP Core
- 1 UP Xtreme Lite
- 36 UP AI Edge
- 207 Starter Kits & Peripheral