RsLogix 500 Data File LONG

Adam303

Lifetime Supporting Member
Join Date
Aug 2009
Location
Chicago
Posts
587
Hi Friends I wanted to ask if there is a equivalent data file to LONG in logix 500. I see that the data file LONG can only be used in MicroLogix processors but does not come up in SLC 5/04.
I need to multiply the process variable of a PID loop by a timer preset of 1000 ms and than divide this by 16383. The value will be compared the timers accumulated value in order to turn off an output.
 
You can use the math registers for 32 bit math. Refer to the instruction set reference manual. Multiply by 1000 using the MUL instruction. The result in the MUL destination word will be bogus, ignore it. The true 32 bit result is in the math register. Immediately after that perform a DDV 16383. That will divide the 32 bit contents of the math register by 16383 and put the answer in a 16 bit integer destination. Finally be sure you unlatch your over flow bit otherwise the processor will fault at the end of the scan.

That is how you do it. That said, dividing by 16.383 as daba suggested is much simpler to program.

You can also use the SCP instruction.
 
Last edited:
It faults out the processor "A minor error bit is set at the end of the scan. refer to S:5 minor error bits."
 
The minor error you see is the Overflow of multiplying a number by 1000, the result is too large to store in the conventional INT data-table address.

Alaric said " The result in the MUL destination word will be bogus, ignore it. ".

The vast majority of SLC/Micrologix programs have an unlatch of the Math Overflow error bit as the last rung of the program, so that this situation can be used.

But just do a DIV xx 16.383 yy - the processor can work with floating point maths
 
Here is an example (look in LAD4) of how to do it on a SLC500 fixed IO processor that doesn't support floating point math. Your 5/04 does support floating point math. The example is provided to show you how to do what you asked, but there is a better way: Just divide by 16.383.
 
I need to multiply the process variable of a PID loop by a timer preset of 1000 ms and than divide this by 16383.

In your posted code, you left the MUL instruction, which causes the math overflow....

DIV {PIDLoop.PV} 16.383 {Destination} does the job as described.

I don't know why the CLR of S:5 isn't stopping the PLC from major faulting - it's usual to just use OTU S:5/0, that way you will pick up on other faults. Is there an OTE somewhere in the code of B3:0/0 - if there is the processor does a pre-scan, turning OFF all non-retentive bits.
 
Adam, now that I have had a chance to come back and look at the picture you posted I can see a couple of things that need your attention.

First off, you said "timer preset of 1000 ms" and I see that you do have a preset of 1000 for T4:0. However, on a SLC 5/04 this timer preset cannot be in milliseconds, but hundredths of a second - thus 1000 is a ten second preset.

Second, when multiplying by T4:0.PRE as you have shown, don't use an integer destination, use a Float destination. That way you don't overflow. Then divide by 16383.

If your timer preset is ALWAYS going to be 1000 then skip the extra step and combine the two terms. That is what dividing by 16.383 does, it combines the operation of first multiplying by 1000 and then dividing by 16383. But if the timer preset may change then use the CPT instruction and do all the math in a single instruction. Force floating point operation by making your constant a float, that way you avoid any overflow problems.

CPT N7:1 PV*T4:0.PRE|16383.0




 
Last edited:
I thought it made more sense for the OP this way instead of multiplying by the inverse of 16.383. (Even though multiplying is more efficient as far as the processor is concerned, we didn't need to get into that.)
 
Yeah but 0.06103888 is too many digits for the SLC


Ooops just checked, no it isn't....
 
Last edited:

Similar Topics

Hi. I'm doing an upgrade of an old 1400e to a new panel view plus 7 standard using ftv studio v 12,which will be communicating to a slc 5/04 via...
Replies
15
Views
2,610
I have a micrologix 1100 that I am trying to read three data points from it on my safety plc using studio 5000. Any tips or guidance is appreciated.
Replies
4
Views
831
I stumbled onto this behavior the other day, then went looking for old forum posts with the assumption that "there is nothing new under the...
Replies
0
Views
776
Hello All, I am working on converting a program written in RSLogix 500 to Connected Components Workbench. The MicroLogix to Micro800 converter...
Replies
1
Views
1,192
I'm working with a customer to copy one of the machines they designed in-house several years ago. The previous PLC programmer had a thing for...
Replies
8
Views
2,067
Back
Top Bottom