3

I'm currently running a small loop in g-code that has to wait for a common variable to change values. With Program Buffering ON, my g-code program does not see changes to the variables!

What is the best way to turn Program Buffering OFF while I am in this g-code loop?

If I manually set Program Buffering (NC Optional Parameter Bit No.2 Bit 7 to "DOES NOT". Then my loop behaves appropriately and the controller properly checks the value of the common variable each loop.

NC Optional Parameter NO. 2, BIT 7

NLOOP G04 F1
IF[VC890 EQ 0] GOTO NRTS
GOTO NLOOP
NRTS RTS

Very straight forward loop. Maybe it needs to be more complex.
Perhaps if it was longer the buffer wouldn't matter?

I expect my customer's will want Program Buffering turned on.
Can I turn it off temporarily with the THINC API?
Because if it works, this would be great:

public void SetNCOptionalParameterBit(
    int intBitIndex,
    int intBitNo,
    OnOffStateEnum enValue);

If this function will let me set param bit no 2 bit 7 on and off then this would probably be a valid work around.

Okuma.CMDATAPI.DataAPI.COptionalParameter myCOPtionalParameter;
myCOptionalParameter = new Okuma.CMDATAPI.DataAPI.COptionalParameter();

myCOPtionalParameter.SetNCOptionalParameterBit(2, 7,
    Okuma.CMDATAPI.Enumerations.OnOffStateEnum.On);    
Scott Solmer
  • 3,871
  • 6
  • 44
  • 72
  • Great idea. You could write an app that would toggle Program Buffering on/off via a common variable. You could also turn it back on automatically whenever it has been turned off and the cycle has ended in case someone forgets to turn it back on. – jweaver Mar 29 '18 at 11:28

3 Answers3

1

What about M331 to prevent read ahead? (I won’t be at a control for a few days to verify usage, I’m holding my newborn and it’s 4am right now but I think it can go either on the line where you read variable on or the line before.)

NLOOP G04 F1 M331 (buffering prohibit)
IF[VC890 EQ 0] GOTO NRTS
GOTO NLOOP
NRTS RTS
Still.Tony
  • 1,437
  • 12
  • 35
  • M331 only works on lathes. I've also had cases where the M331 did not work at all on the lathe and I had to use other methods to stop look ahead. – jweaver Mar 29 '18 at 11:24
1

The SetNCOptionalParameterBit() function is capable of setting NO. 2, BIT 7.

However, depending on what version of API you have, the THINC API test application might fail to do so. I confirmed there is a bug in the test app for API 1.17.2.0. And it was fixed by the time 1.18.0.0 was released.

So just be aware of that. Even if your machine has an older API such as 1.17.2.0, you should still be able to write code that uses this function successfully. Just ignore the test app results.

Scott Solmer
  • 3,871
  • 6
  • 44
  • 72
1

The best solution for my scenario was saving the current value of NC Optional Parameter 2 into a common variable, then changing it to Does Not buffer then running my code, then putting it back to whatever it was before.

in Gcode:

VC892 = VOPRB[2] (save current NC Optional Parameter bit 2 value)
VOPRB[2] = [VOPRB[2] OR 128] (bit magic to flip bit 7 to a 1 if its not)
(insert code to be run without buffering)
VOPRB[2] = VC892 (put back saved NC Optional Parameter bit 2 value)
  • The problem with this method is that if the operator stops the program before you turn it back on and then runs some other program buffering will be turned off again. It might be worth doing it in an app via the API so that if the program stops the app will turn buffering back on – jweaver Jun 29 '18 at 14:13