a simple rotary encoder for my mill. How?

More
02 Jan 2011 16:51 #6371 by mike303
hi,

i have a simple rotary encoder with phase A/B and a integrated switch. the encoder has 32 steps per round.
i connected it to parport0 pin 10,11,12 and GND. in MACH3 under windows all works but with EMC i have no luck with HAL.
also i can't find a documentation about this (or i can't understand this)
my plan:

switch pressing => axsis select (x,y,z,x,y,z...)
turn the encoder => actual axsis is moving

can any one explain/show how this simple setup is done in custom.hal

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

More
02 Jan 2011 18:10 #6373 by PCW
wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Hooking_Up_A_MPG_Pendant
is similar but looks like it uses a selector switch connected to three parallel port input bits for
axis selection

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

More
02 Jan 2011 18:33 #6374 by mike303
i known this docu site but i don't understand it complete. i use it like described but no axis is moving:

loadrt encoder num_chan=1
loadrt mux4 count=1

addf encoder.capture-position servo-thread
addf encoder.update-counters base-thread
addf mux4.0 servo-thread

setp axis.0.jog-vel-mode 0
setp axis.1.jog-vel-mode 0
setp axis.2.jog-vel-mode 0
setp axis.0.jog-vel-mode 1
setp axis.1.jog-vel-mode 1
setp axis.2.jog-vel-mode 1

setp encoder.0.x4-mode 0

setp mux4.0.in0 0.1
setp mux4.0.in1 0.01
setp mux4.0.in2 0.001
setp axis.0.jog-enable TRUE
setp axis.1.jog-enable TRUE
setp axis.2.jog-enable TRUE

net pend-scale axis.0.jog-scale <= mux4.0.out
net pend-scale axis.1.jog-scale
net pend-scale axis.2.jog-scale

net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
net mpg-b encoder.0.phase-B <= parport.0.pin-11-in

net pend-counts axis.0.jog-counts <= encoder.0.counts
net pend-counts axis.1.jog-counts
net pend-counts axis.2.jog-counts

also i can't find a hint to simple select the 3 axis with one button (each press step to the next)

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

More
02 Jan 2011 18:59 #6376 by PCW
It may not work if you dont have the jog scale set correctly (the mux inputs right). For example if the mux select pins were both high, I bet you get 0 for the jog increment

You can back-trace through the operation with HAL meter (I'd look at encoder.0.counts first)

For selecting axis by pushbutton , maybe some HAl guru can suggest an elegant method

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

More
02 Jan 2011 19:25 #6377 by andypugh
mike303 wrote:

also i can't find a hint to simple select the 3 axis with one button (each press step to the next)


I spent about half an hour writing an annotated hal file for you, to do what you want. Unfortunately the forum logged me out half way through, and lost it. :angry:

So, here it is, probably full of errors, and without the annotation. Sorry but my enthusiasm has dwindled.
loadrt encoder num_chan=1
loadrt select8 count=1
loadrt updown count=1

addf encoder.update-counters base-thread
addf encoder.capture-position servo-thread
addf select8.0 servo-thread
addf updown.0 servo-thread

net encA encoder.0.phase-A <= parport.0.pin-10-in
net encB encoder.0.phase-B <= parport.0.pin-11-in
net enc-counts encoder.0.counts => axis.0.jog-counts axis.1.jog-counts axis.2.jog-counts
net jog-button updown.0.countup <= parport.0.pin-12-in
net jog-choice updown.0.count => select8.0.sel
net jogX axis.0.jog-enable <= select.8.0.out0
net jogY axis.1.jog-enable <= select.8.0.out1
net jogZ axis.2.jog-enable <= select8.0.out2

setp encoder.0.counter-mode 1
setp updown.0.max 2
setp updown.0.min 0
setp updown.0.wrap 1

setp axis.0.jog-scale 0.1
setp axis.1.jog-scale 0.1
setp axis.2.jog-scale 0.1

You might want to add a oneshot component between the button input pin and the updown component.
www.linuxcnc.org/docview/html/man/man9/oneshot.9.html

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

More
02 Jan 2011 20:22 #6379 by mike303
Thank You!

Thats was a really helpful post! Now it's working.

Where can i find how to write a HAL-file like this?
'updown' , 'select8', 'net' ore 'setp' are HAL-components?
It looks like a electronic circuit.


Without knowing about the word, you can't learn the language...

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

More
02 Jan 2011 21:36 #6381 by andypugh
mike303 wrote:

Where can i find how to write a HAL-file like this?
'updown' , 'select8', 'net' ore 'setp' are HAL-components?

You can find a list of all the hal components in the "Realtime components and kernel modules" section of this page:
www.linuxcnc.org/docview/html/
Some basic instructions on how to put them together are here:
www.linuxcnc.org/docview/html/hal_basic_hal.html
If you want a more complicated or special function it is quite easy to write them if you know some C:
linuxcnc.org/docs/html/hal_comp.html

It looks like a electronic circuit.

It is very similar, in fact it is so similar that people have found ways to convert HAL files into Eagle schematics to visualise them:
wiki.linuxcnc.org/emcinfo.pl?Eagle2HAL
(I am not sure that is currently useful, though).

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

Time to create page: 0.085 seconds
Powered by Kunena Forum