BCD or GRAY code to feed or spindle override

More
17 Sep 2012 23:32 #24341 by VNR
Hello,

Is there any hal component or source code to convert a bcd or gray code (4 input bits) to a float or unsigned integer output ?

I have a BCD (and a gray) rotary switch and i want to use it in the front panel to control the feed and speed override (connected to halui).
The conversion is not linear, is based on these tables:
Feed override table (4 bits): 1%, 2%, 5%, 10%, 20%, 40%, 50%, 60%, 80%, 90%, 95%, 100%, 105%, 110%, 120%. 130%
Speed override table: 50%, 55%, 60%, 65%, 70%, 75%, 80%, 85%, 90%, 95%, 100%, 105%, 110%, 115%, 120%, 125%

Other solutions are welcome ;)

Thanks you in advance,
VNR

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

More
17 Sep 2012 23:47 #24342 by andypugh
www.linuxcnc.org/docs/html/man/man9/mux16.9.html

Will do it.
You can either set the inputsup to suit your encoding, or set the gray-code option and see if that works….

if you need help making sense if it, just ask.

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

More
18 Sep 2012 12:19 #24357 by VNR
The counter works great ! Thanks you .

But now i have a new problem.

Touchy do not follow halui.feed-override.value at all. This value is always 0, but the screen shows 100%. I want to use touchy because i have a touch screen monitor.

I tried with Axis, always starts with 100%, don't matter what the rotary encoder position is.
I have to move the switch one position and then Axis starts to follows halui.feed-override.value.

--- HAL FILE ---

loadusr -Wn arduino python arduino.py

loadrt mux16 names=sp_ov,f_ov
#addf sp_ov panel-thread
#addf f_ov panel-thread
addf sp_ov servo-thread
addf f_ov servo-thread

setp f_ov.in00 0
setp f_ov.in01 1
setp f_ov.in02 2
setp f_ov.in03 5
setp f_ov.in04 10
setp f_ov.in05 25
setp f_ov.in06 50
setp f_ov.in07 75
setp f_ov.in08 90
setp f_ov.in09 95
setp f_ov.in10 100
setp f_ov.in11 105
setp f_ov.in12 110
setp f_ov.in13 120
setp f_ov.in14 130
setp f_ov.in15 140

net feed-ov-0 arduino.in.53 => f_ov.sel0
net feed-ov-1 arduino.in.52 => f_ov.sel1
net feed-ov-2 arduino.in.51 => f_ov.sel2
net feed-ov-3 arduino.in.50 => f_ov.sel3

setp halui.feed-override.count-enable TRUE
setp halui.feed-override.direct-value TRUE
net feed-ov-connect f_ov.out-s => halui.feed-override.counts
#La escala en 1 es 100%
setp halui.feed-override.scale 0.01

--- HALTCL (with Axis) ---

haltcl: show pin halui.feed-override
Component Pins:
Owner Type Dir Value Name
7 bit IN TRUE halui.feed-override.count-enable
7 s32 IN 105 halui.feed-override.counts <== feed-ov-connect
7 bit IN FALSE halui.feed-override.decrease
7 bit IN TRUE halui.feed-override.direct-value
7 bit IN FALSE halui.feed-override.increase
7 float IN 0.01 halui.feed-override.scale
7 float OUT 1.05 halui.feed-override.value

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

More
18 Sep 2012 12:27 #24360 by andypugh
VNR wrote:

I have to move the switch one position and then Axis starts to follows halui.feed-override.value.
setp halui.feed-override.count-enable TRUE


What happens with count-enable FALSE?

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

More
18 Sep 2012 14:33 #24370 by VNR

I have to move the switch one position and then Axis starts to follows halui.feed-override.value.
setp halui.feed-override.count-enable TRUE
What happens with count-enable FALSE?

Procedure:
1) Start Axis with: setp halui.feed-override.count-enable FALSE in hal file
2) move the switch and halui.feed-override.value follows the switch, but Axis doesn't change (always 100% in screen)
3) haltcl: setp halui.feed-override.count-enable TRUE
5) Axis doesn't change to the current halui.feed-override.value value
6) Move the switch and Axis now follows the halui.feed-override.value value

My own thinking is that Axis waits for an initial change in halui.feed-override.value to actualize the initial value of 100%. May be was writen with an incremental encoder in mind not an a absolute encoder.


In the other hand, I put in touchy.hal : net feed-ov-connect => touchy.wheel-counts
Touchy is working but not correctly, something is not working between Touchy and Halui:

haltcl: show pin halui.feed
Component Pins:
Owner Type Dir Value Name
7 bit IN TRUE halui.feed-override.count-enable
7 s32 IN 50 halui.feed-override.counts <== feed-ov-counts
7 bit IN FALSE halui.feed-override.decrease
7 bit IN TRUE halui.feed-override.direct-value
7 bit IN FALSE halui.feed-override.increase
7 float IN 0.01 halui.feed-override.scale
7 float OUT 1.12 halui.feed-override.value
HALUI is Wrong, Touchy also shows in screen 112%

7 s32 IN 100 halui.feed-override.counts <== feed-ov-counts
7 float IN 0.01 halui.feed-override.scale
7 float OUT 1.25 halui.feed-override.value
HALUI is Wrong, Touchy also shows in screen 125%

7 s32 IN 110 halui.feed-override.counts <== feed-ov-counts
7 float IN 0.01 halui.feed-override.scale
7 float OUT 1.1 halui.feed-override.value
HALUI is OK, but Touchy shows in screen 127%

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

More
18 Sep 2012 14:56 #24373 by andypugh
VNR wrote:

3) haltcl: setp halui.feed-override.count-enable TRUE
5) Axis doesn't change to the current halui.feed-override.value value
6) Move the switch and Axis now follows the halui.feed-override.value value

My own thinking is that Axis waits for an initial change in halui.feed-override.value to actualize the initial value of 100%.


A workaround might be to connect up the BCD bit signals in the posgui HAL file instead. Axis is already up and running at that point, so should see the value change.

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

More
18 Sep 2012 19:06 #24388 by VNR

A workaround might be to connect up the BCD bit signals in the posgui HAL file instead. Axis is already up and running at that point, so should see the value change.

Doesn't work.

I will try to modify the touchy code to support this rotary encoders, it only support incremental encoders and don't read the halui parameter halui.feed-override.value.

Thanks you for your help !
VNR

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

Time to create page: 0.073 seconds
Powered by Kunena Forum