(SOLVED) Max Velocity Selector Switch

More
4 years 10 months ago #230028 by spumco
Thanks gents, finally got it sorted out after working through the scaling

Here's the hal code for a 5-position selector switch:

setp halui.max-velocity.direct-value true
setp halui.max-velocity.scale [see below]
setp mux16.0.in00 [value] #triggered by switch position 1 (unconnected, no input)
setp mux16.0.in01 [value] #triggers mux16.sel0
setp mux16.0.in02 [value] #triggers mux16.sel1
setp mux16.0.in04 [value] #triggers mux16.sel2
setp mux16.0.in08 [value] #triggers mux16.sel3

# position 1 of the selector switch is left unconnected as a 'dead' position.  That will make the first switch position 'off'
net MAXVEL_1            <=  [HMOT](CARD0).7i84.0.1.input-23
net MAXVEL_1            =>  mux16.0.sel0
net MAXVEL_2            <=  [HMOT](CARD0).7i84.0.1.input-22
net MAXVEL_2            =>  mux16.0.sel1
net MAXVEL_3            <=  [HMOT](CARD0).7i84.0.1.input-21
net MAXVEL_3            =>  mux16.0.sel2
net MAXVEL_4            <=  [HMOT](CARD0).7i84.0.1.input-20
net MAXVEL_4            =>  mux16.0.sel3
net MAXVEL_IN           <=  mux16.0.out-s
net MAXVEL_IN           =>  halui.max-velocity.counts

GOTCHA'S:
  • The mux16.N.inXX values must be edited if the MAX_VELOCITY value in the INI file is changed.
  • The .in00-inXX pins only react to whole numbers.  This means it's hard to get exact desired max velocity numbers, but it's close enough for a global override.
  • The max velocity briefly drops to zero during switch changes. This drop to zero speed may cause issues on particular machines.  Mux16.N.suppress-no-input pin eliminates the drop, but you lose the 'dead' position with zero output.  You will only have 4 effective positions (speeds) if you aren't multiplexing. Perhaps 0%, 5%, 25%, and 100% would be acceptable for most people.
  • Not sure how this affects QtPyVcp GUI's (Probe Basic specifically), as the PB devs have added a MAX_LINEAR_VELOCITY and MAX_ANGULAR_VELOCITY setting. This scheme may need fine-tuning once I start moving my 4th axis around.

For an INI file MAX_VELOCITY = 1.5 (90ipm, my test speed) I wound up with the following values:

EXAMPLE 1 (mux16.N.suppress-no-input False):
halui.max-velocity.scale = 0.1
.in00 = 0 [0ipm]
.in01 = 1 [6ipm]
.in02 = 2 [12ipm]
.in04 = 7 [42ipm]
.in08 = 15 [90ipm]

EXAMPLE 2 (mux16.N.suppress-no-input True):
halui.max-velocity.scale = 0.1
.in01 = 0 [0ipm]
.in02 = 1 [6ipm]
.in04 = 4 [24ipm]
.in08 = 15 [90ipm]

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

More
4 years 10 months ago #230029 by chris@cnc
Here my mpg.hal. I use encoder switches to select rapid feed, override, MPG increments, and axis select. But i must load this hal file over the postguit_call_list.hal. If not, was the position of feed override always 100%. Doesn't matter what show the switch.
 

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

More
4 years 10 months ago - 4 years 10 months ago #230109 by cmorley
The whole numbers problem::

multiply the S32 by 10
divide the scale by 10

1.55 needed

scale = .01
.in08 = 155

155 X .01 = 1.55

My VFD used this trick with modbus (that had no float capability)
Last edit: 4 years 10 months ago by cmorley. Reason: Fixed my bad math
The following user(s) said Thank You: spumco

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

More
4 years 10 months ago #230124 by cmorley
Some bad math there but I'm sure you get the idea :)
The following user(s) said Thank You: tommylight

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

Time to create page: 0.378 seconds
Powered by Kunena Forum