MPG - HAL Question(s)

More
08 Mar 2020 20:13 #159505 by mooser
MPG - HAL Question(s) was created by mooser
Wired an offshore pendant (xyz456 type with an enabled button and e-stop) into my 7i76 lathe using various samples I found on the net
Modified a sample Custom.HAL using the linuxcnc document and I almost have something working

Currently:
Estop button is working (although I had to disable the other e-stop but that's a different problem)
The enable button is working
the Axis select X and Z are working (axis-select-x and z in the hal meter)
The scale (x1 x10 x100) is working (scale 1 or scale 2 = true and mpg shows .001, .01 and .1)

Trying to get the handwheel working now, i've got the power connected to TB3 #20 and gnd to #24 so taking 5v from the 5i25, A/A- and B/B- to pins 16 through 19 on TB5
In the custom.HAL I've entered

loadrt encoder num_chan=1
loadrt mux4 count=1
#addf encoder.capture-position servo-thread # not sure what this is
#addf encoder.update-counters base-thread # not sure what this is
addf mux4.0 servo-thread

# If your MPG outputs a quadrature signal per click set x4 to 1
# If your MPG puts out 1 pulse per click set x4 to 0
setp encoder.0.x4-mode 1

net mpg-a encoder.0.phase-A <= hm2_5i25.0.7i76.0.0.input-18
net mpg-b encoder.0.phase-B <= hm2_5i25.0.7i76.0.0.input-19

but what would the other part of the quad (A- and B-) be? is it as simple as
net mpg-a encoder.0.phase-A- <= hm2_5i25.0.7i76.0.0.input-16
net mpg-b encoder.0.phase-B- <= hm2_5i25.0.7i76.0.0.input-17

Also, what would the signal be to watch on the hal meter? X-jog-counter?
Thanks
M
The following user(s) said Thank You: Bncs

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

More
08 Mar 2020 20:26 - 08 Mar 2020 22:08 #159507 by PCW
Replied by PCW on topic MPG - HAL Question(s)
You don't need a software encoder component nor do you need to deal with the
digital inputs pins, instead you use the 7I76s mpg encoder pins:

hm2_5i25.0.7i76.0.0.enc0.count
and
hm2_5i25.0.7i76.0.0.enc1.count

and connect them to motions jog input pins
Last edit: 08 Mar 2020 22:08 by PCW. Reason: wrong card
The following user(s) said Thank You: Bncs

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

More
08 Mar 2020 21:00 - 08 Mar 2020 21:16 #159509 by mooser
Replied by mooser on topic MPG - HAL Question(s)
Just when I thought I was doing well :) I'm not sure about the...
"software encoder component nor do you need to deal with the digital inputs pins," can you clarify a bit for me?

Here's what I've got right now

# Include your custom HAL commands here
# This file will not be overwritten when you run PNCconf again


# Jog Pendant
loadrt encoder num_chan=1
loadrt mux4 count=1
loadrt and2 count=1
addf mux4.0 servo-thread
addf and2.0 servo-thread

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

# If your MPG outputs a quadrature signal per click set x4 to 1
# If your MPG puts out 1 pulse per click set x4 to 0
setp encoder.0.x4-mode 1


# For position mode (the default), set to 0
# In position mode the axis will move exactly jog-scale
# units for each count, regardless of how long that might take,
setp axis.0.jog-vel-mode 0
setp axis.2.jog-vel-mode 0


# This sets the scale that will be used based on the input to the mux4
setp mux4.0.in0 0.001
setp mux4.0.in1 0.01
setp mux4.0.in2 0.1

# The inputs to the mux4 component
net scale1 mux4.0.sel0 <= hm2_5i25.0.7i76.0.0.input-25 #27
net scale2 mux4.0.sel1 <= hm2_5i25.0.7i76.0.0.input-26 #28


# The output from the mux4 is sent to each axis jog scale
net mpg-scale <= mux4.0.out
net mpg-scale => axis.0.jog-scale
net mpg-scale => axis.2.jog-scale


# The MPG inputs
net mpg-a encoder.0.phase-A <= hm2_5i25.0.7i76.0.0.input-18
net mpg-b encoder.0.phase-B <= hm2_5i25.0.7i76.0.0.input-19
#net mpg-a encoder.0.phase-A- <= hm2_5i25.0.7i76.0.0.input-16
#net mpg-b encoder.0.phase-B- <= hm2_5i25.0.7i76.0.0.input-17


# The Axis select inputs
net axis-select-x <= hm2_5i25.0.7i76.0.0.input-20
net axis-select-z <= hm2_5i25.0.7i76.0.0.input-22


# --- ESTOP-EXT ---
net estop_jog <= hm2_5i25.0.7i76.0.0.input-00





# --- MAPPING MPG ENCODER signals to jog counters I believe this is the connection you mean?
# using two different encoders for different axis (X,Z)
net x-jog-counter <= hm2_5i25.0.7i76.0.0.enc0.count
net z-jog-counter <= hm2_5i25.0.7i76.0.0.enc1.count



# --- MAPPING INPUT signals and modes to linux cnc signals / gui

net x-jog-counter => axis.0.jog-counts
net z-jog-counter => axis.2.jog-counts

# Transfer input signal to linux cnc action (enable axis selection)
net axis-select-x => axis.0.jog-enable
net axis-select-z => axis.2.jog-enable


# ESTOP button trigger GUI control
net estop_prog <= iocontrol.0.user-enable-out
net estop_prog => and2.0.in0
net estop_jog => and2.0.in1
net and2out <= and2.0.out => iocontrol.0.emc-enable-in

#net temp <= passthrough.in



Now since I don't see any call for the actual input pins (I'm on TB5, pins 1234, input 16-17-18-19 now) I can only guess there are a specific set on the 7i76 I should be using instead? OK so there it is where it explained the mode 2, I just missed it, so I'm on the correct pins (I think) except it's for two encoders do I just leave the A- and B- unconnected?


Thanks
M
Last edit: 08 Mar 2020 21:16 by mooser. Reason: found the Mode 2 MPG pin reference

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

More
08 Mar 2020 21:20 #159512 by PCW
Replied by PCW on topic MPG - HAL Question(s)
Yes leave the - pins of differential encoder outputs unconnected

Plus all this stuff can be deleted:

loadrt encoder num_chan=1
addf encoder.capture-position servo-thread
addf encoder.update-counters base-thread
# If your MPG outputs a quadrature signal per click set x4 to 1
# If your MPG puts out 1 pulse per click set x4 to 0
setp encoder.0.x4-mode 1
# The MPG inputs
net mpg-a encoder.0.phase-A <= hm2_5i25.0.7i76.0.0.input-18
net mpg-b encoder.0.phase-B <= hm2_5i25.0.7i76.0.0.input-19
#net mpg-a encoder.0.phase-A- <= hm2_5i25.0.7i76.0.0.input-16
#net mpg-b encoder.0.phase-B- <= hm2_5i25.0.7i76.0.0.input-17
The following user(s) said Thank You: Bncs

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

More
08 Mar 2020 21:29 #159514 by mooser
Replied by mooser on topic MPG - HAL Question(s)
Thanks, doing it now

When I add the
hm2_5i25.0.7i76.0.0.enc0.count
it gives me an error on load
I've got to check the main HAL again to make sure I'm in Mode2, I thought I was but maybe not
Does that (hm2_5i25.0.7i76.0.0.enc0.count) have to be called in the main rather than this custom or anything?
M

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

More
08 Mar 2020 21:46 #159516 by PCW
Replied by PCW on topic MPG - HAL Question(s)
Yeah, it sounds like the mode is not correct

The hal pin is available after the driver is loaded so it make no difference
where the net connection is made as long as its done after the hardware
drivers are loaded

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

More
08 Mar 2020 21:58 - 08 Mar 2020 22:01 #159517 by mooser
Replied by mooser on topic MPG - HAL Question(s)
Custom HAL now has....
# Include your custom HAL commands here
# This file will not be overwritten when you run PNCconf again

hm2_5i25.0.7i76.0.0.enc0.count
hm2_7i76e.0.7i76.0.0.enc1.count

# Jog Pendant
loadrt mux4 count=1
loadrt and2 count=1
addf mux4.0 servo-thread
addf and2.0 servo-thread




From the main HAL
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hostmot2
loadrt hm2_pci config=" num_encoders=1 num_pwmgens=0 num_stepgens=2 sserial_port_0=20xxxx"

Originally all I changed was the 0=00xxxx to 0=20xxxx, did I miss something
M
Last edit: 08 Mar 2020 22:01 by mooser.

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

More
08 Mar 2020 22:09 #159519 by PCW
Replied by PCW on topic MPG - HAL Question(s)
Sorry my example up above had the wrong card
hm2_7i76e.0.7i76.0.0.enc1.count needs to be
hm2_5i25.0.7i76.0.0.enc1.count

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

More
08 Mar 2020 22:16 #159521 by mooser
Replied by mooser on topic MPG - HAL Question(s)
No you had it right I just typed it wrong on here

hm2_5i25.0.7i76.0.0.enc0.count
hm2_5i25.0.7i76.0.0.enc1.count

is what is in the custom.hal

Still errors on launch saying it doesn't know that command

Main hal has
loadrt hm2_pci config=" num_encoders=1 num_pwmgens=0 num_stepgens=2 sserial_port_0=20xxxx"

but it can't be going into mode 2. Is there any other setting?
M

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

More
08 Mar 2020 22:22 - 08 Mar 2020 22:38 #159522 by PCW
Replied by PCW on topic MPG - HAL Question(s)
Yeah that's correct
You can't have a pin name as the first token in a hal file

it has to be
net some_signal_name some_pin_name
or
net some_signal_name some_pin_name some_other_pin_name yet_another_pin_name
etc

Or in this specific instance:

net x-jog-counter <= hm2_5i25.0.7i76.0.0.enc0.count
net z-jog-counter <= hm2_5i25.0.7i76.0.0.enc1.count
Last edit: 08 Mar 2020 22:38 by PCW.

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

Time to create page: 0.210 seconds
Powered by Kunena Forum