Search code examples
c#okuma

Change Program Buffering Okuma OSP-300M


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);    

Solution

  • 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)