Overrides Hal example

More
13 Apr 2016 20:56 #73252 by Mtndrew77
I'm adding a spindle and feedrate override to my machine. The spindle override is a potentiometer with wiper connected to input 0 on my 7i76e, and the feedrate override is a 23 position selector switch with 5 outputs. I have those connected to inputs 16 and 20. Does anyone have a hal file example of something similar they could share?
Attachments:

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

More
14 Apr 2016 04:23 #73270 by cmorley
Replied by cmorley on topic Overrides Hal example
Cut from pncconf config:
Gives you (one) the general idea of how to do this with HALUI.
# --- FO-INCR-A ---
net fo-incr-a     <=  hm2_5i25.0.7i76.0.0.input-20

# --- FO-INCR-B ---
net fo-incr-b     <=  hm2_5i25.0.7i76.0.0.input-21

# --- FO-INCR-C ---
net fo-incr-c     <=  hm2_5i25.0.7i76.0.0.input-22

# --- FO-INCR-D ---
net fo-incr-d     <=  hm2_5i25.0.7i76.0.0.input-23

# connect feed overide increments - switches

    setp halui.feed-override.count-enable true
    setp halui.feed-override.direct-value true
    setp halui.feed-override.scale .01
net feedoverride-incr   =>  halui.feed-override.counts
net fo-incr-a           =>  foincr.sel0
net fo-incr-b           =>  foincr.sel1
net fo-incr-c           =>  foincr.sel2
net fo-incr-d           =>  foincr.sel3
net feedoverride-incr   <=  foincr.out-s
    setp foincr.debounce-time      0.200000
    setp foincr.use-graycode      False
    setp foincr.suppress-no-input False
    setp foincr.in00          0.000000
    setp foincr.in01          5.000000
    setp foincr.in02          10.000000
    setp foincr.in03          25.000000
    setp foincr.in04          50.000000
    setp foincr.in05          75.000000
    setp foincr.in06          90.000000
    setp foincr.in07          100.000000
    setp foincr.in08          110.000000
    setp foincr.in09          125.000000
    setp foincr.in10          100.000000
    setp foincr.in11          150.000000
    setp foincr.in12          165.000000
    setp foincr.in13          180.000000
    setp foincr.in14          190.000000
    setp foincr.in15          200.000000

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

More
14 Apr 2016 13:28 #73298 by andypugh
Replied by andypugh on topic Overrides Hal example

spindle override is a potentiometer with wiper connected to input 0 on my 7i76e, and the feedrate override is a 23 position selector switch with 5 outputs


So, there is an analogue voltage for spindle override and a 5-bit encoded feed override.

Your HAL / INI config will need to put the 7i76 into analogue input mode for the spindle.

In the HAL file. :
loadrt hm2_eth board_ip="192.168.1.121" config="firmware=hm2/7i76/7i76e.BIT num_encoders=1 num_pwmgens=0 num_stepgens=2 sserial_port_0=10xxxx"

You will then get some new pins, analogue inputs on IO pins 0 to 3.

Then
loadrt scale names=spindle-scale
addf spindle-scale servo-thread
...
net spindle-analogue hm2_5i25.0.7i76.0.0.analogin0 => spindle-scale.in
net spindle-override spindle-scale.out  => halui.spindle-override.value
setp halui.spindle-override.direct-value 1
setp spindle-scale.scale 1
setp spindle-scale.offset -2.5

The example given by Chris seems to be using a mux-16 called "fo-incr", but you seem to have more that 16 options so need to use mux_generic
linuxcnc.org/docs/2.7/html/man/man9/mux_generic.9.html

For the feed-override I would start like this because it isn't clear how the switch is encoded.
loadrt mux_generic config="ff24"
addf mux_gen.00 servo-thread
...
net feed-sel-0 hm2_5i25.0.7i76.input-16 => mux-gen.00.sel-bit-000
net feed-sel-1 hm2_5i25.0.7i76.input-17 => mux-gen.00.sel-bit-001
net feed-sel-2 hm2_5i25.0.7i76.input-18 => mux-gen.00.sel-bit-002
net feed-sel-3 hm2_5i25.0.7i76.input-19 => mux-gen.00.sel-bit-003
net feed-sel-4 hm2_5i25.0.7i76.input-20 => mux-gen.00.sel-bit-004

setp mux-gen.00.in-float-00 0
setp mux-gen.00.in-float-01 1
setp mux-gen.00.in-float-02 2
setp mux-gen.00.in-float-03 3
setp mux-gen.00.in-float-04 4
... and so on.

The reason to set the inputs with numbers to match the input index is that you can then set up a halmeter on the mux-gen.00.out-float pin and see which input needs to be set to correspond to each switch position.
The switch is likely to be gray-code encoded, so the indexes will seem to jump about.

The rest of the config will be as Chris said.
The following user(s) said Thank You: ts14

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

More
14 Apr 2016 15:28 #73309 by Mtndrew77
Replied by Mtndrew77 on topic Overrides Hal example
Well I see my first problem now was that I was in the wrong mode to get the analogue inputs. I could of swore I set that in PNC config,but
maybe not. I'm still struggling to wrap my head around the Mux Component. Does this sort of work like a switch statement in C? with the 24 in config="ff24" representing the number of different possible cases that determine the output of mux-gen.00.out?
Sorry if I'm being confusing, but like I said I'm still trying to wrap my head around it

Thanks

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

More
15 Apr 2016 10:08 #73339 by andypugh
Replied by andypugh on topic Overrides Hal example

I'm still struggling to wrap my head around the Mux Component. Does this sort of work like a switch statement in C? with the 24 in config="ff24" representing the number of different possible cases that determine the output of mux-gen.00.out?


It's a multiplexer, many inputs to one output. The "select" inputs choose which input is passed to the output.

mux2 is the simplest, two inputs and one output, the "select" bit switches between them.
mux4 has 2 select bits. We got up to mux16 before I decided that we just needed a general-purpose one that could also handle other data types.

The inputs can be set to constant values, or they can be linked to the output pins of other components.

I think my example might have a flaw, you probably need to use "ff32" so that it creates the right number of select bits. I think ff24 will only give you the integer indexer.
The following user(s) said Thank You: Mtndrew77

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

More
15 Apr 2016 13:05 #73345 by Mtndrew77
Replied by Mtndrew77 on topic Overrides Hal example
Okay, that makes more sense. 5 bits can have 32 possible combinations. So I guess in my mind it
is sort of like a switch statement then. The light bulb just went on over my head--Thanks for the help!

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

More
15 Apr 2016 13:16 #73346 by andypugh
Replied by andypugh on topic Overrides Hal example
I think of it as creating an integer from the bits, then using that as the index of an array of inputs.
Interestingly, that isn't how the less general-purpose mux components do it, they look like this:

github.com/LinuxCNC/linuxcnc/blob/master...components/mux4.comp

mux_generic is a lot more complicated :-)
github.com/LinuxCNC/linuxcnc/blob/master...onents/mux_generic.c

Though the vast majority of that code only runs at setup time.

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

More
17 Apr 2016 20:54 #73505 by Mtndrew77
Replied by Mtndrew77 on topic Overrides Hal example
Okay not sure what I'm doing wrong here. Looks like its failing to create the select bit pin. Got any ideas?


Debug file information:
Note: Using POSIX realtime
./spindletest.hal:296: Pin 'mux-gen.00.sel-bit-000' does not
Attachments:

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

More
17 Apr 2016 21:19 #73506 by andypugh
Replied by andypugh on topic Overrides Hal example

Pin 'mux-gen.00.sel-bit-000' does not


Sorry, my mistake, the sel-bit-00 etc pins only have 2 digits.

I was going by the manpage, not a trial run.
(that still makes it my fault, I wrote the manpage :-)

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

More
17 Apr 2016 23:11 #73507 by Mtndrew77
Replied by Mtndrew77 on topic Overrides Hal example
One down, but now I get this one

Debug file information:
Note: Using POSIX realtime
./spindletest.hal:302: parameter or pin 'mux-gen.00.in-s32-00' not found
5789
Attachments:

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

Time to create page: 0.105 seconds
Powered by Kunena Forum