Using Python for plc and user g codes ?

More
25 Jun 2010 22:04 #3207 by cncdog
Hello to all,

Im in the process of using Emc on my Cincinnatti lathe.I had it up with a Delta tau system and the pmac bit the dust.....
Its taken a few days,but Ive gotten the basic idea of how this works.Im using a Mesa 5i20 and 7i33.I have already written all my plc's in DT,which is a stripped version of C,looks an awful lot like python.
Is it possible to to write(or in my case,transfer,after some editing) my machine logic in Python and call it up from HAL?How would I go about it.How do I add my own G codes??-I have the logic that for ALL the Fanuc lathe cycles except G71/G72/G73.
Im also working on using the unused encoder channel on the 7i33 for the handwheel-any one else pull this off yet?Thanks in advance.

JR

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

More
27 Jun 2010 22:16 #3217 by BigJohnT
EMC has a built in PLC called Classicladder to handle machine logic not handled by HAL.

To add your own G Codes you would have to edit the main source code.

To add a MPG is fairly simple. Here is how I did it on my Hardinge lathe with a selector switch for the axis and a selector switch for the resolution to move per click on the MPG. All of this code is in my main.hal file.
loadrt mux4 names=mpg-scale
loadrt or2 count=2

# MPG scale
addf or2.0 servo-thread
addf or2.1 servo-thread

# MPG Jog Speeds
addf mpg-scale servo-thread

# MPG encoder feedback
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.counter-mode 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.filter 1
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-invert 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask-invert 0

net mpg-count hm2_5i20.0.encoder.03.count
net mpg-count => axis.0.jog-counts
net mpg-count => axis.2.jog-counts

setp mpg-scale.in0 .000025
setp mpg-scale.in1 .00025
setp mpg-scale.in2 .0025

net mpg-x axis.0.jog-enable <= hm2_[HOSTMOT2](BOARD).0.gpio.054.in_not
net mpg-z axis.2.jog-enable <= hm2_[HOSTMOT2](BOARD).0.gpio.052.in_not

# MPG Scale
# set the MPG scale based on the inputs from the selector switch
net pos2 mpg-scale.sel0 <= hm2_[HOSTMOT2](BOARD).0.gpio.037.in_not
net pos3 mpg-scale.sel1 <= hm2_[HOSTMOT2](BOARD).0.gpio.035.in_not

net axis-mpg-jog-scale axis.0.jog-scale <= mpg-scale.out
net axis-mpg-jog-scale axis.2.jog-scale <= mpg-scale.out

I hope I didn't miss anything.

John

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

More
28 Jun 2010 10:13 #3227 by Rick G
You may also want to look at user defined M codes.


Rick G

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

More
28 Jun 2010 14:54 #3233 by cncdog
Thank you for the code for the Mpg,I was close.I have a few more questions.Im low on i/o and cash right now,so Ive been adding pvcp buttons to axis for the handle,tailstock,jog increments ect.None of these have predefined Halui pins,this is probably a dumb question,can I just point the button at an existing regular hal pin?
I saw the user m codes in both python and C,Id still rather use python or c for machine logic.I noticed the Boss config doesnt use classic ladder-any suggestions?Thanks again.

JR

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

More
28 Jun 2010 21:53 #3237 by BigJohnT
Yes, start by reading this short chapter.

www.linuxcnc.org/docview/html//hal_basic_hal.html

And remember that any hal "connections" to pyvcp pins must be made in the post-gui.hal file.

Just add classicladder to your main hal file and edit the ladder as needed. Read up on it in the Integrators manual.

The user M codes can use any programming language including HAL and is sort of independent of EMC. EMC starts the file and the file reports back when done then EMC continues.

John

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

More
29 Jun 2010 10:50 #3243 by Rick G

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

Time to create page: 0.079 seconds
Powered by Kunena Forum