Configuring axis gui "axis radio buttons"

More
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.

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

More
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.

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

More
12 Oct 2017 22:49 - 12 Oct 2017 22:52 #100287 by andypugh

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  halui.spindle-override.direct-value
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 ..direct-value 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 parport.0.pin-11-in => halui.spindle-override.direct-value

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.
linuxcnc.org/docs/2.7/html/man/man9/mux2.9.html
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.
linuxcnc.org/docs/2.7/html/man/man9/mux_generic.9.html
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 => mux-gen.00.in-s32-00 
setp mux-gen.00.in-s32-01 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 parport.0.pin-10-in => halui.feed-override.direct-value => 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

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

More
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)

Attachments:

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

Time to create page: 0.094 seconds
Powered by Kunena Forum