Encoders giving zeros in python


#1

I have my class calculating where the robot is by keeping track of the encoder counts. The problem we are running into is the encoders will be returning good numbers, but then suddenly switch to zeros or some other gibberish numbers. The number usually resets after a few times polling it, but by then the software is lost. I replicated this problem using the encoder example provided with the pi. Are there any suggestions or tips that might help me rectify this problem? I am starting to feel frustrated that I picked this hardware for my intro to robotics course. It has worked great so far, but this is a deal breaker if there is no solution. Please help. Thanks!


#2

We’re working with BrickPi for a university project and we’re having the same issue as you have. This is currently preventing us from proceeding.
It even occurs in simple test programs like this one:

from BrickPi import *
import time
​
while True:
	time.sleep(0.05)
	BrickPi.BrickPiUpdateValues()
	print ','.join(map(str, [time.time(), BrickPi.Encoder[PORT_A], BrickPi.Encoder[PORT_D]]))

These errors are commonly printed when DEBUG is enabled:
"BrickPiRx Error: " -2, -4, -5 and -6.


#3

Hey folks,
If we back up, have you run these two examples:

https://github.com/DexterInd/BrickPi_Python/blob/master/Sensor_Examples/LEGO-Encoder_Example.py

and

https://github.com/DexterInd/BrickPi_Python/blob/master/Sensor_Examples/LEGO-Encoder_Test.py

These are the most basic examples of encoder value reading with the motor. What are the results?


#4

Hi,

I have run the 2 examples and saw the encoder values can jump between ports. So at some random time the encoder value of port B appears on port A and those of port C on D. I’ve updated the brick pi software, raspbian and i2c library without result. I’m using a raspberry Pi model 2 B+ and use a battery pack with 6 batteries maybe this had something to do with it?