Brad
Dec 16 2005, 11:00 AM
I am using a CPW comand to move a word to another file were I need to multiply the word, (or would like to) instead of each bit in the word. can this be done?
TechJunki
Dec 16 2005, 11:15 AM
You can multiply a word by using the MUL function.
TWControls
Dec 16 2005, 11:20 AM
| QUOTE |
| I need to multiply the word, (or would like to) instead of each bit in the word. can this be done? |
Do you mean multipy each bit in a word or multilpy each word that you are copying by something(example need to multiply N7:0 through N7:5 by 5)
Brad
Dec 16 2005, 11:34 AM
TWControls,
Yes that is what I am trying to do. If I just use the MUL it only multiplys one bit!
TWControls
Dec 16 2005, 11:36 AM
| QUOTE |
| Yes that is what I am trying to do. |
Which one.
If what you stated is what you are trying to do, use techjunki's post.
If what I stated is what you want to do, how many are you trying to manipulate and do you need to do it in a single scan. The easiest solution depends on these things.
Brad
Dec 16 2005, 11:42 AM
TWControls,
I am trying to do what you wrote. I have copyed a word N15:0 through N15:6 and move it to N80:0 through N80:6 I need to multiply in one scan.
TechJunki
Dec 16 2005, 11:47 AM
I think you may be a little confused between a word and a bit:
A bit is addressed as N80:0/1 -- one bit (bit 1) of a 16 bit Word
The word would be N80:0 -- One 16 bit word
A group of seven words is what you are working with N80:0 to N80:6.
Are you trying to multiply all seven word together or multiply all words by a certain number??
Explain the math you want to perform??
I assume you are using a Micrologix PLC what version is it, as the instructions vary among the different series.
Brad
Dec 16 2005, 11:55 AM
You are right I am confused sorry. I am trying to multiply,
N80:0 through N80:6 by 2 at one time.
using a Micrologix 1500
TechJunki
Dec 16 2005, 12:00 PM
Just to clarify this is the math
N80:0 x 2 = N80:0
N80:1 x 2 = N80:1
N80:2 x 2 = N80:2
N80:3 x 2 = N80:3
N80:4 x 2 = N80:4
N80:5 x 2 = N80:5
N80:6 x 2 = N80:6
And you would like to do this with only one instruction??
TWControls
Dec 16 2005, 12:03 PM
For just 7 values I would use the MUL 7 times like Techjunki said. If you have a boat load of them to do might be able to do something similiar to RsLogix 5000s FOR statement but it's a real pain in RsLogix 500.
Spedley
Dec 16 2005, 12:05 PM
I don't think such an instruction exists. Your only real option (there are other more complex ones) is to have a seperate multiply for each word.
Brad
Dec 16 2005, 12:17 PM
| QUOTE (TechJunki @ Dec 16 2005, 12:00 PM) |
Just to clarify this is the math
N80:0 x 2 = N80:0 N80:1 x 2 = N80:1 N80:2 x 2 = N80:2 N80:3 x 2 = N80:3 N80:4 x 2 = N80:4 N80:5 x 2 = N80:5 N80:6 x 2 = N80:6
And you would like to do this with only one instruction?? |
Yes.
TechJunki
Dec 16 2005, 12:19 PM
I think the simplest way to do this would just be to branch 7 MUL in one rung and multiply them all individually.
There are other ways but they are unecessarily complicated for this.
Brad
Dec 16 2005, 12:21 PM
| QUOTE (TechJunki @ Dec 16 2005, 12:19 PM) |
I think the simplest way to do this would just be to branch 7 MUL in one rung and multiply them all individually.
There are other ways but they are unecessarily complicated for this. |
Easy is better. Thank-you all for your time and the help!
Alaric
Dec 17 2005, 02:19 PM
Unfortunately, FAL (which can do math operations on multiple words in a single instruction and scan) is not available on the ML1500. TechJunk has suggested the best option for for the ML1500.
hakko808
Dec 18 2005, 07:38 PM
Would a rotate instruction be helpfull here? Since multiplication by two just shifts one space left? Usually bit shifts are quicker than multiplies.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.