HAL Driver for Raspberry PI GPIOs

More
04 May 2020 20:11 #166670 by juscious
Thanks again !

Wouldnt managed myself to do so much. You are a savior :). Changed to hal_pi_gpio. Seems like everything works, getting some weird end stop errors, but from this point everything is manageable.

Anyways, i will analyze, and actually i have a task of doing SCARA robot control using LinuxCNC via RPI GPIO. Now feeling quite comfortable.

Please Log in or Create an account to join the conversation.

More
04 May 2020 20:56 #166677 by twoflowers
Oh, I had erratic endstop triggering, too. I used software debouncing and they were gone. Here is the hal-file with debouncing - sorry, the last config was an old backup. Please test:

File Attachment:

File Name: rpi3b-mill.tgz
File Size:4 KB
Attachments:
The following user(s) said Thank You: juscious, Vector

Please Log in or Create an account to join the conversation.

More
19 Jul 2020 08:06 - 19 Jul 2020 09:20 #175120 by Markyd
Apologies for what will be a really basic question; how do I run LinuxCNC with / load the hal_pi_gpio hal file? I've installed linucCNC to my rpi4 but I'm now stuck. I want to try gpio before forking out for a mesa board such as the 7i96.
Last edit: 19 Jul 2020 09:20 by Markyd. Reason: typo

Please Log in or Create an account to join the conversation.

More
19 Jul 2020 08:31 #175125 by twoflowers
Feel free to start with my forum.linuxcnc.org/media/kunena/attachme...17065/rpi3b-mill.tgz - it's just the configs, so it'll work on RPI4, too. But you will need to build the kernel + linuxcnc from git (there's a section in the wiki on how to do that - if you don't find tit, drop me a line).

Please Log in or Create an account to join the conversation.

More
19 Jul 2020 09:06 #175126 by tommylight
Do not know for kernel, but you do not have to build Linuxcnc from GIT on the RPI, there are ready made debs for ARMF here
buildbot.linuxcnc.or/dists

Please Log in or Create an account to join the conversation.

More
19 Jul 2020 09:27 #175128 by Markyd
Thanks for the the files. The bit I'm stuck with is what to do with the files, where do i put them and how do i tell linuxCNC to use them. I'm an absolute beginner to LinuxCNC and all the tutorials I've looked at seem to start with Stepconf which I assume i can't use if i want to use the GPIO port?

Can I work from the version of linuxcnc I have already installed (I used this tutorial gnipsel.com/linuxcnc/uspace/rpi4-rt.html ) ?

Please Log in or Create an account to join the conversation.

More
19 Jul 2020 10:17 #175131 by tommylight
Download the attachment, extract it, open the folder, right click on the file with the .ini extension, choose "open with", on the list of apps near the bottom enter linuxcnc.

Please Log in or Create an account to join the conversation.

More
20 Dec 2020 12:46 #192526 by Markyd
I eventually got this up and running, thanks to everyone's assistance.

I'm having problems trying to invert the enable pin and can't for the life of me work out what I'm doing wrong. I have the following
net xenable => hal_pi_gpio.pin-29-out
setp hal_pi_gpio.pin-29-out.invert_output TRUE

net xstep stepgen.0.step => hal_pi_gpio.pin-32-out
net ystep stepgen.1.step => hal_pi_gpio.pin-23-out
net zstep stepgen.2.step => hal_pi_gpio.pin-36-out


net xdir  stepgen.0.dir  => hal_pi_gpio.pin-24-out
net ydir  stepgen.1.dir  => hal_pi_gpio.pin-19-out
net zdir  stepgen.2.dir  => hal_pi_gpio.pin-40-out

but get a 'parameter or pin not found' error when loading the HAL file. What am i doing wrong?

Please Log in or Create an account to join the conversation.

More
20 Dec 2020 13:05 #192530 by tommylight
Try
setp hal_pi_gpio.pin-29.invert_output TRUE
And show us the error, otherwise we can just guess.

Please Log in or Create an account to join the conversation.

More
20 Dec 2020 13:19 - 20 Dec 2020 13:20 #192532 by Markyd
This is the error. I assume the relevant bit is "parameter or pin 'hal_pi_gpio.pin-29.invert_output' not found". I've tried lots of variations and no luck
Error report created by /usr/lib/tcltk/linuxcnc/show_errors.tcl:

Print file information:
RUN_IN_PLACE=no
LINUXCNC_DIR=
LINUXCNC_BIN_DIR=/usr/bin
LINUXCNC_TCL_DIR=/usr/lib/tcltk/linuxcnc
LINUXCNC_SCRIPT_DIR=
LINUXCNC_RTLIB_DIR=/usr/lib/linuxcnc/modules
LINUXCNC_CONFIG_DIR=
LINUXCNC_LANG_DIR=/usr/lib/tcltk/linuxcnc/msgs
INIVAR=inivar
HALCMD=halcmd
LINUXCNC_EMCSH=/usr/bin/wish8.6
LINUXCNC - 2.8.0
Machine configuration directory is '/home/pi/linuxcnc/configs/Harrison_Vert_Mill'
Machine configuration file is 'Harrison_Vert_Mill.ini'
INIFILE=/home/pi/linuxcnc/configs/Harrison_Vert_Mill/Harrison_Vert_Mill.ini
VERSION=1.1
PARAMETER_FILE=linuxcnc.var
TASK=milltask
HALUI=halui
DISPLAY=axis
COORDINATES=X Y Z
KINEMATICS=trivkins
Starting LinuxCNC...
Starting LinuxCNC server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
Starting LinuxCNC IO program: io
Starting HAL User Interface program: halui
twopass:invoked with <> options
twopass:found ./Harrison_Vert_Mill.hal
twopass:found ./custom.hal
twopass:pass0: loadusr -W hal_manualtoolchange
twopass: Error in file ./Harrison_Vert_Mill.hal:
    setting parameter 'hal_pi_gpio.pin-29.invert_output' to 'TRUE'
parameter or pin 'hal_pi_gpio.pin-29.invert_output' not found
Shutting down and cleaning up LinuxCNC...
Removing HAL_LIB, RTAPI, and Real Time OS modules
Removing NML shared memory segments

Debug file information:
Note: Using POSIX realtime
3852
Stopping realtime threads
Unloading hal components
Note: Using POSIX realtime


And this is how it appears in the HAL file
setp hal_pi_gpio.pin-29.invert_output TRUE
net xenable => hal_pi_gpio.pin-29-out
	

net xstep stepgen.0.step => hal_pi_gpio.pin-32-out
net ystep stepgen.1.step => hal_pi_gpio.pin-23-out
net zstep stepgen.2.step => hal_pi_gpio.pin-36-out

# i use GPIO 14,15,18 for xdir ydir zdir, thats rpin 
net xdir  stepgen.0.dir  => hal_pi_gpio.pin-24-out
net ydir  stepgen.1.dir  => hal_pi_gpio.pin-19-out
net zdir  stepgen.2.dir  => hal_pi_gpio.pin-40-out
Last edit: 20 Dec 2020 13:20 by Markyd.

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.117 seconds
Powered by Kunena Forum