HAL help needed for MPG wheel jogging and machine enabling logic

  • LinuxCrashOut
  • LinuxCrashOut's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
09 Sep 2025 21:07 - 09 Sep 2025 21:15 #334734 by LinuxCrashOut
Hello guys, 

Trying to set up two things :

1) I want my machine to be enabled as soon as I disengage the estop, so halui.machine.is-on is true when the estop is not pressed.

I already have this 

# --- Physical E-stop on INPUT27 ---
# Normally open: 0 = OK, 1 = E-stop pressed

net estop-in    <=  hm2_7i76e.0.7i76.0.0.input-27
net estop-in    =>  iocontrol.0.emc-enable-in

I tried a lot of different ways but unsuccessfully. The most I could do was that the machine was on at start, when the estop was not pushed, but after cycling the estop, the machine would not get back to its on state.

# Load the required components
loadrt toggle2nist
loadrt timedelay
loadrt oneshot

# Add functions to threads
addf toggle2nist.0 servo-thread
addf timedelay.0 servo-thread
addf oneshot.0 servo-thread

# Configure components
setp timedelay.0.on-delay 2.0
setp timedelay.0.off-delay 0.0
setp oneshot.0.width 0.1  # Short pulse

# Create a not component for inversion (using existing not component)
loadrt not names=not.estop
addf not.estop servo-thread

# Connect iocontrol.0.user-enable-out to not component
net user-enable-status iocontrol.0.user-enable-out => not.estop.in

# Detect estop clearance edge (inverted signal)
net estop-cleared <= not.estop.out
net estop-cleared => oneshot.0.in
net estop-pulse oneshot.0.out => timedelay.0.in

# Use existing machine status signal
net machine-is-on => toggle2nist.0.is-on

# Connect delayed pulse to toggle
net delayed-pulse timedelay.0.out => toggle2nist.0.in

# Connect toggle output
net machine-on-toggle toggle2nist.0.on => halui.machine.on

Can you guys tell me why it does not work, what I am doing wrong or forgot?

2) I tried adding an MPG, but I am lost and the documentation is not very helpful for a beginner.

I am wiring my mpg as described in the attached picture but I was not able to make it work :

 

Here is the wiring for my pins on my mesa 7i76e :

5) **Jog MPG** (hm2_7i76e.0.7i76.0.0.enc0.count)

    | TB3 pin  |  Name   | MPG contact |
    |:---|:-----| :--- |
    | 9 | GND | VCC |
    | 12 | +5VP | GND |

    | TB5 pin  |  Name   | MPG contact |
    |:---|:-----| :--- |
    | 1 | INPUT16 | A+ |
    | / | / | A- |
    | 2 | INPUT17 | B+ |
    | / | / | B- |

6) **Jog enabling button**

    | TB5 pin  |  Name   | HAL name |
    |:---|:-----|:---|
    | 5 | INPUT20 | hm2_7i76e.0.7i76.0.0.input-20 |

7) **Speed selector button**

    | TB5 pin  |  Name   |  Position  |
    |:---|:-----|:---|
    | 6 | INPUT21 | X1 |
    | 7 | INPUT22 | X100 |

    If none is selected, the speed is X10

8) **Axis selector button**

    | TB5 pin  |  Name   |  Position  |
    |:---|:-----|:---|
    | 8 | INPUT23 | X |
    | 9 | INPUT24 | Z |

So, if someone has the code for an mpg wired like that, on a 7i76e, I would really appreciate it!

My ini and hal files are attached.
Attachments:
Last edit: 09 Sep 2025 21:15 by LinuxCrashOut.

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

More
09 Sep 2025 21:49 #334735 by PCW
For the MPG wiring you would also need the field power common
to connect to the MPG GND

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

  • LinuxCrashOut
  • LinuxCrashOut's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
09 Sep 2025 23:12 #334737 by LinuxCrashOut
I already have
0) **Power**

    | TB1 pin  |  Name   | Terminal block |
    |:---|:-----|:---|
    | 5 | VIN |  24V+  |     
    | 8 | GROUND |  0V  |     

    | TB3 pin  |  Name   | Terminal block |
    |:---|:-----|:---|
    | 22 | UNREG LOGIC PWR+ IN |  24V+  |     
    | 23 | GND |  0V  |    

And from my post above, I wrote :
| TB3 pin  |  Name   | MPG contact |
    |:---|:-----| :--- |
    | 9 | GND | VCC |
    | 12 | +5VP | GND |

but I meant:
| TB3 pin  |  Name   | MPG contact |
    |:---|:-----| :--- |
    | 9 | GND | GND |
    | 12 | +5VP | VCC |

is the GND on pin 9 floating and I need to wire it to the GND from my power supply?

bit lost here...

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

More
10 Sep 2025 00:00 #334738 by PCW
OK so if you are supplying the same 24V to TB3 and TB1
the 5V and 24V grounds are already common so that's OK.

Does hm2_7i76e.0.7i76.0.0.enc0.count change when you turn the MPG?

 

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

  • LinuxCrashOut
  • LinuxCrashOut's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 Sep 2025 11:22 #334765 by LinuxCrashOut
It does not 

 
Attachments:

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

More
10 Sep 2025 13:55 #334771 by PCW
I would check the swing of the A,B MPG signals, relative to ground.
The input threshold is about 2.5V with ~20% hysteresis so needs a good
say 4V swing to work reliably.
The following user(s) said Thank You: LinuxCrashOut

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

  • LinuxCrashOut
  • LinuxCrashOut's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 Sep 2025 13:59 #334773 by LinuxCrashOut
I guess I am going to need an oscilloscope?

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

More
10 Sep 2025 14:04 #334774 by PCW
A voltmeter will do, you just need to jog the MPG
so you can measure the high and low states.

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

  • LinuxCrashOut
  • LinuxCrashOut's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
14 Sep 2025 17:54 #334988 by LinuxCrashOut
Ok, I got some help and realized the mesa 7i76e was in mode 0, now it is in mode 2 and I can see the counts on hm2_7i76e.0.7i76.0.0.enc0.count

I am still lost about how the following works (as for the logic)

I would love to have one button that enables the jog for x axis for example, and then the mpg makes it move (while the button is pressed)

 

File Attachment:

File Name: empty_sample_0.4.hal
File Size:10 KB
Attachments:

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

More
15 Sep 2025 01:50 - 15 Sep 2025 01:59 #335003 by PCW
A very basic bit of hal code for a 7I76E MPG would be:

net mpg-counts  hm2_7i76e.0.7i76.0.0.enc0.count 
net mpg-counts  axis.x.jog-counts
net mpg-counts  axis.y.jog-counts
net mpg-counts  axis.z.jog-counts
net x-jog-enable hm2_7i76e.0.7i76.0.0.input-07 axis.x.jog-enable
net y-jog-enable hm2_7i76e.0.7i76.0.0.input-08 axis.y.jog-enable
net z-jog-enable hm2_7i76e.0.7i76.0.0.input-09 axis.z.jog-enable

loadrt mux4
addf mux4.0 servo thread
net jog-inc0 hm2_7i76e.0.7i76.0.0.input-10  mux4.0.sel0
net jog-inc1 hm2_7i76e.0.7i76.0.0.input-11  mux4.0.sel1
setp mux4.0.in0 0.0001
setp mux4.0.in1 0.0010
setp mux4.0.in2 0.0100
setp mux4.0.in3 0.1000
net jog-scale mux4.0.out
net jog-scale axis.x.jog-scale
net jog-scale axis.y.jog-scale
net jog-scale axis.z.jog-scale

Notes:

This is for axis rather than for joints so will only work after homing
(a minor change is needed to jog before and after homing)

The I/O pins and jog increments are arbitrary

The mux4 select bits are a binary code 00,01,10,11 to select the jog increment.
This can usually be arranged with a wafer switch but can be redone for linear select
or button press to select the increments.

 
Last edit: 15 Sep 2025 01:59 by PCW.
The following user(s) said Thank You: LinuxCrashOut

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

Time to create page: 0.149 seconds
Powered by Kunena Forum