Binary Fan out HAL function?
30 Mar 2014 04:57 #45388
by WRC_CNC
Binary Fan out HAL function? was created by WRC_CNC
Is there such a thing?
I want to give a PLC the tool number in BCD for tool change purposes.
So I need to take the tool number, Convert to BCD, Then output that on 4 outputs.
Thanks
I want to give a PLC the tool number in BCD for tool change purposes.
So I need to take the tool number, Convert to BCD, Then output that on 4 outputs.
Thanks
Please Log in or Create an account to join the conversation.
30 Mar 2014 07:16 #45396
by andypugh
I don't think there is, which does seem something of an oversight.
In Master there is "mux_generic" and 4 of those with bit-outputs could be configured to do the job.
"weighted_sum" solves the inverse problem.
It would be a very easy component to write, have a look at the comp docs:
www.linuxcnc.org/docs/devel/html/hal/comp.html
Might even work (can't test it here)
A component for inclusion in the project would need docs and a way to specify number of bits, but you can probably sudo comp --install in2bit.comp and get what you need.
Replied by andypugh on topic Binary Fan out HAL function?
Is there such a thing?
I don't think there is, which does seem something of an oversight.
In Master there is "mux_generic" and 4 of those with bit-outputs could be configured to do the job.
"weighted_sum" solves the inverse problem.
It would be a very easy component to write, have a look at the comp docs:
www.linuxcnc.org/docs/devel/html/hal/comp.html
component int2bit;
pin out bit pin0;
pin out bit pin1;
pin out bit pin2;
pin out bit pin3;
pin in bit in;
;;
pin0 = in&0x01;
pin1 = in&0x02;
pin2 = in&0x04;
pin3 = in&0x08;
Might even work (can't test it here)
A component for inclusion in the project would need docs and a way to specify number of bits, but you can probably sudo comp --install in2bit.comp and get what you need.
Please Log in or Create an account to join the conversation.
01 Apr 2014 03:58 #45468
by andypugh
Replied by andypugh on topic Binary Fan out HAL function?
I asked on the IRC and a suggestion was that you can do this in Classic Ladder, which is the software PLC that is built-in to LinuxCNC.
In fact, you might be able to do away with the external PLC.
www.linuxcnc.org/docs/html/ladder/ladder_intro.html
In fact, you might be able to do away with the external PLC.
www.linuxcnc.org/docs/html/ladder/ladder_intro.html
Please Log in or Create an account to join the conversation.
01 Apr 2014 06:34 #45473
by WRC_CNC
Replied by WRC_CNC on topic Binary Fan out HAL function?
Ok, thanks for checking into that!,
I just wanted an external PLC because the machine im working on has like 45 inputs and 16 outs,
Most of these IO is not needed by linuxcnc so I was going to program it in a PLC, Plus I understand PLC's
I cant say that about LinuxCNC yet
Thanks for the help, I will read up on the PLC BFO
I just wanted an external PLC because the machine im working on has like 45 inputs and 16 outs,
Most of these IO is not needed by linuxcnc so I was going to program it in a PLC, Plus I understand PLC's
I cant say that about LinuxCNC yet
Thanks for the help, I will read up on the PLC BFO
Please Log in or Create an account to join the conversation.
01 Apr 2014 16:41 #45483
by andypugh
I will probably add the function you first asked for in the next few days anyway.
Replied by andypugh on topic Binary Fan out HAL function?
I understand PLC's
I cant say that about LinuxCNC yetO
I will probably add the function you first asked for in the next few days anyway.
Please Log in or Create an account to join the conversation.
03 Apr 2014 05:10 #45517
by andypugh
Replied by andypugh on topic Binary Fan out HAL function?
The new function is now pushed to V2.5.
You would need to update tomorrow to get it, following the instructions here:
buildbot.linuxcnc.org
You would need to update tomorrow to get it, following the instructions here:
buildbot.linuxcnc.org
Please Log in or Create an account to join the conversation.
03 Apr 2014 05:53 #45522
by WRC_CNC
Replied by WRC_CNC on topic Binary Fan out HAL function?
Cool, Thanks I'll use it.
Is this the structure then:
component int2bit;
pin out bit pin0;
pin out bit pin1;
pin out bit pin2;
pin out bit pin3;
pin in bit in;
Thanks
Is this the structure then:
component int2bit;
pin out bit pin0;
pin out bit pin1;
pin out bit pin2;
pin out bit pin3;
pin in bit in;
Thanks
Please Log in or Create an account to join the conversation.
03 Apr 2014 06:00 #45523
by andypugh
Not quite.
The entirety of the file is here:
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...fs/heads/v2.5_branch
Replied by andypugh on topic Binary Fan out HAL function?
Cool, Thanks I'll use it.
Is this the structure then:
Not quite.
The entirety of the file is here:
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...fs/heads/v2.5_branch
Please Log in or Create an account to join the conversation.
03 Apr 2014 17:50 #45533
by andypugh
Replied by andypugh on topic Binary Fan out HAL function?
It has now appeared in the docs, so presumably the component itself is now available if you get the very latest release from the buildbot.
manual page: www.linuxcnc.org/docs/html/man/man9/bitslice.9.html
Note that tool number is a signed integer, and this component takes an unsigned integer, so usage would be.
(for a parallel port, edit the output pins to suit what you are using)
manual page: www.linuxcnc.org/docs/html/man/man9/bitslice.9.html
Note that tool number is a signed integer, and this component takes an unsigned integer, so usage would be.
(for a parallel port, edit the output pins to suit what you are using)
#load one bitslice with 4 outputs
loadrt bitslice count=1 personality=4
#load a convertor
loadrt conv_s32_u32 count=1
#add them to the servo thread so that they actually do something
addf bitslice.0 servo-thread
addf conv_s32_u32.0 servo-thread
#connect it up
net toolnumber iocontrol.0.tool-prep-number => conv_s32_u32.0.in
net unsigned-toolnumber conv_s32_u32.0.out => bitslice.0.in
net bit0 bitslice.0.out-00 => parport.0.pin-00-out
net bit1 bitslice.0.out-01 => parport.0.pin-01-out
net bit2 bitslice.0.out-02 => parport.0.pin-02-out
net bit3 bitslice.0.out-03 => parport.0.pin-03-out
Please Log in or Create an account to join the conversation.
Moderators: cncbasher
Time to create page: 0.081 seconds