-
Notifications
You must be signed in to change notification settings - Fork 220
Description
I'm using a rotary encoder based on the KY-040 module, with the Adafruit_BBIO.Encoder.RotaryEncoder
class. I'm running the latest IoT Debian image on a Beaglebone Black:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.2 (stretch)
Release: 9.2
Codename: stretch
$ uname -r
4.4.91-ti-r133
$ python --version
Python 2.7.13
$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[a5d5f437baeaa7f8e14d5ae037268abf7a67e88e]
eeprom:[A335BNLT00C03614BBBK0298]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2017-10-10]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.09-00002-g0f3f1c7907]
kernel:[4.4.91-ti-r133]
nodejs:[v6.12.0]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg:[bb-cape-overlays]:[4.4.20171107.0-0rcnee1~stretch+20171107]
pkg:[bb-wl18xx-firmware]:[1.20170829-0rcnee1~stretch+20170829]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee0~stretch+20170830]
To enable the QEP module on the hardware, I added these lines to /boot/uEnv.txt
as instructed in the Encoder
module source code and rebooted:
cmdline=coherent_pool=1M quiet cape_universal=enable
cape_enable=bone_capemgr.enable_partno=cape-universala
I then configured the equep2
pins on the command line. I don't think this step is necessary, though, as the Encoder module seems to set them up as qep
in code already.
$ config-pin P8.11 qep
$ config-pin P8.12 qep
And with these inputs connected to the encoder, I ran this simple code via an SSH connection:
import time
import Adafruit_BBIO.Encoder as Encoder
encoder = Encoder.RotaryEncoder(Encoder.RotaryEncoder.EQEP2)
encoder.setAbsolute()
encoder.zero()
while True:
print("Encoder position: " + encoder.getPosition())
time.sleep(1)
- Expected: the position is 0 upon every start of the app
- Actual: the position is not 0 and is remembered upon app restarts
The zero()
method calls the setPosition()
method to set the position to 0. The issue here is that currently the setPosition()
method does nothing else than printing debug output. The new position is not set. I'm assuming that it's because the python function to write sysfs files has not yet been implemented?
Just for comparison, I tested the original PyBBIO code, which is the same except for the uncommented part that does set the position, and has a Python API for writing to sysfs. Unfortunately, that caused a segmentation fault.
Thanks!