PMDX-126 Extended Input Mode - Hal help

More
10 Sep 2015 12:18 #62371 by racedirector
So, while I find the dollars to buy a Mesa setup I have been trying to get my PMDX-126 to work in Extended Inputs Mode as specified in the user manual.Steve Stallings of PMDX was nice enough to dig out an old hal file he used to do this with a PMDX-125 when emc still needed an emc.nml file.

I have been trying to get this to work for a couple of days now but am just as confused now as I was in the beginning.

I'll start with Steve's email:

"Ok, I finally found the LinuxCNC files with the support for the
PMDX-125 (same applies to PMDX-126) using input signal multiplexing.
Unfortunately the neurons in my brain that understood what we did
are long since expired. :-(

The electronics of the Expanded Input Mode simply multiplex the
signals from J11 and J12 using the Charge Pump (pin 17) as the
select signal for the multiplexer. That means that the HAL file
for this must set up a Charge Pump signal and demultiplex and
latch the signals coming in on pins 11, 12, 13, and 15 in order
to provide 8 stable signals available in LinuxCNC.

You will find the HAL and INI files attached.
"

The hal file he supplied is this one:
# Generated by stepconf at Tue May 26 18:21:17 2009
# If you make changes to this file, they will be
# overwritten when you run stepconf again
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt probe_parport
loadrt hal_parport cfg="0x0378 out  "
setp parport.0.reset-time 1000
loadrt stepgen step_type=0,0,0
loadrt charge_pump
#net estop-out charge-pump.enable iocontrol.0.user-enable-out
net xenable charge-pump.enable 
net charge-pump <= charge-pump.out
loadrt pwmgen output_type=0

#demux for PMDX-125
loadrt tristate_bit count=8
addf tristate-bit.0 base-thread
addf tristate-bit.1 base-thread
addf tristate-bit.2 base-thread
addf tristate-bit.3 base-thread
addf tristate-bit.4 base-thread
addf tristate-bit.5 base-thread
addf tristate-bit.6 base-thread
addf tristate-bit.7 base-thread

net from-pp-pin11 parport.0.pin-11-in tristate-bit.0.in tristate-bit.4.in 
net from-pp-pin12 parport.0.pin-12-in tristate-bit.1.in tristate-bit.5.in 
net from-pp-pin13 parport.0.pin-13-in tristate-bit.2.in tristate-bit.6.in 
net from-pp-pin15 parport.0.pin-15-in tristate-bit.3.in tristate-bit.7.in 

#net main-pp-pin11 tristate-bit.0.out
net min-home-x <= tristate-bit.0.out
#net main-pp-pin12 tristate-bit.1.out
net max-x <= tristate-bit.1.out
net main-pp-pin13 tristate-bit.2.out
net main-pp-pin15 tristate-bit.3.out
net sec-pp-pin11 tristate-bit.4.out
net sec-pp-pin12 tristate-bit.5.out
net sec-pp-pin13 tristate-bit.6.out
net sec-pp-pin15 tristate-bit.7.out
net main-pp-tristate tristate-bit.0.enable tristate-bit.1.enable tristate-bit.2.enable tristate-bit.3.enable parport.0.pin-17-out
#sets main-pp-tristate true
net main-pp-tristate tristate-bit.4.enable tristate-bit.5.enable tristate-bit.6.enable tristate-bit.7.enable


#not used when PMDX-125# net min-home-x <= parport.0.pin-11-in
#not used when PMDX-125# net max-x <= parport.0.pin-12-in

#end of demux for PMDX-125

addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf charge-pump base-thread
addf pwmgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread

addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf pwmgen.update servo-thread

net spindle-cmd <= motion.spindle-speed-out => pwmgen.0.value
net spindle-enable <= motion.spindle-on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 100.0
setp pwmgen.0.scale 1166.66666667
setp pwmgen.0.offset 0.114285714286
setp pwmgen.0.dither-pwm true
net spindle-cw <= motion.spindle-forward

net estop-out => parport.0.pin-01-out
net astep => parport.0.pin-02-out
setp parport.0.pin-02-out-reset 1
net adir => parport.0.pin-03-out
net ystep => parport.0.pin-04-out
setp parport.0.pin-04-out-reset 1
net ydir => parport.0.pin-05-out
net zstep => parport.0.pin-06-out
setp parport.0.pin-06-out-reset 1
net zdir => parport.0.pin-07-out
net xdir => parport.0.pin-08-out
net xstep => parport.0.pin-09-out
setp parport.0.pin-09-out-reset 1
net spindle-cw => parport.0.pin-14-out
net spindle-pwm => parport.0.pin-16-out
net charge-pump => parport.0.pin-17-out


net estop-ext <= parport.0.pin-10-in-not
#not used when PMDX-125# net min-home-x <= parport.0.pin-11-in
#not used when PMDX-125# net max-x <= parport.0.pin-12-in


setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
setp stepgen.0.dirhold 12000
setp stepgen.0.dirsetup 30000
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb
net xstep <= stepgen.0.step
net xdir <= stepgen.0.dir
net xenable axis.0.amp-enable-out => stepgen.0.enable
net min-home-x => axis.0.home-sw-in
net min-home-x => axis.0.neg-lim-sw-in
net max-x => axis.0.pos-lim-sw-in

setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 12000
setp stepgen.1.dirsetup 30000
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb => axis.1.motor-pos-fb
net ystep <= stepgen.1.step
net ydir <= stepgen.1.dir
net yenable axis.1.amp-enable-out => stepgen.1.enable

setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 12000
setp stepgen.2.dirsetup 30000
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
net zpos-cmd axis.2.motor-pos-cmd => stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb => axis.2.motor-pos-fb
net zstep <= stepgen.2.step
net zdir <= stepgen.2.dir
net zenable axis.2.amp-enable-out => stepgen.2.enable

net estop-out <= iocontrol.0.user-enable-out
net estop-ext => iocontrol.0.emc-enable-in

loadusr -W hal_manualtoolchange
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared

and I "decoded" that into my own setup this way:
# Include your customized HAL commands here
# This file will not be overwritten when you run stepconf again

loadrt lut5
loadusr -Wn x200 mb2hal config=x200vfd.ini

addf lut5.0 servo-thread
addf charge-pump base-thread

setp lut5.0.function 0x10000
net all-limit-home => lut5.0.in-4
net all-limit <= lut5.0.out
net homing-x <= axis.0.homing => lut5.0.in-0
net homing-y <= axis.1.homing => lut5.0.in-1

net all-limit-home => axis.0.home-sw-in
net all-limit => axis.0.neg-lim-sw-in
net all-limit => axis.0.pos-lim-sw-in

net all-limit-home => axis.1.home-sw-in
net all-limit => axis.1.neg-lim-sw-in
net all-limit => axis.1.pos-lim-sw-in

loadrt scale count=1
addf scale.0 servo-thread
scale.0.gain = .16666667

net spindle-speed scale.0.in <= motion.spindle-speed-out
net x200-freq x200.frequency.00 <= scale.0.out

net x200-run x200.run.00 <= motion.spindle-on
# net x200-dir x200.direction.00 <= motion.spindle-reverse 
net spindle-at-speed x200.at-speed.00 <= motion.spindle-at-speed

setp x200.direction.00 0

loadrt charge_pump
net xenable charge-pump.enable 
net charge-pump <= charge-pump.out

#demux for PMDX-125
loadrt tristate_bit count=8
addf tristate-bit.0 base-thread
addf tristate-bit.1 base-thread
addf tristate-bit.2 base-thread
addf tristate-bit.3 base-thread
addf tristate-bit.4 base-thread
addf tristate-bit.5 base-thread
addf tristate-bit.6 base-thread
addf tristate-bit.7 base-thread

net from-pp-pin11 parport.0.pin-11-in tristate-bit.0.in tristate-bit.4.in 
net from-pp-pin12 parport.0.pin-12-in tristate-bit.1.in tristate-bit.5.in 
net from-pp-pin13 parport.0.pin-13-in tristate-bit.2.in tristate-bit.6.in 
net from-pp-pin15 parport.0.pin-15-in tristate-bit.3.in tristate-bit.7.in
 
net main-pp-pin11 tristate-bit.0.out
net main-pp-pin12 tristate-bit.1.out
net main-pp-pin13 tristate-bit.2.out
net main-pp-pin15 tristate-bit.3.out

net sec-pp-pin11 tristate-bit.4.out
net sec-pp-pin12 tristate-bit.5.out
net sec-pp-pin13 tristate-bit.6.out
net sec-pp-pin15 tristate-bit.7.out

net main-pp-tristate tristate-bit.0.enable tristate-bit.1.enable tristate-bit.2.enable tristate-bit.3.enable parport.0.pin-17-out

#sets main-pp-tristate true
net main-pp-tristate tristate-bit.4.enable tristate-bit.5.enable tristate-bit.6.enable tristate-bit.7.enable

#end of demux for PMDX-125

net estop-ext       <= parport.0.pin-10-in-not
#net all-limit-home  <= tristate-bit.2.in

#net probe-z tristate-bit.3.out => motion.probe-input

#net cycle-start <= tristate-bit.7.in
#net feedhold-pause <= tristate-bit.6-in
#net stop-code <= tristate-bit.5.in

#net charge-pump => parport.0.pin-17-out

But it does not work as it seems some things have changed in 2.7 in the way hal connects to various pins. For example, the net charge-pump => parport.0.pin-17-out flags an error as the parport is already used in the first net main-pp-tristate line. I suspect that this is one of the reasons it is failing due to my next email from Steve:

"Using the watch window is the right way to go.

The charge pump signal is ESSENTIAL to making Expanded Input Mode
work. You need to solve the problem with that first. You can use
the Outputs Enabled LED on the PMDX-126 to let you know that the
signal is present and toggling. The E-Stop input must be satisfied
also.

Sorry, but my work on this was over 7 years ago and I don't even
remember how to work with LinuxCNC, much less how this specific
HAL file functioned
."

This was in response to my email to him that contained:

"I am a little confused how this works or more correctly just not getting it. I got it all installed on my machine and watched the hal pins in the watch window.

Previous to this my setup was as follows:

Pin 13 - Proxy Inputs
Pin 12 - Free
Pin 11 - Touch Off Pushbutton
Pin 15 - Z Touch off plate (both fixed and floating)

The buttons I am trying to get working are:

Pin H - Green Pushbutton - Cycle Start (on machine)
Pin G - Yellow Pushbutton - Pause/Feedhold (on machine)
Pin F - Red Pushbutton - Stop (on machine)

With the 126 in Extended Input Mode (config 1 out, config 2 out, config 3 in) I get this in the hal watch window:

from-pp-pin11 = On
from-pp-pin12 = On
from-pp-pin13 = On
from-pp-pin15 = On

main-pp-pin11 = Off
main-pp-pin12 = Off
main-pp-pin13 = Off

sec-pp-pin11 = Off
sec-pp-pin12 = Off
sec-pp-pin13 = Off
sec-pp-pin15 = Off

tristate-bit.1.out = Off
tristate-bit.1.in = On
tristate-bit.2.out = Off
tristate-bit.2.in = On
tristate-bit.3.out = Off
tristate-bit.3.in = On
tristate-bit.4.out = Off
tristate-bit.4.in = On
tristate-bit.5.out = Off
tristate-bit.5.in = On
tristate-bit.6.out = Off
tristate-bit.6.in = On
tristate-bit.7.out = Off
tristate-bit.7.in = On
tristate-bit.0.out = Off
tristate-bit.0.in = On

Press Green Button (Pin H) = tristate-bit-1-out - On, tristate-bit-5-out - On No others on
Press Yellow Button (Pin G) = tristate-bit-2-out - On, tristate-bit-6-out - On No others on
Press Red Button (Pin F) = tristate-bit-3-out - On, tristate-bit-7-out - On No others on

No other inputs trigger anything else.
"

So, I am turning to the guru's to see if anyone can spot the error that is causing my grief. Hoping someone can help.

Cheers
Bruce

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

More
10 Sep 2015 16:39 #62374 by cncbasher
can you post the files from steve as an attachment archive
and your own as you have it , and i'll try and take a stab at it , in the next few days

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

More
10 Sep 2015 17:13 - 10 Sep 2015 18:32 #62376 by racedirector
Thank you Sir, appreciate it. Files attached. The 2 pmdx125 files are Steve's, custom.hal is my attempt.

Cheers
Bruce
Attachments:
Last edit: 10 Sep 2015 18:32 by racedirector. Reason: Added zipped files just in case....

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

More
10 Sep 2015 19:09 - 10 Sep 2015 19:11 #62382 by andypugh
I think that there is a problem with the original HAL.
It seems to me that the idea is that when charge-pump is high the values on the input pins drive tristate-bits 0,1,2,3 and when it is low they drive 4,5,6,7
But that isn't how it is coded, all the tristates are driven from the same charge pump signal, rather than half of them being driven from an inverted version.

I am not sure I like the use of "tristate" here, mainly as it has IO type outputs, which seems a bit untidy.

Here is an alternative way to do much the same thing.
loadrt mux_generic config="bb2,bb2,bb2,bb2,bb2,bb2,bb2,bb2"
addf mux_gen.0 base-thread
addf mux_gen.1 base-thread
addf mux_gen.2 base-thread
addf mux_gen.3 base-thread
addf mux_gen.4 base-thread
addf mux_gen.5 base-thread
addf mux_gen.6 base-thread
addf mux_gen.7 base-thread

net in0    parport.0.pin-11-in => mux-gen.00.in-bit-00 mux-gen.04.in-bit-01 
net in1    parport.0.pin-12-in => mux-gen.01.in-bit-00 mux-gen.05.in-bit-01 
net in2    parport.0.pin-13-in => mux-gen.02.in-bit-00 mux-gen.06.in-bit-01 
net in3    parport.0.pin-15-in => mux-gen.03.in-bit-00 mux-gen.07.in-bit-01 

net out0 mux-gen.00.out => mux-gen.00.in-bit-01 
net out1 mux-gen.00.out => mux-gen.01.in-bit-01
net out2 mux-gen.00.out => mux-gen.02.in-bit-01
net out3 mux-gen.00.out => mux-gen.03.in-bit-01
net out4 mux-gen.00.out => mux-gen.00.in-bit-00
net out5 mux-gen.00.out => mux-gen.00.in-bit-00
net out6 mux-gen.00.out => mux-gen.00.in-bit-00
net out7 mux-gen.00.out => mux-gen.00.in-bit-00

net charge-pump charge-pump.out => parport.0.pin-17-out
net charge-pump mux-gen.00.sel-bit-000  mux-gen.01.sel-bit-000 mux-gen.02.sel-bit-000 mux-gen.03.sel-bit-000
net charge-pump mux-gen.04.sel-bit-000  mux-gen.05.sel-bit-000 mux-gen.06.sel-bit-000 mux-gen.07.sel-bit-000

On reflection, that turned out to be a very complicated way to avoid creating an inverted version of the charge-pump signal.

The way this tries to work (I haven't tested it) is that there are 8 bit-type mux2 components all set up to either take a value from the parport pin or pass their previous output back to the input.
Half of them take a new value when the select is low, half take a new value when it is high. Each parport pin is sent to two muxes.

Amusingly, this is using a set of multiplexer components to create a demultiplexer.

[edit] To use the outputs, you would net whatever components you want to consume the signal to the out0, out1, out2 etc signals. eg
net out0 death-ray.enable
Last edit: 10 Sep 2015 19:11 by andypugh.

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

More
10 Sep 2015 19:47 #62388 by racedirector
Ah.... Wow! I am in awe of how you came up with that, seems I have SO much to learn in this world.

I'll plug this is an report back.

Thanks for doing what you did

Cheers
Bruce

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

More
11 Sep 2015 08:56 - 11 Sep 2015 10:51 #62428 by racedirector
Andy... you Sir are a legend.

The changes you made appear to be working as advertised, I have 8 inputs and they all respond to what is connected to them. I had to make a few changes to the file and I also customised the names of the inputs and pin names but so far so good. I'll do a video of it all working and how it appears in the hal viewer.

I am now getting adventurous and am going to attempt to get the extra outputs working using your file as the base. You could say I am a glutton for punishment :)

EDIT: Not going to do the out put thing, I would only gain 2 more outputs that I don't really need anyway....
Last edit: 11 Sep 2015 10:51 by racedirector.

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

More
11 Sep 2015 10:50 - 11 Sep 2015 10:53 #62429 by racedirector
Ok, so I reached a bit of a gotcha....

I needed my probe input to be off to satisfy motion.prone-input so I linked pin 15 o the "not" value. All well and good. However I am not sure if this is the right way to do it as I might need to make a few of the other pins "not" but they are from the second set of inputs that Andy managed to decipher. I am attaching my hal file for the pin setup, as I said this works fine to have the pins in an N/C state but I think some of them have to be in the N/O state to work as per this thread.....linuxcnc.org/index.php/english/forum/47-...p-holdresume-buttons

I hope I not asking too much......

Cheers
Bruce
Attachments:
Last edit: 11 Sep 2015 10:53 by racedirector.

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

More
11 Sep 2015 16:20 #62438 by andypugh

Ok, so I reached a bit of a gotcha....

I needed my probe input to be off to satisfy motion.prone-input so I linked pin 15 o the "not" value. All well and good. However I am not sure if this is the right way to do it


There are two ways to do it, both will work, and if you really want to confuse future-you then you can mix them.

If you know that you want the inverted version of both inputs that share a pin, then connect the .....-not value to the mux.
if you want to only invert one input, then invert it separately with a HAL "not" function.

(like any HAL function, loadrt.... addf..... net....)

www.linuxcnc.org/docs/html/man/man9/not.9.html

It is well worth taking the time to skim through the descriptions of all the "Realtime components and HAL modules" here www.linuxcnc.org/docs/html/

I am starting to see that perhaps we should have a "demux_generic" :-)

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

More
11 Sep 2015 16:24 #62440 by cncbasher
glad your making progress Bruce

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

More
11 Sep 2015 18:41 #62445 by racedirector
Thanks Andy

In truth I would much rather be shown what to look for over how to do it. They say trial by experience is better than having it offered up. I will look into your links and the "not" function.

cncbasher, thanks, getting there!

Cheers

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

Time to create page: 0.091 seconds
Powered by Kunena Forum