Machinekit Hal Configuration in order to work GPIO

1,233 views
Skip to first unread message

Antonio Bello

unread,
Oct 5, 2017, 10:14:45 AM10/5/17
to Machinekit
Hi All,
I have installed Linuxcnc on my Desktop PC and I'm using two parallels port to control my cnc machine. All seems works as expected except for some disturbs on the pci.
Now I want migrate all configuration on the Machinekit installed on my Raspberry pi3 model B.
I have installed jessie and preempt_rt kernel and installed Machinekit, all demos are working as expected if I'm testing only the axis with GPIO (I have tested those with LEDs).
The next point is to migrate all the remaining hal configurations from linuxcnc to machinekit in order to work using the GPIO but I don't know about the tags for each action that need to be set in hal file.

At this url https://expirebox.com/download/b88a07e8ad3627fbc18a0168657f8f0b.html you can see all asctions that I need to set.

In this other url

https://expirebox.com/download/fd991c58407e8bb81a92d268f2572a4f.html

you can see the standard_pinout.hal file that need to be completed in order to map all actions.

Can you help me to complete it in order to have all worked fine?
Thanks in advance for your time, any suggestion is very appreciated because I'm stuck here.

Regards,

Antonio

Antonio Bello

unread,
Oct 5, 2017, 10:22:42 AM10/5/17
to Machinekit
I have attached here the files also.

standard_pinout.hal.NEW
GPIO.xlsx

Antonio Bello

unread,
Oct 6, 2017, 8:49:28 AM10/6/17
to Machinekit
I was able to create the hal file but I cannot set the limits for axis and for ESTOP input.
Can you help me to understand the right procedure pls?
When I decomment the line 78

net estop-ext <= hal_gpio.pin-37-in

machinekit tell me that the hal_gpio.pin-37-in  not exists...
The same for the line 123

can you help me pls?
standard_pinout.hal
Message has been deleted

Masoun Mardini

unread,
Oct 6, 2017, 11:11:15 AM10/6/17
to Machinekit
As far as I can see all your pins are configured as outputs
you must use direction to set outputs and inputs for example in your Hal file line 10

loadrt hal_gpio dir=0x??????????????
1 means output
0 means input

you can exclude pins that you will not use

loadrt hal_gpio dir=0x???????? exclude=0x???????
1 means don't use this pin
0 means use this pin


refer to lines 8&9 in your Hal file to find which pins are used and how

Masoun

Antonio Bello

unread,
Oct 20, 2017, 7:20:17 AM10/20/17
to Machinekit
Thanks a lot for your answer, I think that this could be the root cause of my issue.
But I cannot well understood how can i specify only certains pin to be recognized like inputs.
I'm seeing the comments on the file (on below) to try to understand the right way to generate the dir using the formulas but is very difficult for me.
Can you help me to found the right way to set only the pin : 16,18,19,21,23,35 as input and all other as output please?
Thanks a lot for your help, very appreciated.

# standard pinout config file for 3-axis steppers
# using RapBerryPi V2 GPIO
#
# first load the gpio driver
#rpi2_gpios[] = {2, 3, 4, 5,   6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 };
#rpi2_pins[] =  {3, 5, 7, 29, 31, 26, 24, 21, 19, 23, 32, 33,  8, 10, 36, 11, 12, 35, 38, 40, 15, 16, 18, 22, 37, 13 };
#  2^26-1 = 67108863 all out
# Output for GPIO 7,8,9,10,11,22,23,24,25 => 2^(5,6,7,8,9, 20,21,22,23)111100000000001111100000b = 15729632
Message has been deleted

Masoun Mardini

unread,
Oct 21, 2017, 4:21:14 PM10/21/17
to Machinekit
"Can you help me to found the right way to set only the pin : 16,18,19,21,23,35 as input and all other as output please?
#rpi2_gpios[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 };
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1 = 67105963

So your dir should be equal to 67105963 to be able to use these pins as inputs

Masoun Mardini

unread,
Oct 21, 2017, 4:24:05 PM10/21/17
to Machinekit
or you can directly write binary numbers in loading hal_gpio comp

loadrt hal_gpio dir=0x11111111111111010010101011
or
loadrt hal_gpio dir=67105963

Antonio Bello

unread,
Oct 23, 2017, 4:19:00 AM10/23/17
to Machinekit
Hi Mardini,
Thanks a lot, I'm able to set my input gpio pins now!
Only two doubts yet:

1) How can I set the "not" one? If I use

net estop-ext       <= hal_gpio.pin-16-in-not

the machinekit tell me that hal_gpio.pin-16-in-not not exists

2) How can I set the reset of pin? If I use

setp hal_gpio.pin-05-out-reset 1

the machinekit tell me that hal_gpio.pin-05-out-reset not exists

Thanks in advance for your assistance.

Antonio

Masoun Mardini

unread,
Oct 26, 2017, 3:27:34 PM10/26/17
to Machinekit
Hi Antonio,
As far as my understanding hal_gpio does not has not nor reset (as such Parport or Mesa), but you can adapt "not" function in your hal file and use not function to invert pins you need

example: 
add the following lines to your hal file
#####################################
loadrt
not count=3 # that means we need to invert 3 pins using alias not.0. and not.1. and not.2 each not has input (in) and output (out) so the first not  input will be something like this (not.0.in) and the output will be (not.0.out)
addf
not.0  servo-thread   #Man pages have something like not.all but when I test it I couldn't find it
addf
not.1  servo-thread.  # instead of adding each function in a separate line
addf
not.2  servo-thread


net  dummy16
not.0.in hal_gpio.pin.16-in             #then you can use the inverted pin value dummy16 = signal name does not effect our program you can name it what ever you like
net  estop
-ext <= not.0.out                          # you can use not.0.out to the signal you want
#####################################

As for reset you can simply send command to the output it self.
Reply all
Reply to author
Forward
0 new messages