lut5 multiple functions on same inputs

More
03 Oct 2018 07:09 #118390 by smalla
Hi all,

I ran into a problem trying to simplify a user interface, which is a simple rotary switch and a button. Depending on the switch position and button pressing, it should do rather different things.

lut5 is a good choice to implement the logic, but uses quite a lot of code, as one lut5 name can only process one function.

it is possible to write a switch-case like code somehow?
or is it possible to modify lut5 to accept more than one function? Something like lut5.0.0x01.out will produce output for the 0x01 truth table, and lut5.0.0x567013a.out will be true if 0x567013a is true.
Function is defined on the output line. Or this is not possible as linuxcnc-s logic is preventing it.
But Im sure multiple functions could be defined with multiple outs.
Is there a better way?

Thanks

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

More
03 Oct 2018 13:44 - 03 Oct 2018 13:45 #118403 by Todd Zuercher
To be honest I'd probably just use a bunch of and2 components to do what you are trying to do. Use one and2 for each of the knob outputs, then connect all of the other inputs of the and2s to the output of the button.
Last edit: 03 Oct 2018 13:45 by Todd Zuercher.

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

More
03 Oct 2018 14:10 #118409 by smalla
OK the rotary switch is not that simple, it uses gray code to encode 16 positions. 4 wires + one for the button. Thats five inputs. With and2 it would be a way too complex.

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

More
03 Oct 2018 15:55 #118415 by Todd Zuercher
I don't know then, looks like your options are:
-use a bunch of lut5s
-use ladder logic (Classicladder)
-write a comp

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

More
03 Oct 2018 16:07 #118416 by Todd Zuercher
It seems as though there should be a way to do it with a couple of select8s and a couple of other components. But I don't have the time to think that all through.

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

More
03 Oct 2018 16:22 - 03 Oct 2018 16:23 #118417 by Todd Zuercher
I couldn't stop thinking about it, 2 select8s weighted_sum and 2 and2s should get it.
Connect 3 of the signals from your switch to the weighted_sum inputs (so you get an integer of 0-7 for all of your switch settings. Connect the output of the weighted_sum to both of the select8s s32 inputs. The 4th output from your switch use both the out and the out-not, connect one of those to first input of each and2. Connect your button output to the other input of each of the and2s. And finally connect the outputs of the and2s to the enables of the select8s (one to each).
Last edit: 03 Oct 2018 16:23 by Todd Zuercher.

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

More
04 Oct 2018 07:31 #118431 by smalla
Thanks. I never used select8 and weighted_sum, so need to understand them first to understand what You wrote :)

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

More
04 Oct 2018 12:34 #118440 by Todd Zuercher
The weighted_sum is used to input an array of bits and convert that to an s32 number.
linuxcnc.org/docs/devel/html/man/man9/weighted_sum.9.html
The select 8 takes an s32 value from 0-7 and sets one of 8 bits true.
linuxcnc.org/docs/devel/html/man/man9/select8.9.html

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

More
04 Oct 2018 13:34 #118441 by andypugh
How many gray-code bits are there? do you need bit-mode outputs or something more interesting?

For 4 bits of gray-code and a button you could put the button onto one of the bits.
For more bits of gray-code it is more difficult.

The various mux components are another option.
linuxcnc.org/docs/2.7/html/man/man9/mux_generic.9.html
You can set one of those up with as many input bits as you want, though you then need a "setp" for every possibly input combination. But the output value can be int or float, rather than just bit.

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

Time to create page: 0.125 seconds
Powered by Kunena Forum