Read input go to subroutine
09 Oct 2016 21:00 #81475
by tjones
Read input go to subroutine was created by tjones
Hi Guys,
I am setting up an automation cell with my CNC lathe. I am creating a separate HMI unit, probably with a raspberry pi or beaglebone black, the specifics have yet to be determined. What I would like to do is send an output from the HMI unit and read it from linuxcnc. There will be many different subroutines for all the different parts, upwards of 30 different subroutines. I was thinking of a serial connection or ethernet, something that will send a binary number that I can read and call the subroutines based on the number it reads. I am not the strongest programmer, but I have used subroutines before, calling them in and out of program. But I am not sure how to read an input and based on that input jump to a specific subroutine. I am in the development of the cell, so hardware and connections can be anything at this point, but I am mainly interested in the input reading and mapping that to a subroutine, without having 30+ connections for each subroutine.
Thanks,
I am setting up an automation cell with my CNC lathe. I am creating a separate HMI unit, probably with a raspberry pi or beaglebone black, the specifics have yet to be determined. What I would like to do is send an output from the HMI unit and read it from linuxcnc. There will be many different subroutines for all the different parts, upwards of 30 different subroutines. I was thinking of a serial connection or ethernet, something that will send a binary number that I can read and call the subroutines based on the number it reads. I am not the strongest programmer, but I have used subroutines before, calling them in and out of program. But I am not sure how to read an input and based on that input jump to a specific subroutine. I am in the development of the cell, so hardware and connections can be anything at this point, but I am mainly interested in the input reading and mapping that to a subroutine, without having 30+ connections for each subroutine.
Thanks,
Please Log in or Create an account to join the conversation.
09 Oct 2016 21:51 #81485
by andypugh
Replied by andypugh on topic Read input go to subroutine
This is something that the Machinekit chaps seem to do a lot, so you could ask them.
The options with LinuxCNC probabaly come down to:
1) Use individual GPIO pins. Easy. Ugly.
2) linuxcnc.org/docs/2.7/html/man/man1/linuxcncrsh.1.html
The options with LinuxCNC probabaly come down to:
1) Use individual GPIO pins. Easy. Ugly.
2) linuxcnc.org/docs/2.7/html/man/man1/linuxcncrsh.1.html
Please Log in or Create an account to join the conversation.
09 Oct 2016 22:00 #81486
by newbynobi
Replied by newbynobi on topic Read input go to subroutine
Or write a python comp and start from there different files,
Qick and easy:-)
Norbert
Qick and easy:-)
Norbert
Please Log in or Create an account to join the conversation.
10 Oct 2016 00:50 #81492
by tjones
Replied by tjones on topic Read input go to subroutine
I was thinking of using 5 input lines and using them as binary code, so I don't need 32 individual inputs. However if I do that, I think the code will be really messy, because i think I will have a lot of if statements for every case. As far as the python comp, is there a good source or examples for how to set something like that up? I am not the best programmer, so seeing examples helps a lot. LinuxCNCCrash looks like a great option to feed it text based files, would be an easier way to run it. Can you run crash alongside AXIS or some other visual display of what the machine is doing?
Please Log in or Create an account to join the conversation.
10 Oct 2016 07:48 #81496
by newbynobi
Replied by newbynobi on topic Read input go to subroutine
Please Log in or Create an account to join the conversation.
10 Oct 2016 12:02 - 10 Oct 2016 12:03 #81501
by andypugh
We don't seem to have a de-multiplexer HAL component, but one would be useful and rather simple.
Docs on custom components are here: linuxcnc.org/docs/2.7/html/hal/comp.html
Replied by andypugh on topic Read input go to subroutine
I was thinking of using 5 input lines and using them as binary code, so I don't need 32 individual inputs. However if I do that, I think the code will be really messy, because i think I will have a lot of if statements for every case.
We don't seem to have a de-multiplexer HAL component, but one would be useful and rather simple.
component demux "5 input demux";
pin in bit sel[5] "input bits"
pin out bit out[32] "output bits"
;;
static int old_pin = 0;
int new_pin = sel[0] + sel[1]<<1 + sel[2]<<2 + sel[3]<<3 + sel[4]<<4;
if (old_pin != new_pin){
out[old_pin] = 0;
out[new_pin] = 1;
old_pin = new_pin;
}
Docs on custom components are here: linuxcnc.org/docs/2.7/html/hal/comp.html
Last edit: 10 Oct 2016 12:03 by andypugh.
Please Log in or Create an account to join the conversation.
Time to create page: 0.113 seconds