Changing Pulley Selection with a button

If you have a question about the software please ask it here.

Changing Pulley Selection with a button

Postby MattTheNoob » Fri Sep 04, 2020 12:34 am

I'm trying to set up buttons to change between my two pulley options and also change the encoder PPR at the same time. (The PPR part is working fine. Dezsoe hooked me up almost 2 years ago... http://cncdrive.com/forum/viewtopic.php?f=4&t=1608 Where does the time go?)

For the pulley, I'm using the setfield for pulley number, but when I press the "apply" button or callbutton(168), the pulley selection goes back to the previous setting. I'm thinking that I need to call "M215 P1" or "M215 P2" from the button macro, but I'm not sure how to call a macro from a macro.

Code: Select all
   AS3.Switchbutton(true, 20055);
   AS3.SetLED(true, 455);
   AS3.Setfield(1,2013); // Sets pulley number to 1

   AS3.Switchbutton(false, 20056); //this turns off the other button that sets the pulley number to 2
   AS3.SetLED(false, 456);

   AS3.Setfield(113, 864); // set new value into field 864
   AS3.Validatefield(864); // Validate
   exec.Callbutton(168); // Apply settings
MattTheNoob
Bostomatic 405 with updated controls... now entering Rev.2
UC300eth-5lpt, ModBus talking to Click PLC, Arduino Gecko servo monitor
Total UC noob.
MattTheNoob
 
Posts: 53
Joined: Sat Nov 03, 2018 3:36 pm

Re: Changing Pulley Selection with a button

Postby dezsoe » Fri Sep 04, 2020 5:32 am

Just 2 more lines. First you have to wait for the apply to finish, then call the M215:

Code: Select all
   AS3.Switchbutton(true, 20055);
   AS3.SetLED(true, 455);
   AS3.Setfield(1,2013); // Sets pulley number to 1

   AS3.Switchbutton(false, 20056); //this turns off the other button that sets the pulley number to 2
   AS3.SetLED(false, 456);

   AS3.Setfield(113, 864); // set new value into field 864
   AS3.Validatefield(864); // Validate
   exec.Callbutton(168); // Apply settings

   while (AS3.Getbuttonstate(168)); // Wait for the apply to finish
   exec.Code("M215 P1"); // Change pulley
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Changing Pulley Selection with a button

Postby MattTheNoob » Fri Sep 04, 2020 12:01 pm

Ah, Exec.code! I didn't know that trick. Thanks!

So let me ask this... if I do the exec.code "M215 P1" do I even need to do the "as3.setfield (1,2013)" part to change the pulley number to 1?
MattTheNoob
Bostomatic 405 with updated controls... now entering Rev.2
UC300eth-5lpt, ModBus talking to Click PLC, Arduino Gecko servo monitor
Total UC noob.
MattTheNoob
 
Posts: 53
Joined: Sat Nov 03, 2018 3:36 pm

Re: Changing Pulley Selection with a button

Postby dezsoe » Fri Sep 04, 2020 12:26 pm

No, M215 will change it.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Changing Pulley Selection with a button

Postby MattTheNoob » Fri Sep 04, 2020 4:35 pm

That works perfectly! For anyone else trying this, here's the final form of the macros to change pulleys and spindle PPR with push buttons.


Change to Pulley 1
Code: Select all
//
//   M20055 is the Macro for setting the High spindle pulley
//

   AS3.Switchbutton(true, 20055);
   AS3.SetLED(true, 455);

   AS3.Switchbutton(false, 20056);
   AS3.SetLED(false, 456);

   AS3.Setfield(113, 864); // set new PPR value into field 864
   AS3.Validatefield(864); // Validate

   exec.Callbutton(168); // Apply settings
   while (AS3.Getbuttonstate(168)); // Wait for the apply to finish
   exec.Code("M215 P1"); // Change pulley


Change to pulley 2
Code: Select all
//
//   M20056 is the Macro for setting the LOW spindle pulley
//

   AS3.Switchbutton(true, 20056);
   AS3.SetLED(true, 456);

   AS3.Switchbutton(false, 20055);
   AS3.SetLED(false, 455);

   AS3.Setfield(607, 864); // set new PPR value into field 864
   AS3.Validatefield(864); // Validate

   exec.Callbutton(168); // Apply settings
   while (AS3.Getbuttonstate(168)); // Wait for the apply to finish
   exec.Code("M215 P2"); // Change pulley
Attachments
pulley buttons.png
MattTheNoob
Bostomatic 405 with updated controls... now entering Rev.2
UC300eth-5lpt, ModBus talking to Click PLC, Arduino Gecko servo monitor
Total UC noob.
MattTheNoob
 
Posts: 53
Joined: Sat Nov 03, 2018 3:36 pm


Return to Ask a question from support here

Who is online

Users browsing this forum: Bing [Bot] and 33 guests