Dynomotion

Group: DynoMotion Message: 1817 From: wcarrothers Date: 9/23/2011
Subject: Trigger in Mach
Hello.

Just got my pendant working and I set it up with an axis selector switch so each axis could jog on one optical in Oder. I have things moving but also wanted to have a button on the control that when pressed it would trigger another digital input. So that input bit + which ever input bit is selected for jogging would zero that axis in Mach. Figure there has to be some code out there for doing that.

Also. Want to get smoother movement when spinning the encoder for fast jogging. Didn't know if there was a trick to that.

I know I should post the code I'm using but pretty much starting with the standard Mach with 2 mpg c code..

B.

B.
Group: DynoMotion Message: 1821 From: wcarrothers Date: 9/24/2011
Subject: Re: Trigger in Mach
basicly for the MPG move I'm useing code similar to the code in the Init3AnalogPlusMPG.c file. made some changes as I have 4 speed selections. But I was wondering, at higher factors and higher MPG rotation speeds things get a little jerkey. Wondering if anyone have a suggestion on adding code to smooth it out a bit at higher speeds?


And like I said in the earler post. I would like to add code also, so I could have an jog bit selected and if another button (bit) is pressed while that is active it would zero that axis. Anyone have an idea how to do that?

I know within MACH you can set it up with the OEM Triggers and OEM codes to do something like that. How ever that looks more to react to 1 bit of intput rather then 2, and I was looking to avoid having to have 4 separate I/O buttons for each axis I have to zero (X,Y, Z1 and Z2)..

Thanks for any help.

sorry for not being more spacific in earler message


for(;;)
{
WaitNextTimeSlice();

// convert quadrature to 2 bit binary
BitA = ReadBit(QA);
PosNoWrap = (ReadBit(QB) ^ BitA) | (BitA<<1);

// Diff between expected position based on average of two prev deltas
// and position with no wraps. (Keep as X2 to avoid division by 2)

DiffX2 = 2*(Pos-PosNoWrap) + (Change2+Change1);

// Calc quadrature wraparounds to bring Diff nearest zero
// offset by 128 wraps to avoid requiring floor()
wraps = ((DiffX2+1028)>>3)-128;

// factor in the quadrature wraparounds
NewPos = PosNoWrap + (wraps<<2);

Change2 = Change1;
Change1 = NewPos - Pos;
Pos = NewPos;

if (ReadBit(31)) // is X1 selected?
Factor = 1.0;
else if (ReadBit(32)) // is X100 selected?
Factor = 75.0;
else // must be X10 then
Factor = 10.0;

if (ReadBit(28)) // is x selected?
ch0->Dest += Change1 * Factor;
else if (ReadBit(29)) // is y selected?
ch1->Dest += Change1 * Factor;
else if (ReadBit(30)) // is z selected?
ch2->Dest += Change1 * Factor;

}


--- In DynoMotion@yahoogroups.com, "wcarrothers" <wcarrothers@...> wrote:
>
> Hello.
>
> Just got my pendant working and I set it up with an axis selector switch so each axis could jog on one optical in Oder. I have things moving but also wanted to have a button on the control that when pressed it would trigger another digital input. So that input bit + which ever input bit is selected for jogging would zero that axis in Mach. Figure there has to be some code out there for doing that.
>
> Also. Want to get smoother movement when spinning the encoder for fast jogging. Didn't know if there was a trick to that.
>
> I know I should post the code I'm using but pretty much starting with the standard Mach with 2 mpg c code..
>
> B.
>
> B.
>
Group: DynoMotion Message: 1822 From: Tom Kerekes Date: 9/24/2011
Subject: Re: Trigger in Mach
Hi Bill,
 
Here is another method of handling an MPG that makes smoother motion.  It uses the KFLOP Exponential Move command to follow the "stepped" position resulting from the handwheel.  There is a Tau parameter you can vary to control the smoothness.  A larger time constant will move slower/smoother, but will be less responsive.  There is also a "FINAL_TIME" setting where after converging for that amount of time toward the final target, if there is no further handwheel motion it will then make a linear move to that destination.
 
 
 
 
Regarding the MPG "Zero" feature there are a few approaches you could take:
 
#1 - zero the position in KFLOP.  This would be simplest but probably not what you want as it would zero the Mach3 Machine coordinates not the "work" coordinates.
 
#2 - I'm not that familiar with creating Mach3 Screens and VB, but as you stated I think you can configure an External Trigger as a hot key to push a button. (I don't know if there is a way to trigger execution of VB directly.  You could then add VB that would check your other inputs to see which axis was selected and then conditionally execute one of the following: 
 
DoOEMButton (1008) 'calculate x work offset
DoOEMButton (1009) 'calculate y work offset
DoOEMButton (1010) 'calculate z work offset
 
#3 - Probably the best option would be to use KFLOP C code to create 3 simulated virtual inputs for Mach3.  KFLOP allows you to read, set, clear 16 virtual IO bits 48-63.  Virtual IO bits exist in KFLOP Memory only and don't go out to real physical pins.  But Mach3 can read them as if they were real inputs.  The code below will map one real "Zero" pushbutton input (35) to 3 virtual "Zero" inputs (48,49,50).  You could then configure Mach3 for 3 External Triggers to do individual Zeros.    Add this code to your MPG loop so it executes periodically every time slice.  
 
HTH
Regards
TK
 
 
 if (ReadBit(35))  // Zero button pushed??
 {
  if (ReadBit(28))  // is x selected?
   SetBit(48);
  else if (ReadBit(29))  // is y selected?
   SetBit(49);
  else if (ReadBit(30))  // is z selected?
   SetBit(50);
 }
 else
 {
  ClearBit(48);
  ClearBit(49);
  ClearBit(50);
 }
 
 
Group: DynoMotion Message: 1823 From: william Carrothers Date: 9/24/2011
Subject: Re: Trigger in Mach
Aaa  yes..  I like the set bit and clear bit aproch.  basicly mach only needs 1 signal to do each action but can't valicate 2 being on.  So validate the 2 bits being on and use that to set a 3 rd bit which mach is watching (but I'm not using for anything else)..    Sounds good to me.  Are bits 48,49 and 50 open to use or connected to anything else?   Guessing/Wondering if there are a group of bits out there that are avaliable for us to pass info through...
 
b.
 
 
 
 
--- On Sat, 9/24/11, Tom Kerekes <tk@...> wrote:

From: Tom Kerekes <tk@...>
Subject: Re: [DynoMotion] Re: Trigger in Mach
To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
Date: Saturday, September 24, 2011, 3:34 PM

 
Hi Bill,
 
Here is another method of handling an MPG that makes smoother motion.  It uses the KFLOP Exponential Move command to follow the "stepped" position resulting from the handwheel.  There is a Tau parameter you can vary to control the smoothness.  A larger time constant will move slower/smoother, but will be less responsive.  There is also a "FINAL_TIME" setting where after converging for that amount of time toward the final target, if there is no further handwheel motion it will then make a linear move to that destination.
 
 
 
 
Regarding the MPG "Zero" feature there are a few approaches you could take:
 
#1 - zero the position in KFLOP.  This would be simplest but probably not what you want as it would zero the Mach3 Machine coordinates not the "work" coordinates.
 
#2 - I'm not that familiar with creating Mach3 Screens and VB, but as you stated I think you can configure an External Trigger as a hot key to push a button. (I don't know if there is a way to trigger execution of VB directly.  You could then add VB that would check your other inputs to see which axis was selected and then conditionally execute one of the following: 
 
DoOEMButton (1008) 'calculate x work offset
DoOEMButton (1009) 'calculate y work offset
DoOEMButton (1010) 'calculate z work offset
 
#3 - Probably the best option would be to use KFLOP C code to create 3 simulated virtual inputs for Mach3.  KFLOP allows you to read, set, clear 16 virtual IO bits 48-63.  Virtual IO bits exist in KFLOP Memory only and don't go out to real physical pins.  But Mach3 can read them as if they were real inputs.  The code below will map one real "Zero" pushbutton input (35) to 3 virtual "Zero" inputs (48,49,50).  You could then configure Mach3 for 3 External Triggers to do individual Zeros.    Add this code to your MPG loop so it executes periodically every time slice.  
 
HTH
Regards
TK
 
 
 if (ReadBit(35))  // Zero button pushed??
 {
  if (ReadBit(28))  // is x selected?
   SetBit(48);
  else if (ReadBit(29))  // is y selected?
   SetBit(49);
  else if (ReadBit(30))  // is z selected?
   SetBit(50);
 }
 else
 {
  ClearBit(48);
  ClearBit(49);
  ClearBit(50);
 }
 
 
Group: DynoMotion Message: 1824 From: william Carrothers Date: 9/24/2011
Subject: Re: Trigger in Mach
And just to clarify,  I really like the responsiveness of movememnt the Kflop gives on my hand wheel.....  Reason for the question is I've gotten used to doing fast jogging with hand wheels on my other machine so I hardly ever use the buttons for moves in mach. 
 
So was talking about smoothing movement when trying to do 10x speed moves (say 500ipm hand wheel jogging.) which wanted to smooth out a bit.
 
Anywho..  As always I come away thinking how cool the K's are and wishing I'd finish this machine already!!!...
 
b.

--- On Sat, 9/24/11, Tom Kerekes <tk@...> wrote:

From: Tom Kerekes <tk@...>
Subject: Re: [DynoMotion] Re: Trigger in Mach
To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
Date: Saturday, September 24, 2011, 3:34 PM

 
Hi Bill,
 
Here is another method of handling an MPG that makes smoother motion.  It uses the KFLOP Exponential Move command to follow the "stepped" position resulting from the handwheel.  There is a Tau parameter you can vary to control the smoothness.  A larger time constant will move slower/smoother, but will be less responsive.  There is also a "FINAL_TIME" setting where after converging for that amount of time toward the final target, if there is no further handwheel motion it will then make a linear move to that destination.
 
 
 
 
Regarding the MPG "Zero" feature there are a few approaches you could take:
 
#1 - zero the position in KFLOP.  This would be simplest but probably not what you want as it would zero the Mach3 Machine coordinates not the "work" coordinates.
 
#2 - I'm not that familiar with creating Mach3 Screens and VB, but as you stated I think you can configure an External Trigger as a hot key to push a button. (I don't know if there is a way to trigger execution of VB directly.  You could then add VB that would check your other inputs to see which axis was selected and then conditionally execute one of the following: 
 
DoOEMButton (1008) 'calculate x work offset
DoOEMButton (1009) 'calculate y work offset
DoOEMButton (1010) 'calculate z work offset
 
#3 - Probably the best option would be to use KFLOP C code to create 3 simulated virtual inputs for Mach3.  KFLOP allows you to read, set, clear 16 virtual IO bits 48-63.  Virtual IO bits exist in KFLOP Memory only and don't go out to real physical pins.  But Mach3 can read them as if they were real inputs.  The code below will map one real "Zero" pushbutton input (35) to 3 virtual "Zero" inputs (48,49,50).  You could then configure Mach3 for 3 External Triggers to do individual Zeros.    Add this code to your MPG loop so it executes periodically every time slice.  
 
HTH
Regards
TK
 
 
 if (ReadBit(35))  // Zero button pushed??
 {
  if (ReadBit(28))  // is x selected?
   SetBit(48);
  else if (ReadBit(29))  // is y selected?
   SetBit(49);
  else if (ReadBit(30))  // is z selected?
   SetBit(50);
 }
 else
 {
  ClearBit(48);
  ClearBit(49);
  ClearBit(50);
 }
 
 
Group: DynoMotion Message: 1825 From: Tom Kerekes Date: 9/24/2011
Subject: Re: Trigger in Mach
Hi Bill,
 
Yes bits 48-63 are available for you to use.  These are "virtual" IO Bits that are not actually connected to anything, but that can be set, cleared, and read by KFLOP and the PC (Mach3).
 
TK

Group: DynoMotion Message: 1826 From: Tom Kerekes Date: 9/24/2011
Subject: Re: Trigger in Mach
Hi Bill,
 
Not sure if the comment on 10X speed moves is a question or a statement.  If you switch to the new method the motion should then be very smooth.
 
Thanks
TK

Group: DynoMotion Message: 1827 From: william Carrothers Date: 9/24/2011
Subject: Re: Trigger in Mach
Was not a question.  Just a statement that I was doing 1.0 and then 5.0 and when I went to 10.0 as a factor in the orignal jog code I could not rotate smoothly enough to get smooth fast movememnt.  Just the K doing its job following as exactly as I could rotate and of course at 10x  it amplified my in ability to rotate the knob smoothly as fast as I was going.

Will try the suggested code..
 
Cool to know about the virtual bits as well.  Not sure if I overlooked that those existed or not.  But for sure the easy way to do it. 
 
Thanks!!! 
 
b;
 


--- On Sat, 9/24/11, Tom Kerekes <tk@...> wrote:

From: Tom Kerekes <tk@...>
Subject: Re: [DynoMotion] Re: Trigger in Mach
To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
Date: Saturday, September 24, 2011, 7:31 PM

 
Hi Bill,
 
Not sure if the comment on 10X speed moves is a question or a statement.  If you switch to the new method the motion should then be very smooth.
 
Thanks
TK