You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old July 20th, 2021, 11:48 AM   #16
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,082
Quote:
Originally Posted by Mwils View Post
Here is more of the code of the RSS /pdf file. That shows motor movement control. I have been trying to simulate what they're doing to do but it doesn't work the way the machine works. The counter continues to count even with compare instruction in place as they have it. They are only using accumulator instruction and a CLR instruction but that's is for automation is present and is option selectable from builder.

Are you trying to simulate the process* that the code controls or the controller itself?


* hopper position, water splitter, water spray, motor, clutches, encoders, etc.
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.

Last edited by drbitboy; July 20th, 2021 at 11:50 AM.
  Reply With Quote
Old July 20th, 2021, 04:55 PM   #17
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,082
Here is an approach that eliminates all of those ONS instructions, and is also easier to read: 38 instructions vs. 53 in the original; 2.2- inputs average, and 3 max, before each output vs. 3.5+, and 4 max, in the original.

It should be equivalent in practice if not in theory. That said, this is only a thought experiment; specifically, since the OP already has working code, there is no reason to change it.
Attached Files
File Type: pdf ctuctd_130011_alternate.pdf (186.2 KB, 8 views)
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
  Reply With Quote
Old July 20th, 2021, 10:43 PM   #18
Mwils
Member
United States

Mwils is offline
 
Join Date: Jan 2021
Location: Salt Lake
Posts: 12
Quote:
Originally Posted by drbitboy View Post
So T4:15/DN is 1 when the VFD is moving the motor forward, plus a (brief?) time beyond as the motor coasts to a stop, to catch any edges that may occur?


And the same for T4:16/DN in reverse?
Yes that is how it works.
  Reply With Quote
Old July 20th, 2021, 11:01 PM   #19
Mwils
Member
United States

Mwils is offline
 
Join Date: Jan 2021
Location: Salt Lake
Posts: 12
Quote:
Originally Posted by drbitboy View Post
Are you trying to simulate the process* that the code controls or the controller itself?


* hopper position, water splitter, water spray, motor, clutches, encoders, etc.
I'm just trying to simulate the code that runs one VFD for (hopper position, guide position, water rail position) per recipe. This is a conversion project from a micrologix 1500 to a compact logix and comms.
  Reply With Quote
Old July 21st, 2021, 09:10 AM   #20
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,082
Quote:
Originally Posted by Mwils View Post
I'm just trying to simulate the code that runs one VFD for (hopper position, guide position, water rail position) per recipe. This is a conversion project from a micrologix 1500 to a compact logix and comms.
Excuse me for being pedantic, but that sounds more like you are trying to port or transfer or duplicate part of the functionality from the MicroLogix into the CompactLogix, not simulate the process.

Or perhaps you are trying to create a simulation of the process so you can test your converted CompactLogix code "on the bench?"

Anyway, my understanding your task is not important. The real question is, was your original query answered in any of the rabbit trails in this thread?

Also, it looks to me like this is motion control using counters and ladder logic. Why not use the motion control facilities of the PLC?
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.

Last edited by drbitboy; July 21st, 2021 at 09:26 AM.
  Reply With Quote
Old July 21st, 2021, 11:45 PM   #21
Mwils
Member
United States

Mwils is offline
 
Join Date: Jan 2021
Location: Salt Lake
Posts: 12
Quote:
Originally Posted by drbitboy View Post
Excuse me for being pedantic, but that sounds more like you are trying to port or transfer or duplicate part of the functionality from the MicroLogix into the CompactLogix, not simulate the process.

Or perhaps you are trying to create a simulation of the process so you can test your converted CompactLogix code "on the bench?"

Anyway, my understanding your task is not important. The real question is, was your original query answered in any of the rabbit trails in this thread?

Also, it looks to me like this is motion control using counters and ladder logic. Why not use the motion control facilities of the PLC?
I'm just trying to understand and check the code after conversion.

No I have not got an answer for my original question about the accumulators being used as preset.

The motion control would be nice but this is a bare minimum project and they would see it extra stuff to do. Plus there isn't a lot of downtime for this machine it runs 6-7 days a week.
  Reply With Quote
Old July 22nd, 2021, 12:46 AM   #22
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,082
If by "accumulators" you mean the C5:[N201:0].ACC values, they are not used as presets in that code. The .ACC values are used as models of the positions of the various moving elements (hopper position, guide position, water rail position). The .ACC values are either incremented by CTU instructions or decremented by CTD instructions whenever a motor encoder has a rising or falling edge.

The .ACC values are compared against pre-stored positions i.e. INT values in the N201:10, and the VFDs are run until the .ACC values equal the stored positions. The N201:10 value in turn is obtained from an INT element of the N210 file, which element is used is derived from the values N7:0 and N201:0, one of which is probably a station number input by the operator and the other is a motor number.

The counters' presets, e.g. C5:0.PRE, C5:1,PRE, etc., are not used by the program; they are hardcoded to 32000, which is too high for the .ACC elements to exceed, so .DN is never 1; not that it matters.
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
  Reply With Quote
Old July 22nd, 2021, 03:07 AM   #23
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,350
AS Drbitboy has re-iterated, the accumulators have been explained, my previous post gave that information, however, DR has made it a lot clearer. Not sure in CLX/SLC but on some systems the pre-set if set say at 200 the .DN (counter reached it's pre-set value will be true when the Actual = or is greater than), some systems the counter would stop counting anything above the pre-set (this is to stop the integer value going above 32767) as this would make the accumulated value go negative & cause the fault light to come on & stop the processor. If the counter never goes above the maximum then you could lower the pre-set, so just to re-iterate.
The counter has a number of possible modes:
When the Accumulated count is = to (or possibly above) then it will turn on it's .DN bit (other platforms vary it is either something like the counter number i.e. C5, CC5 (in Mitsubishi) or in IEC is often a variable bit that is put on the counter function block output). Again depending on the PLC the count will either stop at the accumulated value or carry on until the maximum positive value 32767 & stop, or go over giving a negative .ACC value & possibly put the PLC in fault.
Giving a Pre-set above the expected maximum count you are likely to accumulate and using either count down or a compare of the ACC value & then possibly reset the .ACC value is very common so programmers tend to set the pre-set higher than actual required count.
There are some exceptions to some of the above, for example some PLC's have 32 bit counters as well as 16 bit so the pre-set limit is not limited to 32767 but the maximum limit of a 32 bit double integer.
Attached is a quick list of some of the types of timers the first one is generally the type the older generation PLC's had i.e. the coil, DN & ACC variables are programmed separately (will depend on platform)
The others are IEC equivalents.
Hope this explains fully some of the parts of the timer functions.
Sorry it's not in AB CLX money but I only use them if forced (personal hate of RW, this has very little to do with the platform which is quite good).
Attached Images
File Type: png Counters.png (99.2 KB, 29 views)
  Reply With Quote
Old July 22nd, 2021, 05:17 AM   #24
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 5,339
Quote:
Originally Posted by parky View Post
AS Drbitboy has re-iterated, the accumulators have been explained, my previous post gave that information, however, DR has made it a lot clearer. Not sure in CLX/SLC but on some systems the pre-set if set say at 200 the .DN (counter reached it's pre-set value will be true when the Actual = or is greater than), some systems the counter would stop counting anything above the pre-set (this is to stop the integer value going above 32767) as this would make the accumulated value go negative & cause the fault light to come on & stop the processor. If the counter never goes above the maximum then you could lower the pre-set, so just to re-iterate.
The counter has a number of possible modes:
When the Accumulated count is = to (or possibly above) then it will turn on it's .DN bit (other platforms vary it is either something like the counter number i.e. C5, CC5 (in Mitsubishi) or in IEC is often a variable bit that is put on the counter function block output). Again depending on the PLC the count will either stop at the accumulated value or carry on until the maximum positive value 32767 & stop, or go over giving a negative .ACC value & possibly put the PLC in fault.
Giving a Pre-set above the expected maximum count you are likely to accumulate and using either count down or a compare of the ACC value & then possibly reset the .ACC value is very common so programmers tend to set the pre-set higher than actual required count.
There are some exceptions to some of the above, for example some PLC's have 32 bit counters as well as 16 bit so the pre-set limit is not limited to 32767 but the maximum limit of a 32 bit double integer.
Attached is a quick list of some of the types of timers the first one is generally the type the older generation PLC's had i.e. the coil, DN & ACC variables are programmed separately (will depend on platform)
The others are IEC equivalents.
Hope this explains fully some of the parts of the timer functions.
Sorry it's not in AB CLX money but I only use them if forced (personal hate of RW, this has very little to do with the platform which is quite good).
In ALL Allen-Bradley processors, a Counter preset or accumulator can indeed be negative, and no faults will be generated. This is ONLY the case for Timers, where a negative preset or accumulator will cause a major fault.

All that happens with A-B counters is that when the maximum positive value is reached, the next Count-Up will cause the value to be incremented, which pushes it to the maximum negative value. At the same time, the "Overflow" (.OV) bit will get set.

Subsequent CTU's increment the counter towards zero, then beyond that to the maximum positive value again. So in fact, by looking at the .OV bit, the "positive" count is 3 times the maximum value allowed in the accumulator.

Absolute overflow is when the OV bit is set, and the counter changes from maximum positive to negative yet again. Thatt is when you have "lost" the count, and you should do something about it.

A similar arrangement occurs on a CTD counter, but this time when the counter reaches maximum negative, the next Count Down flips the accumulator to maximum positive, and the "Underflow" (.UN) bit gets set.

Subsequent CTD's decrement the counter towards zero, then beyond that to the maximum negative value again. So in fact, by looking at the .UN bit, the "negative" count is 3 times the minimum value allowed in the accumulator.

With careful programming therefore, by inspection of the .OV and .UN bits, and by trapping any "true" overflow and underflow, you can usefully count 6 times the counter's "range" of values - something that is sometimes needed.

So a 16-bit counter (SLC/Micrologix et al) can count from -32,768 to +32,767 : a "range" of 65,535 counts : 6 times that is 393,210

A 32-bit counter (Logix5000) can count from -2,147,483,648 to
+2,147,483,647 : a "range" of 4,294,967,295 : 6 times that is 25,769,803,770

A counter's .DN bit never stops the counter counting (unless you program it in the CTU or CTD "enable" input yourself). Because of that, many people use a counter as a "flip-flop", by inspecting the counter accumulator bit 0, which continues to "toggle" forever. You can safely do this, completely ignoring any of the flag bits, or the actual value in the accumulator.

One of the advantages of using a counter as a toggle or a "flip-flop" is that the accumulator value is retentive, and survives the pre-scan operations at start-up. Many of the bit-based toggles do not .....
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
Everything works with smoke. Let it out, and it stops working.

Nil Carborundem Illegitimi



  Reply With Quote
Old July 22nd, 2021, 05:47 AM   #25
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,350
Thanks Dabba, Long time since I used RW $***, That is why I stated it depends on platform, I know that Mitsubishi counters will stop counting when they reach the pre-set (well standard ones) the IEC Counter FB's I'm not sure as they do not use the internal so called "Counters".
I seem to remember a couple of other platforms where the counters carry on past the pre-set, again different functionality, one would set the equivalent of the .DN bit only when the ACC & PV were equal, the other would set the .DN bit if it equalled or greater than.
  Reply With Quote
Old July 22nd, 2021, 06:17 AM   #26
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 3,350
Just one other thing in the IEC Up/Dn counters the pre-set is not generally considered just as the value = actual but can be triggered to set the accumulator to a pre-set using a load parameter bit.
TBH, I rarely use counters I just increment or decrement a value in a retentive word.

Last edited by parky; July 22nd, 2021 at 06:19 AM.
  Reply With Quote
Old July 22nd, 2021, 11:40 PM   #27
Mwils
Member
United States

Mwils is offline
 
Join Date: Jan 2021
Location: Salt Lake
Posts: 12
First of all I want to thank everyone for the help and suggestions and lot of good information. I found out my problem was with using the ACC as the preset , after I changed the program using a 32000 preset and removed the setup position count as part of recipe setup it started working and then used a NEQ to stop the motor when in position. I the program still needs more work but it's a start. Thanks again.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
An example of TOD using two counters fredz0003 LIVE PLC Questions And Answers 0 April 17th, 2012 02:25 PM
RSlogix CDM todster LIVE PLC Questions And Answers 2 December 15th, 2008 02:14 AM


All times are GMT -4. The time now is 01:20 AM.


.