584,865 active members*
4,957 visitors online*
Register for free
Login
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2020
    Posts
    15

    Expr.txt and issues with Inputs

    Hi,

    I recently created a script using the Expr.txt file, in order to check whether input 2 is activated before starting a program and to display an error message accordingly. I use an Mk3/4 controller by the way. Here is the short line of code:

    if (_hw_input_num|2==1 && _hw_isprog==1,exec(cmd('Machine.Emergency_Stop'),m sg("Emergency Stop: the security enclosure has been opened during a program. Please close it and start the program again.")))

    To give a bit of context, this input is connected to a reed switch, which is placed on the door of an enclosure surrounding my machine. If the door is open, input 2 is high and it is impossible to start a G-code.

    Everything works very nicely, but I started to notice weird behaviors from the controller when the door is open (input2=1). For instance, the homing procedure doesn't work correctly, but it starts working perfectly again if I close the door. If I manually jog an axis and I suddenly open the door while doing so, the motion stops or gets jerky if I open/close several times.

    Then I started to wonder if the issue also existed with outputs, and found the same problem. Even if nothing is connected to any output, turning on and off the spindle icon while jogging an axis will make it stop or get jerky as well.

    Is there any explanation of how the firmware/controller works to help me understand this? Or is it something else that I'm missing?

    Thanks for the help!

  2. #2
    Join Date
    Jan 2022
    Posts
    107

    Re: Expr.txt and issues with Inputs

    I had some "funny" problems using expr.txt and it seems that the comparison with && does not always do, what expected. That may because of the used language for that syntax.

    So try the following first:

    change
    if (_hw_input_num|2==1 && _hw_isprog==1,exec(cmd('Machine.Emergency_Stop'),m sg("Emergency Stop: the security enclosure has been opened during a program. Please close it and start the program again.")))

    to
    if (and(_hw_input_num|2==1, _hw_isprog==1),exec(cmd('Machine.Emergency_Stop'), msg("Emergency Stop: the security enclosure has been opened during a program. Please close it and start the program again.")))

  3. #3
    Join Date
    Mar 2017
    Posts
    1295

    Re: Expr.txt and issues with Inputs

    @mgravet
    Please export your profile and send it to our support.

    @awpross
    "&&" is logic AND. Function "and" is bitwise AND. Logic AND function is "land".

  4. #4
    Join Date
    May 2020
    Posts
    15

    Re: Expr.txt and issues with Inputs

    Hi,

    @awpross, thanks for the reply. I tried to rework the syntax as you mentioned but the problem is still there.

    @planetcnc I just sent an email to support.

Similar Threads

  1. [TNGv2] - Expr.txt
    By PlanetCNC in forum PlanetCNC
    Replies: 14
    Last Post: 05-29-2023, 06:20 PM
  2. Activate optional Pause in Expr.txt
    By awpross in forum PlanetCNC
    Replies: 3
    Last Post: 02-26-2022, 08:37 PM
  3. TNGv2 Expr.txt usage
    By theRat in forum PlanetCNC
    Replies: 12
    Last Post: 08-07-2020, 10:57 AM
  4. How do the inputs on the DSP controller effect inputs from CAm software
    By bensteele1994 in forum CNC Machine Related Electronics
    Replies: 1
    Last Post: 02-16-2019, 08:59 PM

Tags for this Thread

Posting Permissions

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