Host Engineering Forum
General Category => CTRIO and CTRIO2 => Topic started by: johnny rotten on April 24, 2013, 10:08:57 AM
-
Using the above to count from an encoder, 1000ppr, maybe maximum of 3000pps in the process. I'm taking the signal from an encoder that is going to another counter. All works well, and the ctrio matches the other counter perfectly, which is a must. The problem is matching the batch length and resetting the count. If I send a reset command from the ladder logic at the end of the batch length, I am counting pulses past the batch length depending on where the cpu scan is. If I don't reset the count and just use a calculator and watch the count, it is perfect, if I use the reset command from ladder logic, it is not accurate, but close.
How do I reset the count at the end of a batch length without depending on cpu scan time? Using a dl260 cpu. Thank you.
John
-
There are two possible ways to reset the count without involving the PLC. You can configure the counter channel's 'C' input as a reset, or you can use a preset table with a reset entry. Another possibility would be to not reset at the batch end, but instead capture the count using the channel's 'D' input and let the accumulator run.
-
Thank you for that information. Really all I want to do is have the operator enter a batch length from the touch screen and have the count reset at that value without cpu scan times effecting the accuracy. I will investigate those ideas. Thanks again.
John
-
I like the idea of the preset table with reset entry, going to try and make that work and may ask for some help.
-
I like the idea of the preset table with reset entry, going to try and make that work and may ask for some help.
There may still be issues with that, although they should be far better than with the PLC. The preset table reset behavior in the CTRIO is still bound by the scan time of the CTRIO...it is a software function. While significantly faster than the PLC (especially if you use a CTRIO2) it is still not exact. Please report back, and if it isn't working like you hope we can brainstorm some more.
-
So I've tried using the output preset table with a simple 'reset count' and it doesn't reset the counter. The encoder is only one channel so I have the input set as a counter on input A.
-
Hey Bob, what if I take my compare and reset rung in my program, and copy it so that it is every other rung in the program lol. Going to sleep on this one, maybe some help tomorrow would be great. Thank you so much.
-
So I've tried using the output preset table with a simple 'reset count' and it doesn't reset the counter. The encoder is only one channel so I have the input set as a counter on input A.
How are you loading the table? Setting it as default or doing a table load command? Are you resetting the counter after the table is loaded?
Finally...if you plan on doing very much CTRIO/2 work, I would strongly recommend a Do-more CPU. It reduces the complexity by a bunch. Huge even.
-
I'm actually not loading a table at all, simply taking the scaled count in my program and using sp relays (equal and greater than) the entered batch length, and fire the reset bit. I do find some of that confusing, but if you steer me in the proper direction, I will give it a try. What I want to do is take the v memory location that the operator enters, and I suppose load that into the ctrio so that it resets to zero. I still need to use the scaled count within the program to do a bunch of other stuff, but if I can make the batch count accurate, one happy boy.
-
I'm going to go through the manual again today, if there are some good program examples you could send me, that would be great.
mironjp@yahoo.com
-
Ok, hope you don't mind all my posts here, but this is important.
So within the workbench, I've set Output 0 to 'Discrete on Ch1/fn1'. and in the Preset table, added 'Reset Count at xxx'.
It works, and I imagine it is much more accurate than the dl260 cpu doing the reset. Why this works, I don't really know lol. Now is there a simple Ibox or other way to have the v memory location from the program change this 'Reset Count at xxx' value?
John
-
Last one of the day. Didn't have much time today, so will attempt changing the preset table from ladder logic tomorrow. Find the manual very confusing, any help would be great. Thanks again.
-
johnny rotten, you can use the CTRLDPT "CTRIO Load Preset Table" IBox to load the Preset Table for the particular CTRIO Output. You can use the CTREDRL "CTRIO Edit Preset Table Entry and Reload" IBox to modify your Reset Count entry to whatever value you want and then reload that table so that it is ready to use with its new value.
If that is not enough to get you up and going, please feel free to let me know (support@hosteng.com).
-
Sorry Johnny. We are running downhill trying to finish up Rev 1.1 for Do-more and the forum has taken backseat to an extent.
Preset tables are generally for on-module outputs to be fired based on encoder position. We added the reset entry too, which although it isn't an output function, folks needed to reset counters after 0 to n output operations. Since preset tables are actually output functions...that happen to affect input functions...you still have to load the table to make it work, even if it doesn't use output presets. You apparently configured a default table, which is automatically loaded by the module...thus bypassing the need to actually load it.
You can use the Initialize Table function (0x12) to erase the table currently in memory and initialize it with a single entry. There should be an I-Box to do that. You can also edit the table in memory via Edit Table Entry (function 0x14) to change the reset value.
The manual for the CTRIO is far from our best effort...and I am very sorry for that. All I can offer is that it has gotten much, much easier with Do-more, but that may not be an option for you. To put it in perspective, however, I wrote the CTRIO's firmware, CtrioWb, and large parts of DirectSoft...I am as close to an expert as you will find...and given the choice, I would gladly rewrite my DL application for Do-more to get the improvements. FWIW...
-
Thank you Bob and Greg.
I have Ctrio Workbench 2, Version 2.1.11.1.
May have to upgrade that.
Soo on this Friday, I do not have the ibox 'CTRLDPT' - it is simply not there. So I thought I would try the ibox 'CTREDRL', and see what it would do. It gives me an error with the CTRIO # which is set at K0 as default, have tired numbers up to K5, and even K51 as the id of the card from the Plc is 51, and have no idea what value it should be. So I can't even begin to guess what I should be puting in for output #, table #, entry #(0-based), entry type, pulse time, preset count, workspace, success, and error.
I actually have this system working on the plant floor now. The workbench software says the ctrio card is in slot 2.
I think once I understand this, I can basically use this card to do everything I want, use the 'set' and 'reset' and actually use the discrete output on the card rather than all the math in my program, so I'm eager to learn. As far as the 'think and do', I've never played with that at all, perhaps in the future.
-
Probably be best to work directly with Greg. We'll get you going.
-
I will send some pics, I'm actually getting somewhere, no errors, so I'm going to go through some examples and see what I can figure out.
-
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!
-
Totally understand. Thank you so much Greg. Have an awesome weekend. Will do this on Monday!
-
Well finally had a go at it today. Got frustrated and added the 'CTRWFTR' Ibox in. Changed some of my logic and finally got it working. I imagine I don't want to be constantly writing to the ROM of the CTRIO. Also the 'Preset Value' to reset the count is rarely going to change, so I really want to keep the reading and writing to the CTRIO to a minimum and perhaps only when the operator value changes after the first scan. I suppose I can handle all of that.
So just some thoughts, I'm not certain if I actually need the 'CTRWFTR' Ibox. I think I will have to reload the Ibox's each time the operator enters a new value (v-memory). Even though the reset count resides in the CTRIO memory, the hope is that it is much faster than using the cpu to fire the reset bit. We are not using this piece of equipment for a week or so, so I hope to try this upgrade and see how much better it works. The solenoid being fired is 120V so I can't use the discrete outputs, and don't want an interfacing relay.
Open to ideas of course, and thank you so much.
John
'One time at PLC camp, I put my outputs into my inputs' - just made that up lol.
-
Yeah...don't do the ROM write thingy. You don't need it, and depending on how often you write, it will wear out the memory.
I offered the best idea I had...use Do-more...but if that isn't possible, you should just need to load the table and edit the entry. Shouldn't be too bad, even with IBoxes. If that isn't working for you, I really would encourage you to get Mr. Greg on the phone and let him help you through it.
-
Ok, I will take that instruction out. I think I will be ok with the Ibox's. The batch length would only be changed once a week. Whatever is most accurate. Even with the reset command coming from the cpu, it is not bad, and as mentioned, I put registration adjust buttons in the touch screen, just trying to make it as perfect as possible.
-
Hey Bob and Greg, just wanted to thank you for all of your help. We now have an extremely accurate automated marking system working on the plant floor. We do the marking on press rather than by hand. Tried the new program a little over a week ago, and after several shifts it keeps perfect count, even with the reset. Production has more than doubled, and that includes half a day dialing it in. Thanks!!!!
John
-
That's great news! We always love to hear about user successes. Thanks for letting us know.
-
Awesome, John. Glad we could contribute. ;D