Hi Barrett,
Okay, here’s what I came up with, I hope it’s close to what you need.
Because the read/clear latches were spread out all over (not conducive to a simple/quick read), I leveraged the “Custom Configuration Area” (F0D5 0000) and corresponding “Custom Data Access Area” (F0D6 0000) in the mem map. That way, to read/clear and load your on and off tables, you can just do 2 simple calls like this:
nResult = ReadNumTableFromIoUnitMemMap( 64, 0, MyIOUnit, 0xF0D60000, ntMyIOOnLatches );
nResult = ReadNumTableFromIoUnitMemMap( 64, 0, MyIOUnit, 0xF0D60100, ntMyIOOffLatches );
Here’s what your overall logic looks like:

That first OptoScript block 1 loads up those read/clear on/off addresses (shown in the previous post) into that F0D5 0000 Config area for subsequent re-direct reading from that handy-dandy “Custom Data Access” area at: F0D6 0000.
So the set-up code looks like this:
nResult = 0;
nMemMapCustomConfigAddress = 0xF0D50000;// config area for custom mem mapping, start at the top for On-Latches,
//Off-Latches will be at: F0D50100
// Loop through all the points and map the read/clear addresses to the "custom" area for easier access later
nModuleIndex = 0;
while ( ( nModuleIndex < 16 ) and (nResult == 0 ) )
// map the ON/OFF LATCH read/clear areas (see form 1465 on www.opto22.com for details)
nMemMapReadClearOnLatchAddress = 0xF02E0004 + (nModuleIndex * 0x600);
nMemMapReadClearOffLatchAddress = 0xF02E0008 + (nModuleIndex * 0x600);
nPointIndex = 0;
while ( (nPointIndex < 4 ) and (nResult == 0 ) )
// 4 points per module x 4 bytes per point x 16 modules = 256 or 0x100 (hex)
// Configure the address to read, first the on latch, then the off latch at 0x100 off
nResult = WriteNumToIoUnitMemMap( MyIOUnit, nMemMapCustomConfigAddress, nMemMapReadClearOnLatchAddress );
nResult = WriteNumToIoUnitMemMap( MyIOUnit, (nMemMapCustomConfigAddress + 0x100), nMemMapReadClearOffLatchAddress );
nMemMapCustomConfigAddress = nMemMapCustomConfigAddress + 4; // each address is 4 bytes
// each latch address is 18 hex from the next one
nMemMapReadClearOnLatchAddress = nMemMapReadClearOnLatchAddress + 0x18;
nMemMapReadClearOffLatchAddress = nMemMapReadClearOffLatchAddress + 0x18;
IncrementVariable( nPointIndex );
wend
IncrementVariable( nModuleIndex );
wend
I hope that makes sense! Import the 9.3 basic (or better) chart attached below to save yourself some typing…
-OptoMary
GetClearIOUnitLatchesExampleB.zip (2.4 KB)