bbb, hal_pru_generic, encoder ... what I'm missing?

104 views
Skip to first unread message

Juergen Gnoss

unread,
Jan 16, 2020, 10:45:31 AM1/16/20
to Machinekit


Hello folks,

I try to get an encoder to work on a beaglebone black using hal_pru_generic.
If I rotate the encoder the encoder component doesn't say anything.
I'm sure I'm missing something but I've no clue what.

here my setup:

bbb, no cape hardware attached.

******************************
OS, kernel, overlays
******************************

machinekit@beaglebone:/opt$ sudo scripts/tools/version.sh

git:/opt/scripts/:[66b9438a789ce79859aa5489de9d952b6242d526]
eeprom:[A335BNLT000C1716BBBG0543]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[Machinekit Debian Image 2019-12-16]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-g3d8c979660]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-g3d8c979660]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-UIO-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0]
kernel:[4.19.82-bone-rt-r41]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[disable_uboot_overlay_audio=1]
uboot_overlay_options:[disable_uboot_overlay_wireless=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.14.20191218.0-0rcnee0~stretch+20191218]
pkg:[bb-wl18xx-firmware]:[1.20190227.1-0rcnee0~stretch+20190227]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
pkg:[firmware-ti-connectivity]:[20180825+dfsg-1rcnee1~stretch+20181217]
groups:[machinekit : machinekit adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev gpio pwm eqep remoteproc admin spi docker tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 rng_core.default_quality=100 quiet console=tty0 console=ttyO0,115200n8]
dmesg | grep remote
[    1.208558] remoteproc remoteproc0: wkup_m3 is available
[    1.323638] remoteproc remoteproc0: powering up wkup_m3
[    1.323657] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[    1.325717] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru
dmesg | grep pinctrl-single
[    0.772313] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[    0.784074] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

*********************
Pinmux Settings
*********************

machinekit@beaglebone:~$ for i in 27 28 29 30 31 41; do config-pin -q P9_$i; done;
P9_27 Mode: pruin
P9_28 Mode: pruin
P9_29 Mode: pruin
P9_30 Mode: pruin
P9_31 Mode: pruin
P9_41 Mode: pruin

*********************
machinekit config
*********************

**********************
.ini file
**********************

[PRUCONF]
DRIVER=hal_pru_generic
PRUBIN=rt-preempt/pru_generic.bin
CONFIG=pru=0 halname=hpg num_stepgens=1 num_encoders=2

###############################################################################
# Hardware Abstraction Layer section
###############################################################################
[EMC]

# Name of machine, for use with display, etc.
MACHINE =               elLeadscrew

# Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
DEBUG = 0
#DEBUG =                0x00000003
#DEBUG =                0x00000007


###############################################################################
# Sections for display options
###############################################################################
[DISPLAY]
# Name of display program, e.g., tkemc
DISPLAY = axis
#DISPLAY = tkemc
#DISPLAY = gscreen

# Touchy currently won't work without some hardware buttons/jog-wheel
#DISPLAY = touchy

# Cycle time, in seconds, that display will sleep between polls
CYCLE_TIME =            0.200

# Path to help file
HELP_FILE =             tklinucnc.txt

# Initial display setting for position, RELATIVE or MACHINE
POSITION_OFFSET =       MACHINE

# Initial display setting for position, COMMANDED or ACTUAL
POSITION_FEEDBACK =     ACTUAL

# Highest value that will be allowed for feed override, 1.0 = 100%
MAX_FEED_OVERRIDE =     1.5

# Prefix to be used
#PROGRAM_PREFIX = /home/machinekit/machinekit/nc_files/
#PROGRAM_PREFIX = ../../../nc_files/
PROGRAM_PREFIX = /home/machinekit/machinekit/nc_files

# Introductory graphic
INTRO_GRAPHIC =         machinekit.gif
INTRO_TIME =            5

# Increments for the JOG section
INCREMENTS = 10 1 0.1 0.01


#PYVCP = 3D.Temps.panel.xml

[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python


###############################################################################
# Task controller section
###############################################################################
[TASK]

# Name of task controller program, e.g., milltask
TASK =                  milltask

# Cycle time, in seconds, that task controller will sleep between polls
CYCLE_TIME =            0.010


###############################################################################
# Part program interpreter section
###############################################################################
[RS274NGC]
# File containing interpreter variables
PARAMETER_FILE =        pru-stepper.var

###############################################################################
# Motion control section
###############################################################################
[EMCMOT]

EMCMOT =                motmod

# Timeout for comm to emcmot, in seconds
COMM_TIMEOUT =          1.0

# Interval between tries to emcmot, in seconds
COMM_WAIT =             0.010

# Servo task period, in nanoseconds
SERVO_PERIOD =          1000000


###############################################################################
# Hardware Abstraction Layer section
###############################################################################
[HAL]

# The run script first uses halcmd to execute any HALFILE
# files, and then to execute any individual HALCMD commands.

# list of hal config files to run through halcmd
# files are executed in the order in which they appear

HALFILE =               enctest.hal

# list of halcmd commands to execute
# commands are executed in the order in which they appear

HALUI =                 halui



###############################################################################
# Trajectory planner section
###############################################################################
[TRAJ]

AXES =                  1
COORDINATES =           X
MAX_ANGULAR_VELOCITY = 45.00
DEFAULT_ANGULAR_VELOCITY = 4.50
LINEAR_UNITS =          mm
ANGULAR_UNITS =         degree
CYCLE_TIME =            0.010
DEFAULT_VELOCITY = 20.00
MAX_LINEAR_VELOCITY = 200.00





###############################################################################
# Axes sections
###############################################################################
[AXIS_0]

#
# Step timing is 40 us steplen + 40 us stepspace
# That gives 80 us step period = 12.5 KHz step freq
#
# Bah, even software stepping can handle that, hm2 doesnt buy you much with
# such slow steppers.
#
# Scale is 200 steps/rev * 5 revs/inch = 1000 steps/inch
#
# This gives a maxvel of 12.5/1 = 12.5 ips
#


TYPE =              LINEAR
MAX_VELOCITY =       200.0
MAX_ACCELERATION =   3000.0
# Set Stepgen max 20% higher than the axis
STEPGEN_MAX_VEL =    240.0
STEPGEN_MAX_ACC =    3600.0

BACKLASH =           0.000

# scale is 200 steps/rev * 5 revs/inch
SCALE =  -160

MIN_LIMIT =             -1.0
MAX_LIMIT =             220.0

FERROR =     1.0
MIN_FERROR = 0.25

HOME =                  0.000
HOME_OFFSET =           0.00
HOME_IGNORE_LIMITS =    YES
HOME_USE_INDEX =        NO
HOME_SEQUENCE =         0

# Set to zero if you don't have physical home/limit switches
# Set to the desired homing and latch velocity if you have switches
# See: https://github.com/machinekit/machinekit-docs
HOME_SEARCH_VEL =       0.0
HOME_LATCH_VEL =        0.0

# these are in nanoseconds
DIRSETUP   =              200
DIRHOLD    =              200
STEPLEN    =              1000
STEPSPACE  =              1000



[EMCIO]

# Name of IO controller program, e.g., io
EMCIO =                 io

# cycle time, in seconds
CYCLE_TIME =            0.100

# tool table file
TOOL_TABLE =            tool.tbl


****************************************
.hal file
****************************************

# Launch the setup script to make sure hardware setup looks good

loadusr -w ./setup.sh
loadusr -w config-pin -f ./enctest.bbio


# ###################################
# Core EMC/HAL Loads
# ###################################
# kinematics
loadrt trivkins


# trajectory planner
loadrt tp

# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES tp=tp kins=trivkins


# load low-level drivers
loadrt hal_bb_gpio output_pins=826,914,923 input_pins=817
loadrt [PRUCONF](DRIVER) prucode=$(HAL_RTMOD_DIR)/[PRUCONF](PRUBIN) [PRUCONF](CONFIG)



# ################################################
# THREADS
# ################################################
# hpg = [PRUCONF](DRIVER)
addf hpg.capture-position                 servo-thread
addf bb_gpio.read                         servo-thread
addf motion-command-handler               servo-thread
addf motion-controller                    servo-thread
addf hpg.update                           servo-thread
addf bb_gpio.write                        servo-thread


# ######################################################
# Axis-of-motion Specific Configs (not the GUI)
# ######################################################
# ################
# X [0] Axis
# ################
# axis enable chain
newsig emcmot.00.enable bit
sets emcmot.00.enable FALSE

net emcmot.00.enable <= axis.0.amp-enable-out
net emcmot.00.enable => hpg.stepgen.00.enable


# position command and feedback
net emcmot.00.pos-cmd <= axis.0.motor-pos-cmd
net emcmot.00.pos-cmd => hpg.stepgen.00.position-cmd

net motor.00.pos-fb <= hpg.stepgen.00.position-fb
net motor.00.pos-fb => axis.0.motor-pos-fb


# timing parameters
setp hpg.stepgen.00.dirsetup        [AXIS_0]DIRSETUP
setp hpg.stepgen.00.dirhold         [AXIS_0]DIRHOLD

setp hpg.stepgen.00.steplen         [AXIS_0]STEPLEN
setp hpg.stepgen.00.stepspace       [AXIS_0]STEPSPACE

setp hpg.stepgen.00.position-scale  [AXIS_0]SCALE

setp hpg.stepgen.00.maxvel          [AXIS_0]STEPGEN_MAX_VEL
setp hpg.stepgen.00.maxaccel        [AXIS_0]STEPGEN_MAX_ACC

#setp hpg.stepgen.00.step_type       0
# P8.43 PRU1.out2
setp hpg.stepgen.00.steppin        813
# P8.44 PRU1.out4
setp hpg.stepgen.00.dirpin         812



# ##################################################
# Standard I/O - EStop, Enables, Limit Switches, Etc
# ##################################################

# Create estop signal chain
# Drive software estop to hardware
net estop-out iocontrol.0.user-enable-out => bb_gpio.p8.out-26
setp bb_gpio.p8.out-26.invert 1

# Monitor estop input from hardware
net estop-loop bb_gpio.p8.in-17 => iocontrol.0.emc-enable-in
setp bb_gpio.p8.in-17.invert 1

# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed

# Axis enable signal (active low)
net emcmot.00.enable => bb_gpio.p9.out-14
setp bb_gpio.p9.out-14.invert 1

# Machine power
# Use halui.machine.is-on instead?
net emcmot.00.enable => bb_gpio.p9.out-23


# ##################################################
# Encoder stuff
# ##################################################

setp hpg.encoder.00.chan.00.A-pin       2927
setp hpg.encoder.00.chan.00.B-pin       2928
setp hpg.encoder.00.chan.00.index-pin   2929


*********************************
END configs
*********************************

after start axis
this setup produces steps and dir on P8_13 and P8-12 as expected

in hal config (from axis) i can see that

hpg.encoder.00.chan.00.A-pin
hpg.encoder.00.chan.00.B-pin
hpg.encoder.00.chan.00.index-pin

are set correctly, but on rotating the encoder nothing happend to the encoder component

Thanks for any hints
Ju

Message has been deleted

Juergen Gnoss

unread,
Jan 16, 2020, 10:47:59 PM1/16/20
to Machinekit


OK, for the after world, I found what was wrong

description in the following post


The encoder component doesn't like the pin scheme I used, there has to go the pru pin numbers

changed


setp hpg.encoder.00.chan.00.A-pin       2927
setp hpg.encoder.00.chan.00.B-pin       2928
setp hpg.encoder.00.chan.00.index-pin   2929

to
 
setp hpg.encoder.00.chan.00.A-pin        5
setp hpg.encoder.00.chan.00.B-pin        3
setp hpg.encoder.00.chan.00.index-pin  1

did the trick


Reply all
Reply to author
Forward
0 new messages