588,289 active members*
5,871 visitors online*
Register for free
Login

Thread: EMC2

Page 1 of 2 12
Results 1 to 20 of 33
  1. #1
    Join Date
    Nov 2008
    Posts
    17

    EMC2

    I am trying to create a M100 to turn an output on in a program. What is the descripter for M100 to be used in HAL. When I create a Gcode program and open it it causes and error because M100 is not defined.

    Jamy

  2. #2
    Join Date
    Nov 2005
    Posts
    496
    Did you look in the integrators manual under M100? Did you follow those instructions? We need more info.

    Cheers Chris

  3. #3
    Join Date
    Nov 2008
    Posts
    17
    This is whats in the manual.

    12.12 M100 to M199 User Defined Commands
    To invoke a user-defined command, program M- P- Q- where P- and Q- are both optional. The
    external program “Mnnn” in the directory [DISPLAY]PROGRAM_PREFIX is executed with the P and Q
    values as its two arguments. Execution of the RS274NGC file pauses until the invoked program
    exits.
    It is an error if
    • The specified User Defined Command does not exist

    I dont what they mean by M- P- Q-. Also the external program "Mnnn" in the directroy [Display]Program_PREFIX is executed with P and Q values as its two arguments. They also talk about the RS274NGC file. I dont know what that is and where to find the file.

  4. #4
    Join Date
    Nov 2005
    Posts
    496
    Just to confirm- you want to use M100 to run a 'seperate program' to turn an output on or do you just want a M code to turn a output on?

    For M100 the m- is just the m number you used 100-199, p- and q- are variables that are passed to the seperate program like on the command line. A RS274NGC file is the original G code file. I think the seperate program needs to be named the same as the M number eg. M100 the program is called m100. The program prefix is probably where EMC is supposed to look for the seperate program. I will try to find out.

    If you just want an output turned on and off you want to use M62-65

  5. #5
    Join Date
    Nov 2005
    Posts
    496
    I asked on the EMC maillist here is what I got:

    >
    > Does this mean the external program must be named M100-199?

    Yes

    > What is meant by PROGRAM_PREFIX ? pathway?

    >From my lathe .ini file:
    ...
    # Sections for display options
    ------------------------------------------------
    [DISPLAY]
    DISPLAY = axis
    LATHE = 1
    PYVCP = spindle.xml

    # DISPLAY = usrmot
    # DISPLAY = tkemc

    CYCLE_TIME = 0.100
    HELP_FILE = doc/help.txt
    POSITION_OFFSET = RELATIVE
    POSITION_FEEDBACK = ACTUAL
    MAX_FEED_OVERRIDE = 1.2
    PROGRAM_PREFIX = ../../nc_files/
    ...

    you can see that the M1xx files will need to be two directories up from
    the current directory and in nc_files. I believe that makes
    it /home/user_name/emc2/nc_files. You can change PROGRAM_PREFIX if you
    want.

    > I assume the external program can be in any supported language or are
    > we talking G code?

    My guess is that you can not execute G-code, but bash, python, C or any
    non-real-time executable would work. I use a bash script to create
    missing g-codes for my lathe, such as M102 Collet Open:

    file = /home/kwallace/emc2/nc_files/M102

    -----------------
    #!/bin/sh

    # Custom - Only intended for Kirk Wallace's HNC lathe, KW 20070823
    # M102 - Opens Collet Closer
    halcmd setp parport.0.pin-07-out False
    halcmd setp parport.0.pin-06-out True

    exit 0
    -----------------

    I use M102 in my G-code files for opening the collet closer.

    hope that helps

  6. #6
    Join Date
    Feb 2007
    Posts
    514
    Jamy,

    In response to your question that chester88 posted on the users list and to Kirk's answer I have updated the manual. See if it makes more sense...

    http://www.linuxcnc.org/docview/html...:M100-to-M199:

    Thanks for asking the question.

    John

  7. #7
    Join Date
    Nov 2008
    Posts
    17
    How do I go about doing the M64 and M65 turning on the Digital output. I know in the program I just type M64. But in the HAL file?

  8. #8
    Join Date
    Feb 2007
    Posts
    514

  9. #9
    Join Date
    Nov 2008
    Posts
    17

    1 input to start program and continue program after a M0

    How do I create an input to start a program in EMC2. Also the same input to run the program after a M0 stop command. I was able to do start the program and when it got to M0 it stopped but when I pressed the input it started the program from the beginning. It seems like I need to do some sort of IF statement. If program.run and mode.auto is true then input only is used to program.run. Is there anyone that can help me?

  10. #10
    Join Date
    Apr 2005
    Posts
    1778
    Quote Originally Posted by Jamy View Post
    How do I create an input to start a program in EMC2. Also the same input to run the program after a M0 stop command. I was able to do start the program and when it got to M0 it stopped but when I pressed the input it started the program from the beginning. It seems like I need to do some sort of IF statement. If program.run and mode.auto is true then input only is used to program.run. Is there anyone that can help me?
    If you are just talking about resuming after an M0, I believe that you just press the 'S' key on the keyboard. This is like when the machine stops for a tool change, you have changed the tool and want to resume the run.

    Alan

  11. #11
    Join Date
    Nov 2008
    Posts
    17
    Yes I know the S will work and also clicking on the resume button on the screen. What I am refering to is a button used by a operator to start a program. I would like to use the same button to resume the program when the program is paused (M0). The only input the operator can toggle is this button. The button is setup like this remote-start halui.program.run halui.mode.auto = parport 15

    What Im going to try next is to create a manual and auto button on the screen. By selecting auto the switch can be configured as remote start halui.program. run halui.program.resume=parport 15. I have a feeling that it probaly will just start the program over with having Halui.program.run.

    Any other suggestions?

  12. #12
    Join Date
    Feb 2007
    Posts
    514
    If you use halui you can take advantage of the pins halui.program.is-paused, is-idle, resume, run to restart/start based on the current status. For this you use a logic operator to do the right thing.

    In your hal file you want to do the following pseudo code

    Code:
                                If paused then resume
    My button pressed |
                                If idle then start
    John

  13. #13
    Join Date
    Nov 2008
    Posts
    17
    Is that exactly how I would type it into Hal? Im trying to find a good resourse on hal and halui online where I can learn the proper way on doing things like this.

  14. #14
    Join Date
    Feb 2007
    Posts
    514
    No, that is pseudo code.

    All the online docs are here:

    http://www.linuxcnc.org/content/view/5/5/lang,en/

    The basic HAL page is here:

    http://www.linuxcnc.org/docview/html...basic_hal.html

    The halui page is here:

    http://www.linuxcnc.org/docview/html//gui_halui.html

    This should get you started... once you chew on that a bit and after you get halui added open up the Show HAL Configuration and look at the pins for halui.

    Hint you want to 'and2' two inputs and have the output of the 'and2' do the proper thing.

    John

  15. #15
    Join Date
    Nov 2008
    Posts
    17
    As of now there is only one input. That input is used to start a program. When a M0 is called in a program it pauses the program. I want the same input switch to resume the program.

  16. #16
    Join Date
    Feb 2007
    Posts
    514
    Exactly why you need the and2 component. What your wanting to do is:

    If the program is paused and the button is pressed then resume.
    If the program is not running and the button is pressed the start the program.

    So the button goes to both and2 components and is paused goes to one and2 and is idle goes to the second and2 component. The output of the one and2 component is resume and the output of the second and2 is start.

    Does this make sense now?

    John

  17. #17
    Join Date
    Feb 2007
    Posts
    514
    Or jump on the IRC from this page and we can chat...

    http://www.linuxcnc.org/content/view/4/8/lang,en/

    John

  18. #18
    Join Date
    Nov 2008
    Posts
    17
    I sort of understand.
    So if I put this in the hal file it should work?

    net RemoteStart and 2.0.in.0 <= paraport0.pin-15-in
    net OktoRun and2.0.in.1 <= halui.program.idle
    net Run halui.program.run <= and2.0.out

    net RemoteStart and 2.1.in.0 <= paraport0.pin-15-in
    net OktoResume and2.1.in.1 <= halui.program.paused
    net Resume halui.program.run <= and2.1.out

  19. #19
    Join Date
    Feb 2007
    Posts
    514
    That's pretty close. You will need to load the two and2 and add them as shown in the link. Also you will get an error trying to create the same signal twice I believe. I think your starting to understand now Pay attention to which hal file you add the above to.

    Start by loading the and2's then start EMC if you get an error look at the bottom of the list for a hint.

    Have Fun
    John

  20. #20
    Join Date
    Nov 2008
    Posts
    17
    ok, I entered the script and corrected the errors. But it does not and the two signals. I checked the hal meter for the two inputs and they are true but the output is not. Here is the script. Do I need to add something else?

    loadrt and2 count=2
    addf and2.0 servo-thread

    net RemoteStart and2.0.in0 <= parport.0.pin-15-in-not
    net OktoRun and2.0.in1 <= halui.program.is-idle
    net Run halui.program.run <= and2.0.out

    net RemoteStart and2.1.in0 <= parport.0.pin-15-in-not
    net OktoResume and2.1.in1 <= halui.program.is-paused
    net Resume halui.program.resume <= and2.1.out

Page 1 of 2 12

Similar Threads

  1. M8 still not being red by EMC2
    By CROSSHATCH in forum LinuxCNC (formerly EMC2)
    Replies: 27
    Last Post: 04-13-2008, 09:36 PM
  2. EMC2 to diy CNC
    By dakiller322 in forum LinuxCNC (formerly EMC2)
    Replies: 11
    Last Post: 10-05-2007, 06:16 AM
  3. Emc2
    By sdantonio in forum Mach Mill
    Replies: 2
    Last Post: 02-05-2007, 09:26 PM
  4. emc2 -hal*?
    By essa in forum LinuxCNC (formerly EMC2)
    Replies: 3
    Last Post: 05-27-2006, 06:06 PM
  5. emc2
    By heilcnc in forum LinuxCNC (formerly EMC2)
    Replies: 2
    Last Post: 05-23-2006, 11:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •