Stuck

Ok, I'm stuck trying to adapt my existing Limits Function to accept INT, DINT, or REAL (Immediate Values, Memory Variables or Arrays) for HiLimit, LoLimit and Test Inputs. I want to drop the FC in line in my ladder and not have to bother with an output bit.

I think I'm on the right Track, but I'm stuck and would like someone to have a look and see what's missing. I've inserted comments in areas where I feel like I've missed something. Feel free to modify or simply comment.

Eric
 
I would use 3 separate FC's for the INT, DINT and REAL limit checks and not use any pointers. You cannot enter a constant when using any pointers so so will have to load a constant to a temp and then pass the temp as the any pointer parameter.

Here's my implementation using any pointers - using loops to process parameters might be more applicable if you had say 10 parameters, but for three a bit of in-line code is a lot easier to debug and monitor. Note I've added some monitoring outputs to the FC which can be removed.
 
Simon,

Thanks a million. Quite ingenius the use of UDTs as temp variables, I hadn't thought of that. Your example has definitely answered a question I have been pondering about bytes 6-9. That routine looks very good, and yes you're right about the loop being unneccesary with only 3 but I have a similar requirement for a scaling function that has 5 input parameters and 1 in_out parameter so to minimize the code I used a loop, and then chopped it up for this limit function.

I guess I'd better go back and have another whack at that Scaling Function, after seeing your code. I think it can be improved with your example as well.

Eric
 
Simon,

I'm a little unsure why you are toggling the accumulators. Could you explain please? I've not seen that used before. Also should I put a JNB in after the Logic Operations in the Network for 'Selecting type of limit required'? I'm unsure how the code will execute if the RLO is false. I know the first instruction after the RLO won't execute but if it resumes on the next instruction then it would be resetting the #bUnsupported bit.

Thanks again.

Eric
 
When doing a chain of comparisons the TAK instruction is sometimes useful as it simply restores the original compare value. e.g.


L x //accu1=x accu2=?
L y //accu1=y accu2=x
compare
tak //accu1=x accu2=y
L z //accu1=z accu2=x
compare
tak //accu1=x accu2=z
L w //accu1=w accu2=x
compare
etc.
 
arkansascontrols said:
Simon,

Also should I put a JNB in after the Logic Operations in the Network for 'Selecting type of limit required'? I'm unsure how the code will execute if the RLO is false. I know the first instruction after the RLO won't execute but if it resumes on the next instruction then it would be resetting the #bUnsupported bit.

No. After each comparison, if the RLO=0 then the = will evaluate false and the Reset will have no effect.

So, Unsupported is initially set to TRUE. If a match is found it will be reset to FALSE. If no match is found it will remain TRUE.
 

Similar Topics

Hello Everyone, I have been programming a little while so I would of thought learning a new ladder program would not be to much of an issue, I...
29
Replies
847
Views
I have a client that has a Micro850 PLC with a 2080-IF4 analog plug-in module. I am using 2 analog channels. The analog values will appear...
5
Replies
236
Views
Hello, I have noticed that in version 35 of Studio there are times that XIC/XIO bits get stuck and will not function properly. After toggling...
14
Replies
408
Views
TM221CE24R, Machine Expert Basic, PID Assistant (native block, not scripted). Controlling a steam valve via PWM (%Q0.1) for a slow batch heating...
12
Replies
361
Views
CPU 1215C + CB1241 (RS485), talking Modbus RTU to a VFD (19200 baud, no parity, 8N2). Modbus_Comm_Load initializes fine every time (DONE=TRUE...
0
Replies
237
Views
Top