johnny rotten,
Sorry about that typo. I should've told you it was CTRLDPR and not CTRLDPT. I'm going to walk you through an example.
Overall, you have to configure the CTRIO properly to do what you want, and then you have to write the ladder logic to properly interface with the CTRIO.
Configuring the CTRIO I/O:
1. Start CTRIO Workbench
2. Press <Config IO> button.
3. I assume at this point you have Channel 1 Input A configured as a Counter. If not, that's what you want.
a. Here you can choose Up or Down counter.
b. Which edges to count.
c. Scaling (the little ruler icon in the top of the Function 1 box)
d. Configure a default Preset (a Single Preset, or a Load Table Table Number).
i. At this point, leave this at None because I want to walk you through an example.
4. In the Output tab, choose Output 0 as "Discrete on Ch1/Fn1".
5. Press <OK>
Now the CTRIO's Input A should be wired to your encoder. Your CTRIO's Output 0 doesn't have to be connected in your situation because you are not really using it in your process. But now we need a Discrete Table (other names for this is Preset Table, File, Profile). So...
Configuring Preset Table:
1. In CTRIO Workbench main screen, press the <Discrete Tables> button.
2. Press the <Add Preset Table> button.
3. By default it will be File #1. You can enter a Name if you want (optional).
4. Press the <Add Preset> button.
5. Choose "Reset Count".
6. Enter the value you want your count to reset at in Preset field.
7. Press <OK>.
8. Press <OK>.
9. Press <Exit>.
You now have a Preset Table (File #1) that has an entry in it that, when in use (or "loaded" as we like to say), will reset the count when it reaches a certain value. This table resides in the CTRIO's memory and can be loaded for a particular output to drive an output if desired. However, in your case, you are not doing that; instead, you are only using it to reset your count.
Now, since you have some of this working, I assume you know how to use the <I/O Map> button and map your CTRIO parameters to V-memory. So, write this configuration to your CTRIO. You are now read to use the IBoxes in ladder logic to control this configuration.
Writing Ladder Logic Control:
Before you use the CTRIO IBoxes (all these begin with "CTR" in their names), it is necessary to put a configuration IBox for your module in ladder.
1. At the very first rung of your ladder logic, put a CTRIO IBox (IB-1000). Do not put any logic on the input leg. You should have a CTRIO IBox (IB-1000) for each hardware CTRIO you have in your system. In your case you only have one.
a. CTRIO #: Enter any K value you want. This is just a way for all the other CTRIO IBoxes to point to this module. So, you might call it K0.
b. Slot: Enter the slot number... in your case, that sounds like it should be K2.
c. Workspace: Enter any free V-memory register (must be unique).
d. CTRIO Location: Choose "Local Base" of course.
e. Input: Enter the V-memory starting address of your CTRIO input map (you get this from the <I/O Map> button in CTRIO Workbench).
f. Output Enter the V-memory starting address of your CTRIO output map (ditto).
2. Somewhere in your program use the CTRLDPR IBox (IB-1001). This IBox needs input logic (whatever you want to use to trigger this event).
a. CTRIO #: This IBox is basically asking you which CTRIO to use in your system (because you could have more than one in different slots). Since in Step 1 above we entered this to be K0, then enter K0 here to point to that module.
b. Output #: Since in CTRIO Workbench we chose Output 0 for "Discrete on Ch1/Fn1", enter K0 to point to this CTRIO output (even though you are not physically using this).
c. File #: This IBox wants to know which file in the CTRIO you want to load and use. We configured File #1 as a Preset Table in CTRIO Workbench, so enter K1.
d. Workspace: Again, enter any free V-memory register (unique).
e. Success: Enter any C-bit that is free. Basically when you turn the logic ON on this IBox and it executes successfully, this bit will get SET ON.
f. Error: Enter any C-bit that is free. This will turn ON if the CTRLDPR was unsuccessful.
The Preset Table that has the entry of RESET COUNT AT x (whatever count you entered), is now loaded and ready to use.
When you want to change the RESET COUNT AT x value, then somewhere in your ladder logic, you would use the CTREDRL IBox (IB-1002):
1. Enter CTREDRL IBox
a. CTRIO #: K0 (again, pointing to your CTRIO IBox #)
b. Output #: We're using the Preset Table you have previously loaded above for Output 0... so, K0.
c. Table #: We are editing File #1, remember? So, K1.
d. Entry # (0-based): If you will recall your Preset Table only has one entry (RESET COUNT AT x), since this value is 0-based, then the first (an only entry) is K0.
e. Entry Type #: When you configured your Preset Table in CTRIO Workbench, you could pick Set, Reset, Pulse On, Pulse Off, Toggle, or Reset Count. We chose RESET COUNT. Each of these types has a number associated with it: 0=Set, 1=Reset, 2-Pulse ON, 3-Pulse OFF, 4-Toggle and 5-Reset Count. You are changing a Reset Count... So this value should be K5.
f. Pulse Time: Some of the Entry Types need a Pulse Time (e.g. Pulse ON and Pulse OFF). Reset Count does not need a Pulse Time. So enter K0 (since in your case it is ignored anyways).
g. Preset Count: THIS is your new preset value that you are changing. This should, I believe, come from your HMI if I understand your application correctly. You should make this a variable (V-memory), and store the new value in this V-memory location before every time you execute this CTREDRL IBox.
h. Workspace: Free V-memory
i. Success: C-bit that will turn ON if successful.
j. Error: C-bit that will turn ON if error.
This should get you started at understanding what is going on with the CTRIO and its IBox interface. Hope this helps!