Writing directly to IO points while using block writes

Pac Control:
I wasn’t aware of this, but I found this little note at the bottom of the “MoveNumbericTableToIOUnit()” command help. Apparently they introduced this in 9.4.

If you’re using a block read and block write program design, there always seems to end up being the case were you need to write directly to one of two outputs. The problem of course is, you write to the output directly, and then the block write overwrites the state you just wrote….well I figured that if I first wrote to the xxx_dout variable and on next line the xxx_do ouput point, that would solve the problem……wrong.

So I went back the the command help page and found the note.

//these are NaN, not a number value to prevent the write table from writing to these outputs since they //are being written directly to.
i32Temp = 0x7fc00000;
Move32Bits(i32Temp, Pvr_WaterDrawDownNaN_dout);
Move32Bits(i32Temp, Mpim_ClearLatchNaN_dout);
Move32Bits(i32Temp, Pico_InhibitFlagNaN_dout);

Note that this only works if you are using a float table for block writes and these vars I list here are actually floats (Pico_InhibitFlagNaN_dout). The idea is that by using this script you can load a float table with a NaN number, and the table will not update those output points.

This allows one to write directly to specific outputs all while using block read/block writes.

Apparently, this note is only on the command help of “MoveNumbericTableToIOUnit()” and not on the EX version, which is probably why is wasn’t aware of it. The good news is, it works on both.

Here is the note:
(PAC firmware R9.4d and higher.) This command does not write to discrete or analog points when either:
The float table value is set to a floating point NaN (not a number), or
An integer table element is set to 0x7fc00000 (the floating point representation of +NaN).**
You can use a NaN to prevent modifications to discrete and analog points. For details, see Notes.**

To prevent modifications to discrete and analog points, you can create a floating point variable that contains a NaN, and then assign it as a constant to table locations. For example, this OptoScript sample creates i32Temp, a 32-bit floating point variable that contains a NaN:

i32Temp = 0x7fc00000;
Move32Bits(i32Temp, f32FloatNan);

1 Like