Pop Up Reminder


Results 1 to 14 of 14

Thread: Pop Up Reminder

  1. #1
    Member Need TECH Help!'s Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    578
    Downloads
    0
    Uploads
    0

    Default Pop Up Reminder

    Tom,
    I decided to move this topic from yahoo group. Maybe someone else might be able to use it. And having it on CNC Zone makes it easier.

    Original post from Yahoo Group.....

    On 12/31/2017 1:05 PM, T Day [DynoMotion] wrote:

    Hello Tom,
    Looking for a way to have a pop up reminder.
    My VFD will run on Single or 3Phase, but its not recommended to run it on Single phase with my 10 HP motor.The 3 phase converter iam running allows the single phase 220 line to pass on through to machine, even with converter off.
    So what i need is a reminder to tell me to turn on phase converter. How could KMCNC be set to pop up a message the first time a spindle command is executed? Whether it be by Gcode or a button.


    Troy


    Sent: Sunday, December 31, 2017 4:19 PM
    I'm not sure I understand, but you might add a message box to the Spindle on (M3/M4) C Program such as "Converter ON?" with Yes No buttons. Halt without turning on the spindle for No.

    A Virtual Bit could be used as a flag to indicate whether the question has ever been ever answered Yes.

    It isn't clear when the Converter might be turned off and you would want to ask the question again. After Cycle Power on KFLOP? After relaunching KMotionCNC? After not running the Spindle for 5 minutes?

    Can you interface the Converter status to KFLOP?

    Regards
    TK


    On 1/3/2018 1:36 PM, 'T Day' [DynoMotion] wrote:

    Hi Tom,
    Do you have an example of using virtual bit as you described?

    Thanks,
    Troy


    Sent: Wednesday, January 03, 2018 7:04 PM
    Hi Troy,

    Bits 48-63 are Virtual. They are guaranteed to be 0 on power up.

    So you would do something like:

    if (!ReadBit(48)) // is the bit set indicating the Operator answered yes?
    {
    // no, ask the question
    .
    .
    .
    // Operator Answered Yes - set the Bit to remember this
    SetBit(48);
    }
    HTH
    Regards
    TK


    Similar Threads:
      www.tsjobshop.com, www.homecncstuff.elementfx.com


    • #2
      Member Need TECH Help!'s Avatar
      Join Date
      Dec 2007
      Location
      United States
      Posts
      578
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Tom,
      I altered my M3 c code program to have a Pop up asking if converter is on. And that much works. Now how can Pop up be skipped
      if the Virtual Bit 48 is set? Is there an ‘if ignore’ statement of some sort?

      Here is my program so far….

      Code:
      //Added Pop up to ask if 3 phase converter is turned on.
      #include "KMotionDef.h"
      #define TMP 10 // which spare persist to use to transfer data
      #include "KflopToKMotionCNCFunctions.c"
      
      main()
      {
      	
      	int Answer;
      
      	Answer = MsgBox("Is 3phase Converter On?",MB_YESNO|MB_ICONEXCLAMATION);
      	if (Answer == IDYES)
      		//printf("Answer is Yes\n");
      		{
      		SetBit(48);
      		ClearBit(148); //Spindle CCW bit
      		Delay_sec(.2);
      		SetBit(147); // turn on spindle clockwise
      		}
      	
      	else
      		//printf("Answer is No\n");
      		{
      		ClearBit(48);
      		SetBit(147); // turn off spindle clockwise
      		SetBit(148); // turn off spindle counterclockwise
      	}		
      				
      }
      Thanks,
      Troy

      www.tsjobshop.com, www.homecncstuff.elementfx.com


    • #3
      Member TomKerekes's Avatar
      Join Date
      May 2006
      Location
      USA
      Posts
      4043
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Troy,

      Just use an "if" statement to only execute the message box stuff if the Virtual bit is NOT set.

      if (!ReadBit(48)) // is the virtual bit not set indicating the Operator hasn't already answered yes?
      {


      }

      (Note when posting code in cnczone you must un-tabify the text in order for the formatting to come out properly. There is a button in Visual Studio under Edit | Advanced untabify to do that for you)

      HTH
      Regards

      Regards
      TK http://dynomotion.com


    • #4
      Member Need TECH Help!'s Avatar
      Join Date
      Dec 2007
      Location
      United States
      Posts
      578
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Tom,
      Have it some what working now. When i MDI a M3 or M4 command it works. After pop up is answered YES, executing another M3 or M4 does not cause another pop up until bit 48 is cleared.This is good.

      But when i try to use the on screen CW or CCW spindle buttons, the first click of button there is no spindle movement and bit 48 gets cleared. Then after second click of button i get the pop up again, obviously because bit 48 got switched off.
      So why do the buttons not work like the M3 or M4 MDI command?

      Below is my code for M3. I think i formatted as you suggest. Iam not using VS, just copied code from Kmotion. Didnt see an option to untabify there.

      Code:
      //Added Pop up to ask if 3 phase converter is turned on.
      #include "KMotionDef.h"
      #define TMP 10 // which spare persist to use to transfer data
      #include "KflopToKMotionCNCFunctions.c"
      
      main()
      {
      	
      int Answer;
      if (!ReadBit(48)) // is the virtual bit not set indicating the Operator hasn't already answered yes?
      
      Answer = MsgBox("Is 3phase Converter On?",MB_YESNO|MB_ICONEXCLAMATION);
      if (Answer == IDYES)
      //printf("Answer is Yes\n");
      {
      SetBit(48);
      ClearBit(148); //Spindle CCW bit
      Delay_sec(.2);
      SetBit(147); // turn on spindle clockwise
      }
      	
      else
      //printf("Answer is No\n");
      {
      ClearBit(48);
      SetBit(147); // turn off spindle clockwise
      SetBit(148); // turn off spindle counterclockwise
      }		
      				
      }


      www.tsjobshop.com, www.homecncstuff.elementfx.com


    • #5
      Member TomKerekes's Avatar
      Join Date
      May 2006
      Location
      USA
      Posts
      4043
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Troy,

      Hmmm Its a bit technical but I think the issue comes about because if the Windows GUI Thread is blocking then the MessageBox can not be displayed. So the problem only arises when a GUI Button invokes the code. The push button is waiting for the code to finish, but the code can't finish because it needs to display a MessageBox, but the MessageBox can't display until the push button finishes.This is sometimes referred to as a deadly embrace.

      This has come up before and there is usually some reasonable workaround. But I don't see one in this case.

      Possible solutions could be:

      #1 change pushbuttons to never wait for Actions to complete

      #2 change pushbuttons to invoke actions from a worker Thread on the PC

      Please give us some time to come up with the best solution.

      Regards
      TK http://dynomotion.com


    • #6
      Member Need TECH Help!'s Avatar
      Join Date
      Dec 2007
      Location
      United States
      Posts
      578
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Tom,
      Looks like i opened another can of worms No rush at all. Idea tho... would it make a difference if the buttons where set to execute the M code program?

      Troy

      www.tsjobshop.com, www.homecncstuff.elementfx.com


    • #7
      Member TomKerekes's Avatar
      Join Date
      May 2006
      Location
      USA
      Posts
      4043
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Troy,

      Idea tho... would it make a difference if the buttons where set to execute the M code program?
      I was thinking along those lines but not really. The Spindle On button already does invoke the M3 Action. If M3 invoked the Interpreter to do something then it would be a re-entrant call to the Interpreter when M3 is called from GCode.

      Please see if this new Version Solves the problem. GUI Buttons that invoke actions now create a Worker Thread on the PC to perform the Action which releases the GUI Thread. Therefore if he Action need to display a message on the GUI and wait for a response it should work,

      KMotion 4.34k

      Changes

      Please let us know if there are any issues

      Thanks

      Regards
      TK http://dynomotion.com


    • #8
      Member Need TECH Help!'s Avatar
      Join Date
      Dec 2007
      Location
      United States
      Posts
      578
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hay Tom,
      Sorry just getting back, been busy.
      I have v 4.34K installed. But still have same issue as before. When i execute a M3 or M4 by MDI pop up works correctly. But if i use the on screen buttons for turning on spindle, the first click causes the Virtual Bit to clear, then 2nd click causes pop up.
      Was there something c code wise i needed to change for this Kmotion version?

      Thanks,
      Troy

      www.tsjobshop.com, www.homecncstuff.elementfx.com


    • #9
      Member TomKerekes's Avatar
      Join Date
      May 2006
      Location
      USA
      Posts
      4043
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Troy,

      I checked here and it seemed to work for me but I noticed a bug in the M3 C Program. The "if" condition when checking the Virtual bit doesn't have curly brackets to skip everything like we want. Without them it only skips asking the question but still does the rest which uses an Answer that wasn't ever asked. So the results could be wrong and unpredictable. Below is the corrected code.

      Code:
      //Added Pop up to ask if 3 phase converter is turned on.
      #include "KMotionDef.h"
      #define TMP 10 // which spare persist to use to transfer data
      #include "KflopToKMotionCNCFunctions.c"
      
      main()
      {
          int Answer;
          if (!ReadBit(48)) // is the virtual bit not set indicating the Operator hasn't already answered yes?
          {
              Answer = MsgBox("Is 3phase Converter On?",MB_YESNO|MB_ICONEXCLAMATION);
              if (Answer == IDYES)
              //printf("Answer is Yes\n");
              {
                  SetBit(48);
                  ClearBit(148); //Spindle CCW bit
                  Delay_sec(.2);
                  SetBit(147); // turn on spindle clockwise
              }
              else
              //printf("Answer is No\n");
              {
                  ClearBit(48);
                  SetBit(147); // turn off spindle clockwise
                  SetBit(148); // turn off spindle counterclockwise
              }        
          }                
      }

      BTW On a related note when posting code to cnczone if you don't want to use Visual Studio to format and untab code you can change tabs to 4 spaces using the Find/Replace in KMotion. Right click at the beginning of the file, Find/Replace, Select Regular expressions, find /t (tab), replace with 4 spaces, then Replace All.

      Pop Up Reminder-replacetabs-png

      Thanks again for taking the time for this.

      Regards

      Regards
      TK http://dynomotion.com


    • #10
      Member Need TECH Help!'s Avatar
      Join Date
      Dec 2007
      Location
      United States
      Posts
      578
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Tom,
      I tried code you posted and pop works but there is a different issue now. After user answers Yes, bit is set on and spindle starts. Then after spindle is stopped and a M3 or on screen button is executed the spindle does not start. Only way to restart spindle is to clear bit 48 using Kmotion. Also noticed that when trying to restart spindle, after pop up has been answered yes, that the Axis dros turn yellow then back to green and the jog buttons gray out.

      As for tabs in c code i didnt know that tabs should be removed and space used. Can using tabs cause issues? As iam sure i have them in other programs.

      Thanks again,
      Troy

      www.tsjobshop.com, www.homecncstuff.elementfx.com


    • #11
      Member TomKerekes's Avatar
      Join Date
      May 2006
      Location
      USA
      Posts
      4043
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Troy,

      After user answers Yes, bit is set on and spindle starts. Then after spindle is stopped and a M3 or on screen button is executed the spindle does not start. Only way to restart spindle is to clear bit 48 using Kmotion.
      Well duhhh. Once the Virtual bit is ever set we do nothing so of course the Spindle never comes on. The Virtual bit should just skip asking the question with an assumed response of Yes.

      Another issue that just occurred to me. If during a Job the Operator was to answer "no" then the Spindle wouldn't be turned on but the Job would continue which could be bad. So in that case I think the Job should be Halted.

      I've tried to fix those two issues in the code below:
      Code:
      //Added Pop up to ask if 3 phase converter is turned on.
      #include "KMotionDef.h"
      #define TMP 10 // which spare persist to use to transfer data
      #include "KflopToKMotionCNCFunctions.c"
      
      main()
      {
          int Answer=IDYES; // assume ok to turn on
          
          if (!ReadBit(48))// is the virtual bit not set indicating the Operator hasn't already answered yes? 
              Answer = MsgBox("Is 3phase Converter On?",MB_YESNO|MB_ICONEXCLAMATION);
          
          if (Answer == IDYES)
          {
              //printf("Answer is Yes\n");
              SetBit(48);  // set Virtual bit to not ask again
              ClearBit(148); //Spindle CCW bit
              Delay_sec(.2);
              SetBit(147); // turn on spindle clockwise
          }
          else
          {
              //printf("Answer is No\n");
              SetBit(147); // turn off spindle clockwise
              SetBit(148); // turn off spindle counterclockwise
      
              // if running a Job and Spindle isn't to be turned on Halt the Job
              if (JOB_ACTIVE)
                  DoPC(PC_COMM_HALT);
          }        
      }

      Also noticed that when trying to restart spindle, after pop up has been answered yes, that the Axis dros turn yellow then back to green and the jog buttons gray out.
      I don't see that here. Let's fix the issues above and then see if there is still an issue.

      As for tabs in c code i didnt know that tabs should be removed and space used. Can using tabs cause issues? As iam sure i have them in other programs.
      There isn't a problem with using tabs or spaces. The only problem is with posting code into a cnczone post it looks ugly, indented improperly, and hard to read. So change all the tabs to spaces so it looks pretty.

      Regards
      TK http://dynomotion.com


    • #12
      Member Need TECH Help!'s Avatar
      Join Date
      Dec 2007
      Location
      United States
      Posts
      578
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Tom,
      You say duhh, i say wow cause i dont know anything
      It appears to be working now. DROs still flash yellow and jog buttons gray. No worries for me unless it is a symptom of something else.

      Good catch on halting gcode if user selects no Tried this and even tho pop up is active the gcode continues until user answers No, then gcode halts.

      Noted on tabs, thanks.

      www.tsjobshop.com, www.homecncstuff.elementfx.com


    • #13
      Member TomKerekes's Avatar
      Join Date
      May 2006
      Location
      USA
      Posts
      4043
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hi Troy,

      It appears to be working now. DROs still flash yellow and jog buttons gray. No worries for me unless it is a symptom of something else.
      Is this with an MDI or button?

      Good catch on halting gcode if user selects no Tried this and even tho pop up is active the gcode continues until user answers No, then gcode halts.
      Check if you have "Exec/Wait" selected for the M3 Action. If set to wait then GCode should not continue until the User answers the question.

      Regards

      Regards
      TK http://dynomotion.com


    • #14
      Member Need TECH Help!'s Avatar
      Join Date
      Dec 2007
      Location
      United States
      Posts
      578
      Downloads
      0
      Uploads
      0

      Default Re: Pop Up Reminder

      Hay Tom,

      Is this with an MDI or button?
      Its with both. This also happens when a M6 T is executed from GCode. This has always been like this, not just this version of Kmotion.

      Check if you have "Exec/Wait" selected for the M3 Action. If set to wait then GCode should not continue until the User answers the question
      .

      Duhh.. moment for me. I actually knew about this one. It was set to Execute. Changing it to "Exec/Wait" fixed it.

      Thanks,
      Troy

      www.tsjobshop.com, www.homecncstuff.elementfx.com


    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
    •  


    About CNCzone.com

      We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

    Follow us on


    Our Brands

    Pop Up Reminder

    Pop Up Reminder