Configuring axis gui "axis radio buttons"

11 Oct 2017 23:29 #100245 by andypugh
An encoder uses an A and B channel in quadrature. Those are simply those two channels being sent to the module that counts encoder pulses from the parallel port.

It is entirely possible to make the push-button of the encoder set feed-rate to 100%, but it has taken dozens of messages to get this far.
12 Oct 2017 08:38 #100260 by Clive s

but it has taken dozens of messages to get this far.

Is there a problem with this? I did not realise that there was a number on this so that I have gone back and counted the reply messages (8) from where I was asking about the pots.

I am near 73 and never done any programming but have done a lot of reading and really am trying to help myself to learn the HAL files this is why I asked the last question. Cryptic answers are very hard to follow for me.

Having said that I do appreciate your time. Thanks.
12 Oct 2017 22:49 - 12 Oct 2017 22:52 #100287 by andypugh

Clive s wrote: Is there a problem with this?

Sorry, it was past midnight and I wasn't really in the mood to think hard.

The relevant pins for spindle-override are:
 bit   IN halui.spindle-override.count-enable
s32   IN halui.spindle-override.counts
bit   IN halui.spindle-override.decrease
bit   IN
bit   IN  halui.spindle-override.increase
float IN  halui.spindle-override.scale
float OUT halui.spindle-override.value

With a scale of 0.01 it takes 100 counts to move the slider from 0 to 100%.
If you slide it back to zero in the GUI, then another 100 counts (to 200) will move it back to 100%

However, if the pin is set to true then it takes absolute rather than relative counts. If counts is 50 and direct-value is set nothing happens, but then as soon as the counts changes to 51 it will go to 51 x scale = 51%.

So, on button press we need to set counts to 100 and also set direct-value to true.

Setting direct-value is easy, we just connect that pin to whatever input pin is operated by the button press.
net spindle-direct =>

But, setting the counts to 100 is a little bit harder. There is a HAL component called mux2 that can help here. It outputs one of two inputs depending in the state of the control input.
But, rather annoyingly, that has an input and output type of "float" and the counts pin is S32[1]
There is an alternative, "mux-generic" where you can select the data type of the inputs and outputs.
It's a bit more difficult to use, but rather more adaptable.
We need to load it:
loadrt mux_generic config="ss2,ss2"
And then it needs to be added to a realtime thread, otherwise it won't get run. You get the function name from the manpage linked above. Note that it is mux_generic to load the file, but mux-gen in the HAL pins. (because file names can't contain "-")
addf mux-gen.00 servo-thread
addf mux-gen.01 servo-thread
We will use 00 for feed-rate and 01 for spindle-rate
We want it to pass normal counts when not "energised" and 100 counts when "energised"
delete your current line
net   feed-rate   <=   encoder.3.counts
Then add
net feed-counts  encoder.3.counts => 
setp 100
net feed-rate mux-gen.00.out-s32
And then make the mux operate at the same time as the direct-value:
net feed-100 => => mux-gen.00.sel-bit-00

If you add that to the HAL file you will find that it almost, but not quite works.
What happens is that the override goes to zero, but as soon as the button is released the slider bounces back to the encoder/potentiometer value. (This is a timing thing, when the counts goes from 100 to the new value that is seen as a delta in the counts from 100 to the real encoder counts, and alters the slider again.)
The answer is to set halui.feed-override.count-enable to 0 for a moment when the apparent counts changes. I am still thinking about the best way to do that. If Halui ran in the servo thread it would be fairly easy, as 1mS delay (one thread interval) would be enough. But it doesn't.

[1] float is "floating point" like 3.1415, it can (approximately) represent any real number. S32 is signed 32-bit integer, representing whole numbers from -2,147,483,648 to +2,147,483,647
Last edit: 12 Oct 2017 22:52 by andypugh.
The following user(s) said Thank You: Clive s
13 Oct 2017 10:16 #100318 by Clive s
Well, you have certainly given me something to think about. Thanks for such a detailed reply.

Its a pity that this tutorial can't be made as a sticky as I am sure it will help a lot of people with the inner workings of Lcnc.

With your help I have managed to setup 3 mpg's and 1 alps encoder/pot to move a slider connected to two PP's on the bench. The goal is to set this lot up with the 7i76 mesa card next. ( I know about the pins 16,17,18,18 on the card)

Time to create page: 0.116 seconds
Powered by Kunena Forum