halui.spindle−override.counts - change every 10%

More
28 Oct 2019 21:20 #149005 by Cynas
Hello, I need to change the value exactly every 10%.
I have a 13 position switch with variable resistance connected to analogin0. The resistance value does not change linearly.

spindle-scale ->> conv-float-s32
switch position 1 -> spindle-scale = 0
switch position 2 -> spindle-scale = 1
switch position 3 -> spindle-scale = 3
switch position 4 -> spindle-scale = 4
switch position 5 -> spindle-scale = 6
switch position 6 -> spindle-scale = 7
switch position 7 -> spindle-scale = 9
switch position 8 -> spindle-scale = 11
switch position 9 -> spindle-scale = 12
switch position 10 -> spindle-scale = 14
switch position 11 -> spindle-scale = 17
switch position 12 -> spindle-scale = 20
switch position 13  -> spindle-scale = 23

Resolution can be increased using scale.gain.

How should I write it down?
spindle-scale = 0-----> counts 0
spindle-scale = 1-----> counts 2
spindle-scale = 2-----> counts 4
..................
spindle-scale = 9-----> counts 16
..................

What HAL component should I use?

Currently, everything works only the value does not change lines.

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

More
28 Oct 2019 21:52 #149009 by cmorley
Are you using halui.spindle-override.direct-value ?
In the problem converting arbitrary input steps to exact discreet steps ?
Can you share the HAL code you have ?

Chris

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

More
28 Oct 2019 22:24 - 28 Oct 2019 22:32 #149012 by Cynas
loadrt conv_float_s32 count=1
loadrt scale names=spindle-scale
addf spindle-scale servo-thread
addf conv-float-s32.1 servo-thread


setp halui.spindle-override.direct-value false
setp halui.spindle-override.count-enable true
setp spindle-scale.gain 12
setp spindle-scale.offset 0
setp halui.spindle-override.scale 0.004347826086956521

net spindle-analogue hm2_7i76e.0.7i76.0.0.analogin0 => spindle-scale.in
net spindle-convert spindle-scale.out conv-float-s32.1.in
net spindle-override conv-float-s32.1.out  halui.spindle-override.counts

I would like to assign specific values to a specific switch position.
switch position 1 -> override = 30%
switch position 2 -> override = 40%
switch position 3 -> override = 50%
switch position 4 -> override = 60%
..............................
switch position 12 -> override = 140%
switch position 13  ->  override = 150%
Last edit: 28 Oct 2019 22:32 by Cynas.

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

More
28 Oct 2019 22:32 #149013 by cmorley
set direct-value to true
then adjust halui.spindle-override.scale to suit

Chris
The following user(s) said Thank You: Cynas

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

More
28 Oct 2019 22:39 #149014 by Cynas
Thank you!
I'll check it tomorrow.

I would like to assign specific values to a specific switch position.
switch position 1 -> override = 30%
switch position 2 -> override = 40%
switch position 3 -> override = 50%
switch position 4 -> override = 60%
..............................
switch position 12 -> override = 140%
switch position 13  ->  override = 150%

I'm afraid the values will not increase linearly.

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

More
28 Oct 2019 22:44 #149015 by cmorley
look at the lincurve component. I haven't used it but I think it will do what you want.
(linearlize the float input)

a buch of window comparators going to a mux would work too

Andy P will probably chime in - he is very good at this sort of thing.


Chris
The following user(s) said Thank You: Cynas

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

More
28 Oct 2019 22:54 #149016 by Cynas
I would need to check the results to compare it with the given range and then if true send a specific value to halui.spindle-override.counts
example
spindle-scale  = x

x<2  --> y =30%
2<x<5    ->> y= 40%
................
...............

is there any hall component?

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

More
28 Oct 2019 22:59 - 28 Oct 2019 22:59 #149018 by cmorley
Last edit: 28 Oct 2019 22:59 by cmorley.

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

More
29 Oct 2019 16:17 #149062 by Cynas
I did it and it works correctly.

Maybe someone will be useful as an example.
Control spindle 30-150%
loadrt lincurve personality=13
addf lincurve.0 servo-thread

setp halui.spindle-override.direct-value true
setp halui.spindle-override.count-enable true
setp spindle-scale.gain 1
setp spindle-scale.offset 0
setp halui.spindle-override.scale 0.1

net spindle-analogue hm2_7i76e.0.7i76.0.0.analogin0 => spindle-scale.in
net spindle-convert spindle-scale.out conv-float-s32.1.in
net spindle-override1 conv-float-s32.1.out conv-s32-float.0.in
net spindle-raw conv-s32-float.0.out  => lincurve.0.in


setp lincurve.0.x-val-00 0
setp lincurve.0.y-val-00 3
setp lincurve.0.x-val-01 1
setp lincurve.0.y-val-01 4
setp lincurve.0.x-val-02 3
setp lincurve.0.y-val-02 5
setp lincurve.0.x-val-03 4
setp lincurve.0.y-val-03 6
setp lincurve.0.x-val-04 6
setp lincurve.0.y-val-04 7
setp lincurve.0.x-val-05 7
setp lincurve.0.y-val-05 8
setp lincurve.0.x-val-06 9
setp lincurve.0.y-val-06 9
setp lincurve.0.x-val-07 11
setp lincurve.0.y-val-07 10
setp lincurve.0.x-val-08 12
setp lincurve.0.y-val-08 11
setp lincurve.0.x-val-09 14
setp lincurve.0.y-val-09 12
setp lincurve.0.x-val-10 17
setp lincurve.0.y-val-10 13
setp lincurve.0.x-val-11 20
setp lincurve.0.y-val-11 14
setp lincurve.0.x-val-12 23
setp lincurve.0.y-val-12 15


net spindle-corrected-lincurve lincurve.0.out => conv-float-s32.4.in
net spindle-override2 conv-float-s32.4.out  halui.spindle-override.counts

Thank you for your help
The following user(s) said Thank You: tommylight

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

Time to create page: 0.158 seconds
Powered by Kunena Forum