Quickly adding the sum of 60 registers.

RickParrot

Member
Join Date
Nov 2015
Location
Iowa
Posts
68
Good day all. I have been given process that involves tracking the speed of 60 rollers and issuing an alert for ones running fast, or ones running slow. I was thinking of doing and average and them comparing each input to that average.
Is there a simple way to add the numerical value of 60 registers. I really don't want to step it out (a+b=c, c+d=e, e+f=g and so on.)
I will be doing this on a ML1400. I have a feeling a sequencer will be necessary.
Any help would be appreciated. Thanks,
 
Are the rolls independently driven?

Do you know the reference?

Why would you want to average the individual roller speeds?

What is 'fast' and what is 'slow' with regard to reference?
 
As noted without an absolutely defined 'normal' an average is all you can hope for. If there are routine outliers then you may want to sort the speeds then throw out the highest and lowest before averaging. It may take some experimenting to determine how far away from 'average' is to be considered 'fast' or 'slow'. Maybe ask those requesting this for definitions.

I don't see how a sequencer would be applicable.
 
The ML1400 is ladder only.

That being said, you can still implement a pseudo-for loop in ladder using JMP and LBL instructions and a pointer. That only helps you if your speeds are all in sequential registers (or at least, following a repeatable pattern in their distribution), but if they are, then you could knock it all off in a couple of rungs.

Obviously, consider future readability - looping has it's place, but if 60 ADD instructions are going to be easier for whoever has to maintain it to manage, then hey, pick yourself out a new subroutine and go to town!

Your other option is one giant CPT instruction. Gets it all done in one instruction, clear and concise, but of course you're still typing 60x "A+B+C+..." into it.
 
The ML1400 is ladder only.

That being said, you can still implement a pseudo-for loop in ladder using JMP and LBL instructions and a pointer. That only helps you if your speeds are all in sequential registers (or at least, following a repeatable pattern in their distribution), but if they are, then you could knock it all off in a couple of rungs.

Obviously, consider future readability - looping has it's place, but if 60 ADD instructions are going to be easier for whoever has to maintain it to manage, then hey, pick yourself out a new subroutine and go to town!

Your other option is one giant CPT instruction. Gets it all done in one instruction, clear and concise, but of course you're still typing 60x "A+B+C+..." into it.

That's what I was going to suggest, using the jump and label, incrementing the array index each time....but likely he's not using an array, who knows.
 
I don't think the CPT instruction will compile with 60 adds in it. This is one of those cases where a conditional subroutine with indirect addressing as well as a LBL and conditional backward JMP is the best tool for the job. Unless you are working with some scan time sensitive system, that is what I would do. I would even relocate existing registers in order to get them all in one block to set this up.

Bury it in a subroutine with a nice rung comment. It is clean and easy to deal with. It may not be the most efficient for the CPU, but the ML1400 is pretty darn quick so it is unlikely to matter if the scan time spikes a couple of milliseconds when this function gets called.
 
Is there a limit to how much you can stick in a CPT function? To be honest, I've never tried to find out...

I mean, you could still whack 6 CPT's in parallel, I'm sure it can handle 10 instructions each.
 
This is one of those cases where a conditional subroutine with indirect addressing

I second the indirect addressing. Could probably do your math nice and clean like.

To many variables for me to say what exactly to do though...All running the same reference? How often is speed changed if ever? Are the speeds in sequential registers (What does this PLC have as far as block compares go)?
 
Wow, thanks for the comments guys. 1st things 1st. I tried hunting the site for "averaging" before giving up. Apologies, I will look again. Second, these rollers can run at "slightly" different speeds. Each roller is driven by its OWN belt. So, differing speeds are possible and LIKELY. Heated glass is reciprocating back and forth over these rollers, so differing speeds of 5% or more can cause defects/scratches/haze and ticked QA people.
What is "fast" and what is "slow"? I agree... it is a good question. If you had 60 students take a test and the "average" was 100pts, then the ones that scored a 108pts scored "high". The ones that scored 92 pts, scored low. Now, you know why the AVERAGE is important.
Before any other questions pop up. These rollers slow down, stop, reverse, speed up, and have fast exit and entry speeds.
The 'step it out' CPT would be simple enough if it was just A's and B's, but we all know it is more like N7:1 +N7:2=N7:3. 58 more rollers to go.
Program is from scratch so I can assign registers in any order I want.
Thanks again, guys... you're awesome!
 
The CPT can take a much longer expression than just A+B=C

Destination: N7:0

Expression: N7:1+N7:2+N7:3+N7:4+N7:5+N7:6+N7:7+N7:8+N7:9+N7:10...

Copy and paste that in and I've done 1/6th of your work for you! :)

Otherwise, if you're starting from scratch and can arrange all of your speeds in sequential registers, then as a few people have said, you can use a JMP/LBL loop and a pointer to execute ADD N7:0 N7:[Pointer] N7:0 60 times in one (or two) rungs. Easy enough, but if it were me, I'd be going the CPT option. Much simpler, much faster for the PLC to execute, much easier to see at a glance what's going on, less chance of fat fingering something and accidentally crashing your PLC. And in the amount of time it's taken me to write this post, I could probably have written out the rung. It's not such a big deal.
 
Compute Instruction.

Note the number of characters.

CPT - Compute Instruction Type: output
The CPT instruction performs copy, arithmetic, logical, and conversion
operations. You define the operation in the Expression and the result is written in
the Destination. The CPT uses functions to operate on one or more values in the
Expression to perform operations such as:
• converting from one number format to another.
• manipulating numbers.
• performing trigonometric functions.
Enter the following parameters when programming this instruction:
Expression is zero or more lines, with up to 28 characters per line, up to
255 characters.

• Destination is a word address or the address of a floating-point data
element.
 
Last edited:
Thanks Mickey! Good to know!

So, two CPT instructions will easily do the trick. You could even include your averaging math in the second one and still have room to spare
 

Similar Topics

Just installed RS500 and RSLinx on a new Win7 x64 VM. When I open RS500 and try and who active a server busy message box appears and rslinx...
Replies
3
Views
2,779
I am building a machine , and I have 3 Air Springs ( Air Bags ) that need to Inflate and Deflate very quickly. What type of valve do you recommend...
Replies
5
Views
3,192
Hey =D I'm using Unity Pro XL 4.1 to build a project involving a simulated factory. One of the goals is if we press a Emergency button, all...
Replies
2
Views
1,517
Hi there and Season's Greetings to all. It's been a few years since I connected to a slc/pv combination via rs232 and it's all gone with the...
Replies
14
Views
3,057
Hello, My name is Ettore (‘E’ for short) and I am a newbie EE straight out of University. I was recently hired by a small engineering/CAD...
Replies
19
Views
10,333
Back
Top Bottom