{
  "version": 2,
  "name": "Recipe Select with Pointers",
  "exported": "2026-10-14T00:00:00.000Z",
  "notes": "Generic v1.125 example (not tied to one scene). X1/X2/X3 = Recipe A/B/C select PBs (N.O.), X4 = Fault Reset PB (N.O.). AX1 = process value 0-4095. D1 = recipe number 0-2 (INT). Setpoint table D100-D102 is loaded on the first scan; demand table D110-D112 starts from dregs. D2 = pointer to the setpoint (100 + D1), D3 = pointer to the demand (110 + D1). D10 = working setpoint, D11 = working demand. Y1 = at setpoint (AX1 >= D10). AY1 = demand while below setpoint, 0 at setpoint. Y8 = math fault lamp (SB12); X4 clears the fault flags and SW17.",
  "program": [
    {"id": 1, "rn": 0,
     "comment": "LOAD SETPOINT TABLE — first scan only: recipe A, B, C setpoints into D100-D102",
     "elements": [
       {"id":101,"kind":"contact","type":"XIC","addr":"SB3"},
       {"id":102,"kind":"block","type":"MOV","addr":"D100","src":"1000","dt":"INT","pre":0},
       {"id":103,"kind":"block","type":"MOV","addr":"D101","src":"2000","dt":"INT","pre":0},
       {"id":104,"kind":"block","type":"MOV","addr":"D102","src":"3000","dt":"INT","pre":0}
     ]},
    {"id": 2, "rn": 1,
     "comment": "SELECT RECIPE A — one press of X1 sets recipe number 0",
     "elements": [
       {"id":105,"kind":"contact","type":"P","addr":"X1"},
       {"id":106,"kind":"block","type":"MOV","addr":"D1","src":"0","dt":"INT","pre":0}
     ]},
    {"id": 3, "rn": 2,
     "comment": "SELECT RECIPE B — one press of X2 sets recipe number 1",
     "elements": [
       {"id":107,"kind":"contact","type":"P","addr":"X2"},
       {"id":108,"kind":"block","type":"MOV","addr":"D1","src":"1","dt":"INT","pre":0}
     ]},
    {"id": 4, "rn": 3,
     "comment": "SELECT RECIPE C — one press of X3 sets recipe number 2",
     "elements": [
       {"id":109,"kind":"contact","type":"P","addr":"X3"},
       {"id":110,"kind":"block","type":"MOV","addr":"D1","src":"2","dt":"INT","pre":0}
     ]},
    {"id": 5, "rn": 4,
     "comment": "FETCH RECIPE — pointers D2 = 100 + recipe and D3 = 110 + recipe, then MOV through them into the working registers",
     "elements": [
       {"id":111,"kind":"contact","type":"XIC","addr":"SB1"},
       {"id":112,"kind":"block","type":"ADD","addr":"D2","a":"100","b":"D1","dt":"INT","pre":0},
       {"id":113,"kind":"block","type":"ADD","addr":"D3","a":"110","b":"D1","dt":"INT","pre":0},
       {"id":114,"kind":"block","type":"MOV","addr":"D10","src":"D[D2]","st":"INT","dt":"INT","pre":0},
       {"id":115,"kind":"block","type":"MOV","addr":"D11","src":"D[D3]","st":"INT","dt":"INT","pre":0}
     ]},
    {"id": 6, "rn": 5,
     "comment": "Y1 AT SETPOINT — typed compare: AX1 at or above the working setpoint D10",
     "elements": [
       {"id":116,"kind":"compare","type":"GEQ","addr":"AX1","cmp":"D10","dt":"INT"},
       {"id":117,"kind":"output","type":"OTE","addr":"Y1"}
     ]},
    {"id": 7, "rn": 6,
     "comment": "DEMAND — below setpoint, AY1 gets the recipe's demand D11",
     "elements": [
       {"id":118,"kind":"contact","type":"XIO","addr":"Y1"},
       {"id":119,"kind":"block","type":"MOV","addr":"AY1","src":"D11","st":"INT","pre":0}
     ]},
    {"id": 8, "rn": 7,
     "comment": "DEMAND OFF — at setpoint, AY1 = 0",
     "elements": [
       {"id":120,"kind":"contact","type":"XIC","addr":"Y1"},
       {"id":121,"kind":"block","type":"MOV","addr":"AY1","src":"0","pre":0}
     ]},
    {"id": 9, "rn": 8,
     "comment": "Y8 MATH FAULT — SB12 is on while any error flag is set (a pointer outside D1-D4000 sets SB11)",
     "elements": [
       {"id":122,"kind":"contact","type":"XIC","addr":"SB12"},
       {"id":123,"kind":"output","type":"OTE","addr":"Y8"}
     ]},
    {"id": 10, "rn": 9,
     "comment": "FAULT RESET — one press of X4 clears the sticky flags and the error code",
     "elements": [
       {"id":124,"kind":"contact","type":"P","addr":"X4"},
       {"id":125,"kind":"output","type":"OTU","addr":"SB9"},
       {"id":126,"kind":"output","type":"OTU","addr":"SB10"},
       {"id":127,"kind":"output","type":"OTU","addr":"SB11"},
       {"id":128,"kind":"block","type":"MOV","addr":"SW17","src":"0","pre":0}
     ]}
  ],
  "comments": {
    "X1": "Recipe A PB",
    "X2": "Recipe B PB",
    "X3": "Recipe C PB",
    "X4": "Fault Reset PB",
    "AX1": "Process Value 0-4095",
    "AY1": "Demand Output",
    "Y1": "At Setpoint",
    "Y8": "Math Fault",
    "D1": "Recipe Number 0-2",
    "D2": "Setpoint Pointer",
    "D3": "Demand Pointer",
    "D10": "Working Setpoint",
    "D11": "Working Demand",
    "D100": "Setpoint Recipe A",
    "D101": "Setpoint Recipe B",
    "D102": "Setpoint Recipe C",
    "D110": "Demand Recipe A",
    "D111": "Demand Recipe B",
    "D112": "Demand Recipe C"
  },
  "dregs": {"D110": 1500, "D111": 2500, "D112": 4095},
  "dfmt": {}
}
